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; 021import static org.junit.Assert.assertNull; 022 023import org.apache.hadoop.conf.Configuration; 024import org.apache.hadoop.hbase.HBaseClassTestRule; 025import org.apache.hadoop.hbase.HBaseTestingUtility; 026import org.apache.hadoop.hbase.regionserver.ChunkCreator; 027import org.apache.hadoop.hbase.testclassification.MasterTests; 028import org.apache.hadoop.hbase.testclassification.MediumTests; 029import org.apache.hadoop.hbase.util.FSUtils; 030import org.junit.AfterClass; 031import org.junit.BeforeClass; 032import org.junit.ClassRule; 033import org.junit.Test; 034import org.junit.experimental.categories.Category; 035import org.slf4j.Logger; 036import org.slf4j.LoggerFactory; 037 038@Category({MasterTests.class, MediumTests.class}) 039public class TestMasterNotCarryTable { 040 041 @ClassRule 042 public static final HBaseClassTestRule CLASS_RULE = 043 HBaseClassTestRule.forClass(TestMasterNotCarryTable.class); 044 045 private static final Logger LOG = LoggerFactory.getLogger(TestMasterNotCarryTable.class); 046 047 private static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); 048 049 private static HMaster master; 050 051 @BeforeClass 052 public static void setUp() throws Exception { 053 Configuration c = UTIL.getConfiguration(); 054 // We use local filesystem. Set it so it writes into the testdir. 055 FSUtils.setRootDir(c, UTIL.getDataTestDir()); 056 UTIL.startMiniZKCluster(); 057 master = new HMaster(UTIL.getConfiguration()); 058 master.start(); 059 // As no regionservers, only wait master to create AssignmentManager. 060 while (master.getAssignmentManager() != null) { 061 LOG.debug("Wait master to create AssignmentManager"); 062 Thread.sleep(1000); 063 } 064 } 065 066 @AfterClass 067 public static void tearDown() throws Exception { 068 master.stop("Shutdown"); 069 UTIL.shutdownMiniZKCluster(); 070 } 071 072 @Test 073 public void testMasterNotCarryTable() { 074 // The default config is false 075 assertFalse(LoadBalancer.isTablesOnMaster(UTIL.getConfiguration())); 076 assertFalse(LoadBalancer.isSystemTablesOnlyOnMaster(UTIL.getConfiguration())); 077 } 078 079 @Test 080 public void testMasterBlockCache() { 081 // no need to instantiate block cache. 082 assertNull(master.getCacheConfig().getBlockCache()); 083 } 084 085 @Test 086 public void testMasterMemStoreLAB() { 087 // no need to instantiate MemStoreLAB. 088 assertNull(ChunkCreator.getInstance()); 089 } 090}