HBASE-24033 Add ut for loading the corrupt recovered hfiles (#1322)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / client / TestAsyncToolAdminApi.java
blobbc78aaa0a621f0c45d4845732ff3c723cf3bce30
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.client;
20 import static org.junit.Assert.assertEquals;
22 import org.apache.hadoop.hbase.HBaseClassTestRule;
23 import org.apache.hadoop.hbase.testclassification.ClientTests;
24 import org.apache.hadoop.hbase.testclassification.MediumTests;
25 import org.junit.ClassRule;
26 import org.junit.Test;
27 import org.junit.experimental.categories.Category;
28 import org.junit.runner.RunWith;
29 import org.junit.runners.Parameterized;
31 /**
32 * Test the admin operations for Balancer, Normalizer, CleanerChore, and CatalogJanitor.
34 @RunWith(Parameterized.class)
35 @Category({ MediumTests.class, ClientTests.class })
36 public class TestAsyncToolAdminApi extends TestAsyncAdminBase {
38 @ClassRule
39 public static final HBaseClassTestRule CLASS_RULE =
40 HBaseClassTestRule.forClass(TestAsyncToolAdminApi.class);
42 @Test
43 public void testBalancer() throws Exception {
44 boolean initialState = admin.isBalancerEnabled().get();
46 // Start the balancer, wait for it.
47 boolean prevState = admin.balancerSwitch(!initialState).get();
49 // The previous state should be the original state we observed
50 assertEquals(initialState, prevState);
52 // Current state should be opposite of the original
53 assertEquals(!initialState, admin.isBalancerEnabled().get());
55 // Reset it back to what it was
56 prevState = admin.balancerSwitch(initialState).get();
58 // The previous state should be the opposite of the initial state
59 assertEquals(!initialState, prevState);
61 // Current state should be the original state again
62 assertEquals(initialState, admin.isBalancerEnabled().get());
65 @Test
66 public void testNormalizer() throws Exception {
67 boolean initialState = admin.isNormalizerEnabled().get();
69 // flip state
70 boolean prevState = admin.normalizerSwitch(!initialState).get();
72 // The previous state should be the original state we observed
73 assertEquals(initialState, prevState);
75 // Current state should be opposite of the original
76 assertEquals(!initialState, admin.isNormalizerEnabled().get());
78 // Reset it back to what it was
79 prevState = admin.normalizerSwitch(initialState).get();
81 // The previous state should be the opposite of the initial state
82 assertEquals(!initialState, prevState);
84 // Current state should be the original state again
85 assertEquals(initialState, admin.isNormalizerEnabled().get());
88 @Test
89 public void testCleanerChore() throws Exception {
90 boolean initialState = admin.isCleanerChoreEnabled().get();
92 // flip state
93 boolean prevState = admin.cleanerChoreSwitch(!initialState).get();
95 // The previous state should be the original state we observed
96 assertEquals(initialState, prevState);
98 // Current state should be opposite of the original
99 assertEquals(!initialState, admin.isCleanerChoreEnabled().get());
101 // Reset it back to what it was
102 prevState = admin.cleanerChoreSwitch(initialState).get();
104 // The previous state should be the opposite of the initial state
105 assertEquals(!initialState, prevState);
107 // Current state should be the original state again
108 assertEquals(initialState, admin.isCleanerChoreEnabled().get());
111 @Test
112 public void testCatalogJanitor() throws Exception {
113 boolean initialState = admin.isCatalogJanitorEnabled().get();
115 // flip state
116 boolean prevState = admin.catalogJanitorSwitch(!initialState).get();
118 // The previous state should be the original state we observed
119 assertEquals(initialState, prevState);
121 // Current state should be opposite of the original
122 assertEquals(!initialState, admin.isCatalogJanitorEnabled().get());
124 // Reset it back to what it was
125 prevState = admin.catalogJanitorSwitch(initialState).get();
127 // The previous state should be the opposite of the initial state
128 assertEquals(!initialState, prevState);
130 // Current state should be the original state again
131 assertEquals(initialState, admin.isCatalogJanitorEnabled().get());