HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / rsgroup / EnableRSGroupsTestBase.java
blob9611bafc2c9e99a14d9e7ba69a94d4fb87212f13
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.rsgroup;
20 import static java.lang.Thread.sleep;
21 import static org.junit.Assert.assertTrue;
23 import java.io.IOException;
24 import org.apache.hadoop.conf.Configuration;
25 import org.apache.hadoop.hbase.HBaseTestingUtil;
26 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
27 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
28 import org.junit.AfterClass;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public abstract class EnableRSGroupsTestBase {
36 private static final Logger LOG = LoggerFactory.getLogger(TestEnableRSGroupsCompatibility.class);
38 private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
40 @BeforeClass
41 public static void setUp() throws Exception {
42 final Configuration conf = TEST_UTIL.getConfiguration();
43 conf.setBoolean(CoprocessorHost.COPROCESSORS_ENABLED_CONF_KEY, true);
44 TEST_UTIL.startMiniCluster(5);
47 @AfterClass
48 public static void tearDown() throws Exception {
49 LOG.info("to stop miniCluster");
50 TEST_UTIL.shutdownMiniCluster();
53 protected abstract void enableRSGroup(Configuration conf);
55 @Test
56 public void testEnableRSGroup() throws IOException, InterruptedException {
57 TEST_UTIL.getMiniHBaseCluster().stopMaster(0);
58 TEST_UTIL.getMiniHBaseCluster().waitOnMaster(0);
60 LOG.info("stopped master...");
61 enableRSGroup(TEST_UTIL.getMiniHBaseCluster().getConfiguration());
63 TEST_UTIL.getMiniHBaseCluster().startMaster();
64 TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(60000);
65 LOG.info("started master...");
67 // check if master started successfully
68 assertTrue(TEST_UTIL.getMiniHBaseCluster().getMaster() != null);
70 // wait RSGroupBasedLoadBalancer online
71 RSGroupBasedLoadBalancer loadBalancer =
72 (RSGroupBasedLoadBalancer) TEST_UTIL.getMiniHBaseCluster().getMaster().getLoadBalancer();
73 long start = EnvironmentEdgeManager.currentTime();
74 while (EnvironmentEdgeManager.currentTime() - start <= 60000 && !loadBalancer.isOnline()) {
75 LOG.info("waiting for rsgroup load balancer onLine...");
76 sleep(200);
79 assertTrue(loadBalancer.isOnline());