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.client; 019 020import static org.junit.jupiter.api.Assertions.assertNotNull; 021 022import java.io.IOException; 023import org.apache.hadoop.hbase.HBaseTestingUtil; 024import org.apache.hadoop.hbase.HConstants; 025import org.apache.hadoop.hbase.MetaTableAccessor; 026import org.apache.hadoop.hbase.TableName; 027import org.junit.jupiter.api.AfterAll; 028import org.junit.jupiter.api.AfterEach; 029import org.junit.jupiter.api.BeforeAll; 030import org.junit.jupiter.api.BeforeEach; 031import org.junit.jupiter.api.TestInfo; 032 033public class TestAdminBase { 034 035 protected final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); 036 protected static Admin ADMIN; 037 038 protected String methodName; 039 040 @BeforeEach 041 public void setUpMethodName(TestInfo info) { 042 this.methodName = info.getTestMethod().get().getName(); 043 } 044 045 @BeforeAll 046 public static void setUpBeforeClass() throws Exception { 047 TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100); 048 TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250); 049 TEST_UTIL.getConfiguration().setInt("hbase.client.retries.number", 6); 050 TEST_UTIL.getConfiguration().setBoolean("hbase.master.enabletable.roundrobin", true); 051 TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 30); 052 TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HANDLER_COUNT, 30); 053 TEST_UTIL.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, true); 054 TEST_UTIL.startMiniCluster(3); 055 ADMIN = TEST_UTIL.getAdmin(); 056 } 057 058 @AfterAll 059 public static void tearDownAfterClass() throws Exception { 060 TEST_UTIL.shutdownMiniCluster(); 061 } 062 063 @AfterEach 064 public void tearDown() throws Exception { 065 for (TableDescriptor htd : ADMIN.listTableDescriptors()) { 066 TEST_UTIL.deleteTable(htd.getTableName()); 067 } 068 } 069 070 protected TableState.State getStateFromMeta(TableName table) throws IOException { 071 TableState state = MetaTableAccessor.getTableState(TEST_UTIL.getConnection(), table); 072 assertNotNull(state); 073 return state.getState(); 074 } 075}