HBASE-26481 Consider rolling upgrading from old region replication framework (#3880)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / client / TestCleanupMetaReplicaThroughConfig.java
blob66f2df6bbc8c25ddd70a389a75e7c9a83dc19631
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 java.util.List;
23 import org.apache.hadoop.hbase.HBaseClassTestRule;
24 import org.apache.hadoop.hbase.HConstants;
25 import org.apache.hadoop.hbase.master.HMaster;
26 import org.apache.hadoop.hbase.testclassification.MediumTests;
27 import org.apache.hadoop.hbase.testclassification.MiscTests;
28 import org.apache.hadoop.hbase.util.JVMClusterUtil;
29 import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
30 import org.junit.BeforeClass;
31 import org.junit.ClassRule;
32 import org.junit.Test;
33 import org.junit.experimental.categories.Category;
35 /**
36 * Make sure we will honor the {@link HConstants#META_REPLICAS_NUM}.
38 @Category({ MiscTests.class, MediumTests.class })
39 public class TestCleanupMetaReplicaThroughConfig extends MetaWithReplicasTestBase {
41 @ClassRule
42 public static final HBaseClassTestRule CLASS_RULE =
43 HBaseClassTestRule.forClass(TestCleanupMetaReplicaThroughConfig.class);
45 @BeforeClass
46 public static void setUp() throws Exception {
47 startCluster();
50 @Test
51 public void testReplicaCleanup() throws Exception {
52 ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
53 List<String> metaReplicaZnodes = zkw.getMetaReplicaNodes();
54 assertEquals(3, metaReplicaZnodes.size());
56 final HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
57 master.stop("Restarting");
58 TEST_UTIL.waitFor(30000, () -> master.isStopped());
59 TEST_UTIL.getMiniHBaseCluster().getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 1);
61 JVMClusterUtil.MasterThread newMasterThread = TEST_UTIL.getMiniHBaseCluster().startMaster();
62 final HMaster newMaster = newMasterThread.getMaster();
64 // wait until new master finished meta replica assignment logic
65 TEST_UTIL.waitFor(30000, () -> newMaster.getMasterQuotaManager() != null);
66 TEST_UTIL.waitFor(30000,
67 () -> TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes().size() == 1);