HBASE-23723 Ensure MOB compaction works in optimized mode after snapshot clone (...
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / replication / TestSerialReplicationFailover.java
blob324a69fa8a8dd0054d423e0adf2c3d6a7afb1cb8
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.replication;
20 import java.io.IOException;
21 import org.apache.hadoop.hbase.HBaseClassTestRule;
22 import org.apache.hadoop.hbase.HConstants;
23 import org.apache.hadoop.hbase.TableName;
24 import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
25 import org.apache.hadoop.hbase.client.Put;
26 import org.apache.hadoop.hbase.client.Table;
27 import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
28 import org.apache.hadoop.hbase.testclassification.MediumTests;
29 import org.apache.hadoop.hbase.testclassification.ReplicationTests;
30 import org.apache.hadoop.hbase.util.Bytes;
31 import org.apache.hadoop.hbase.util.CommonFSUtils.StreamLacksCapabilityException;
32 import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
33 import org.junit.Before;
34 import org.junit.ClassRule;
35 import org.junit.Test;
36 import org.junit.experimental.categories.Category;
38 @Category({ ReplicationTests.class, MediumTests.class })
39 public class TestSerialReplicationFailover extends SerialReplicationTestBase {
41 @ClassRule
42 public static final HBaseClassTestRule CLASS_RULE =
43 HBaseClassTestRule.forClass(TestSerialReplicationFailover.class);
45 @Before
46 public void setUp() throws IOException, StreamLacksCapabilityException {
47 setupWALWriter();
48 // add in disable state, so later when enabling it all sources will start push together.
49 addPeer(false);
52 @Test
53 public void testKillRS() throws Exception {
54 TableName tableName = TableName.valueOf(name.getMethodName());
55 UTIL.getAdmin().createTable(
56 TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder
57 .newBuilder(CF).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build()).build());
58 UTIL.waitTableAvailable(tableName);
59 try (Table table = UTIL.getConnection().getTable(tableName)) {
60 for (int i = 0; i < 100; i++) {
61 table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
64 RegionServerThread thread = UTIL.getMiniHBaseCluster().getRegionServerThreads().stream()
65 .filter(t -> !t.getRegionServer().getRegions(tableName).isEmpty()).findFirst().get();
66 thread.getRegionServer().abort("for testing");
67 thread.join();
68 try (Table table = UTIL.getConnection().getTable(tableName)) {
69 for (int i = 100; i < 200; i++) {
70 table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
73 enablePeerAndWaitUntilReplicationDone(200);
74 checkOrder(200);