From 64d4915ca800622eafe09afe717608513a7e7771 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Wed, 30 Jun 2021 08:00:17 +0800 Subject: [PATCH] HBASE-26039 TestReplicationKillRS is useless after HBASE-23956 (#3440) Signed-off-by: Michael Stack --- .../hadoop/hbase/replication/TestReplicationBase.java | 2 +- .../hbase/replication/TestReplicationKillMasterRS.java | 13 ++++++++++--- .../replication/TestReplicationKillMasterRSCompressed.java | 5 +---- .../TestReplicationKillMasterRSWithSeparateOldWALs.java | 13 +++---------- .../hadoop/hbase/replication/TestReplicationKillRS.java | 14 ++------------ .../hbase/replication/TestReplicationKillSlaveRS.java | 13 ++++++++++--- .../TestReplicationKillSlaveRSWithSeparateOldWALs.java | 12 +++--------- 7 files changed, 30 insertions(+), 42 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java index b40ee94af1..967ab75863 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java @@ -83,7 +83,7 @@ public class TestReplicationBase { protected static Configuration CONF2 = UTIL2.getConfiguration(); protected static int NUM_SLAVES1 = 1; - protected static final int NUM_SLAVES2 = 1; + protected static int NUM_SLAVES2 = 1; protected static final int NB_ROWS_IN_BATCH = 100; protected static final int NB_ROWS_IN_BIG_BATCH = NB_ROWS_IN_BATCH * 10; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java index ae99eb897a..b261b25bd8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRS.java @@ -20,20 +20,27 @@ package org.apache.hadoop.hbase.replication; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.ReplicationTests; +import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; /** - * Runs the TestReplicationKillRS test and selects the RS to kill in the master cluster - * Do not add other tests in this class. + * Runs the TestReplicationKillRS test and selects the RS to kill in the master cluster Do not add + * other tests in this class. */ @Category({ ReplicationTests.class, LargeTests.class }) public class TestReplicationKillMasterRS extends TestReplicationKillRS { @ClassRule public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestReplicationKillMasterRS.class); + HBaseClassTestRule.forClass(TestReplicationKillMasterRS.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + NUM_SLAVES1 = 2; + TestReplicationBase.setUpBeforeClass(); + } @Test public void killOneMasterRS() throws Exception { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java index e649149ca5..8cfe802734 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSCompressed.java @@ -36,12 +36,9 @@ public class TestReplicationKillMasterRSCompressed extends TestReplicationKillMa public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestReplicationKillMasterRSCompressed.class); - /** - * @throws java.lang.Exception - */ @BeforeClass public static void setUpBeforeClass() throws Exception { CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true); - TestReplicationBase.setUpBeforeClass(); + TestReplicationKillMasterRS.setUpBeforeClass(); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java index aa3aadde51..d0ceb6b395 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillMasterRSWithSeparateOldWALs.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.hadoop.hbase.replication; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -24,24 +23,18 @@ import org.apache.hadoop.hbase.testclassification.ReplicationTests; import org.apache.hadoop.hbase.wal.AbstractFSWALProvider; import org.junit.BeforeClass; import org.junit.ClassRule; -import org.junit.Test; import org.junit.experimental.categories.Category; @Category({ ReplicationTests.class, LargeTests.class }) -public class TestReplicationKillMasterRSWithSeparateOldWALs extends TestReplicationKillRS { +public class TestReplicationKillMasterRSWithSeparateOldWALs extends TestReplicationKillMasterRS { @ClassRule public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestReplicationKillMasterRSWithSeparateOldWALs.class); + HBaseClassTestRule.forClass(TestReplicationKillMasterRSWithSeparateOldWALs.class); @BeforeClass public static void setUpBeforeClass() throws Exception { CONF1.setBoolean(AbstractFSWALProvider.SEPARATE_OLDLOGDIR, true); - TestReplicationBase.setUpBeforeClass(); - } - - @Test - public void killOneMasterRS() throws Exception { - loadTableAndKillRS(UTIL1); + TestReplicationKillMasterRS.setUpBeforeClass(); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillRS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillRS.java index 360424a733..c1f0760e49 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillRS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillRS.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.replication; import static org.junit.Assert.fail; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.UnknownScannerException; import org.apache.hadoop.hbase.client.Connection; @@ -28,20 +27,11 @@ import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; -import org.apache.hadoop.hbase.testclassification.LargeTests; -import org.apache.hadoop.hbase.testclassification.ReplicationTests; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Category({ ReplicationTests.class, LargeTests.class }) -public class TestReplicationKillRS extends TestReplicationBase { - - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestReplicationKillRS.class); +public abstract class TestReplicationKillRS extends TestReplicationBase { private static final Logger LOG = LoggerFactory.getLogger(TestReplicationKillRS.class); @@ -49,7 +39,7 @@ public class TestReplicationKillRS extends TestReplicationBase { * Load up 1 tables over 2 region servers and kill a source during the upload. The failover * happens internally. WARNING this test sometimes fails because of HBASE-3515 */ - public void loadTableAndKillRS(HBaseTestingUtility util) throws Exception { + protected void loadTableAndKillRS(HBaseTestingUtility util) throws Exception { // killing the RS with hbase:meta can result into failed puts until we solve // IO fencing int rsToKill1 = util.getHBaseCluster().getServerWithMeta() == 0 ? 1 : 0; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java index 733fa3aa8d..16663f0e77 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRS.java @@ -20,20 +20,27 @@ package org.apache.hadoop.hbase.replication; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.ReplicationTests; +import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; /** - * Runs the TestReplicationKillRS test and selects the RS to kill in the slave cluster - * Do not add other tests in this class. + * Runs the TestReplicationKillRS test and selects the RS to kill in the slave cluster Do not add + * other tests in this class. */ @Category({ ReplicationTests.class, LargeTests.class }) public class TestReplicationKillSlaveRS extends TestReplicationKillRS { @ClassRule public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestReplicationKillSlaveRS.class); + HBaseClassTestRule.forClass(TestReplicationKillSlaveRS.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + NUM_SLAVES2 = 2; + TestReplicationBase.setUpBeforeClass(); + } @Test public void killOneSlaveRS() throws Exception { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java index abff3e2caf..195ad89b3e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationKillSlaveRSWithSeparateOldWALs.java @@ -24,24 +24,18 @@ import org.apache.hadoop.hbase.testclassification.ReplicationTests; import org.apache.hadoop.hbase.wal.AbstractFSWALProvider; import org.junit.BeforeClass; import org.junit.ClassRule; -import org.junit.Test; import org.junit.experimental.categories.Category; @Category({ ReplicationTests.class, LargeTests.class }) -public class TestReplicationKillSlaveRSWithSeparateOldWALs extends TestReplicationKillRS { +public class TestReplicationKillSlaveRSWithSeparateOldWALs extends TestReplicationKillSlaveRS { @ClassRule public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestReplicationKillSlaveRSWithSeparateOldWALs.class); + HBaseClassTestRule.forClass(TestReplicationKillSlaveRSWithSeparateOldWALs.class); @BeforeClass public static void setUpBeforeClass() throws Exception { CONF1.setBoolean(AbstractFSWALProvider.SEPARATE_OLDLOGDIR, true); - TestReplicationBase.setUpBeforeClass(); - } - - @Test - public void killOneSlaveRS() throws Exception { - loadTableAndKillRS(UTIL2); + TestReplicationKillSlaveRS.setUpBeforeClass(); } } -- 2.11.4.GIT