1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.rsgroup;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.hadoop.hbase.IntegrationTestingUtility;
25 import org.apache.hadoop.hbase.Waiter;
26 import org.apache.hadoop.hbase.testclassification.IntegrationTests;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.experimental.categories.Category;
30
31
32
33
34
35
36 @Category(IntegrationTests.class)
37 public class IntegrationTestRSGroup extends TestRSGroupsBase {
38
39 private final static Log LOG = LogFactory.getLog(IntegrationTestRSGroup.class);
40 private static boolean initialized = false;
41
42 @Before
43 public void beforeMethod() throws Exception {
44 if(!initialized) {
45 LOG.info("Setting up IntegrationTestGroup");
46 LOG.info("Initializing cluster with " + NUM_SLAVES_BASE + " servers");
47 TEST_UTIL = new IntegrationTestingUtility();
48 ((IntegrationTestingUtility)TEST_UTIL).initializeCluster(NUM_SLAVES_BASE);
49
50 admin = TEST_UTIL.getHBaseAdmin();
51 cluster = TEST_UTIL.getHBaseClusterInterface();
52 rsGroupAdmin = new VerifyingRSGroupAdminClient(rsGroupAdmin.newClient(TEST_UTIL.getConnection()),
53 TEST_UTIL.getConfiguration());
54 LOG.info("Done initializing cluster");
55 initialized = true;
56
57
58 afterMethod();
59 }
60 }
61
62 @After
63 public void afterMethod() throws Exception {
64 LOG.info("Cleaning up previous test run");
65
66 deleteTableIfNecessary();
67 deleteNamespaceIfNecessary();
68 deleteGroups();
69 admin.setBalancerRunning(true, true);
70
71 LOG.info("Restoring the cluster");
72 ((IntegrationTestingUtility)TEST_UTIL).restoreCluster();
73 LOG.info("Done restoring the cluster");
74
75 TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
76 @Override
77 public boolean evaluate() throws Exception {
78 LOG.info("Waiting for cleanup to finish "+ rsGroupAdmin.listRSGroups());
79
80
81 return rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getServers().size()
82 >= NUM_SLAVES_BASE;
83 }
84 });
85
86 TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
87 @Override
88 public boolean evaluate() throws Exception {
89 LOG.info("Waiting for regionservers to be registered "+ rsGroupAdmin.listRSGroups());
90
91
92 return rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getServers().size()
93 == getNumServers();
94 }
95 });
96
97 LOG.info("Done cleaning up previous test run");
98 }
99 }