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.Assert.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.After;
028import org.junit.AfterClass;
029import org.junit.BeforeClass;
030import org.junit.Rule;
031import org.junit.rules.TestName;
032
033public class TestAdminBase {
034
035  protected final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
036  protected static Admin ADMIN;
037
038  @Rule
039  public TestName name = new TestName();
040
041  @BeforeClass
042  public static void setUpBeforeClass() throws Exception {
043    TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
044    TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
045    TEST_UTIL.getConfiguration().setInt("hbase.client.retries.number", 6);
046    TEST_UTIL.getConfiguration().setBoolean("hbase.master.enabletable.roundrobin", true);
047    TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 30);
048    TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HANDLER_COUNT, 30);
049    TEST_UTIL.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, true);
050    TEST_UTIL.startMiniCluster(3);
051    ADMIN = TEST_UTIL.getAdmin();
052  }
053
054  @AfterClass
055  public static void tearDownAfterClass() throws Exception {
056    TEST_UTIL.shutdownMiniCluster();
057  }
058
059  @After
060  public void tearDown() throws Exception {
061    for (TableDescriptor htd : ADMIN.listTableDescriptors()) {
062      TEST_UTIL.deleteTable(htd.getTableName());
063    }
064  }
065
066  protected TableState.State getStateFromMeta(TableName table) throws IOException {
067    TableState state = MetaTableAccessor.getTableState(TEST_UTIL.getConnection(), table);
068    assertNotNull(state);
069    return state.getState();
070  }
071}