001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.master;
019
020import static org.junit.Assert.assertFalse;
021
022import org.apache.hadoop.conf.Configuration;
023import org.apache.hadoop.hbase.HBaseClassTestRule;
024import org.apache.hadoop.hbase.HBaseTestingUtility;
025import org.apache.hadoop.hbase.testclassification.MasterTests;
026import org.apache.hadoop.hbase.testclassification.MediumTests;
027import org.apache.hadoop.hbase.util.CommonFSUtils;
028import org.junit.AfterClass;
029import org.junit.BeforeClass;
030import org.junit.ClassRule;
031import org.junit.Test;
032import org.junit.experimental.categories.Category;
033import org.slf4j.Logger;
034import org.slf4j.LoggerFactory;
035
036@Category({MasterTests.class, MediumTests.class})
037public class TestMasterNotCarryTable {
038
039  @ClassRule
040  public static final HBaseClassTestRule CLASS_RULE =
041      HBaseClassTestRule.forClass(TestMasterNotCarryTable.class);
042
043  private static final Logger LOG = LoggerFactory.getLogger(TestMasterNotCarryTable.class);
044
045  private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
046
047  private static HMaster master;
048
049  @BeforeClass
050  public static void setUp() throws Exception {
051    Configuration c = UTIL.getConfiguration();
052    // We use local filesystem.  Set it so it writes into the testdir.
053    CommonFSUtils.setRootDir(c, UTIL.getDataTestDir());
054    UTIL.startMiniZKCluster();
055    master = new HMaster(UTIL.getConfiguration());
056    master.start();
057    // As no regionservers, only wait master to create AssignmentManager.
058    while (master.getAssignmentManager() != null) {
059      LOG.debug("Wait master to create AssignmentManager");
060      Thread.sleep(1000);
061    }
062  }
063
064  @AfterClass
065  public static void tearDown() throws Exception {
066    master.stop("Shutdown");
067    UTIL.shutdownMiniZKCluster();
068  }
069
070  @Test
071  public void testMasterNotCarryTable() {
072    // The default config is false
073    assertFalse(LoadBalancer.isTablesOnMaster(UTIL.getConfiguration()));
074    assertFalse(LoadBalancer.isSystemTablesOnlyOnMaster(UTIL.getConfiguration()));
075  }
076
077  @Test
078  public void testMasterBlockCache() {
079    // no need to instantiate block cache.
080    assertFalse(master.getBlockCache().isPresent());
081  }
082
083  @Test
084  public void testMasterMOBFileCache() {
085    // no need to instantiate mob file cache.
086    assertFalse(master.getMobFileCache().isPresent());
087  }
088}