Skip to content

Commit 078da31

Browse files
kgeisztaklwu
authored andcommitted
HBASE-29724: Backport "HBASE-25334: TestRSGroupsFallback.testFallback is flaky" into branch-2 and branch-2.6 (#7472)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
1 parent 8683cf6 commit 078da31

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsFallback.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,13 @@ public void testFallback() throws Exception {
101101
assertRegionsInGroup(tableName, FALLBACK_GROUP);
102102

103103
// add a new server to default group, regions move to default group
104-
JVMClusterUtil.RegionServerThread t =
105-
TEST_UTIL.getMiniHBaseCluster().startRegionServerAndWait(60000);
106-
Address startRSAddress = t.getRegionServer().getServerName().getAddress();
107-
TEST_UTIL.waitFor(3000,
108-
() -> rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).containsServer(startRSAddress));
104+
TEST_UTIL.getMiniHBaseCluster().startRegionServerAndWait(60000);
109105
assertTrue(master.balance().isBalancerRan());
110106
assertRegionsInGroup(tableName, RSGroupInfo.DEFAULT_GROUP);
111107

112108
// add a new server to test group, regions move back
113-
t = TEST_UTIL.getMiniHBaseCluster().startRegionServerAndWait(60000);
109+
JVMClusterUtil.RegionServerThread t =
110+
TEST_UTIL.getMiniHBaseCluster().startRegionServerAndWait(60000);
114111
rsGroupAdmin.moveServers(
115112
Collections.singleton(t.getRegionServer().getServerName().getAddress()), groupName);
116113
assertTrue(master.balance().isBalancerRan());
@@ -119,11 +116,11 @@ public void testFallback() throws Exception {
119116
TEST_UTIL.deleteTable(tableName);
120117
}
121118

122-
private void assertRegionsInGroup(TableName tableName, String group) throws IOException {
119+
private void assertRegionsInGroup(TableName table, String group) throws IOException {
123120
ProcedureTestingUtility
124121
.waitAllProcedures(TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor());
125122
RSGroupInfo groupInfo = rsGroupAdmin.getRSGroupInfo(group);
126-
master.getAssignmentManager().getRegionStates().getRegionsOfTable(tableName).forEach(region -> {
123+
master.getAssignmentManager().getRegionStates().getRegionsOfTable(table).forEach(region -> {
127124
Address regionOnServer = master.getAssignmentManager().getRegionStates()
128125
.getRegionAssignments().get(region).getAddress();
129126
assertTrue(groupInfo.getServers().contains(regionOnServer));

hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ public DeadServer getDeadServers() {
549549
* @return true if any RS are being processed as dead, false if not
550550
*/
551551
public boolean areDeadServersInProgress() throws IOException {
552-
return master.getProcedures().stream().anyMatch(p -> p instanceof ServerCrashProcedure);
552+
return master.getProcedures().stream()
553+
.anyMatch(p -> !p.isFinished() && p instanceof ServerCrashProcedure);
553554
}
554555

555556
void letRegionServersShutdown() {

hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDeadServer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.junit.Assert.assertFalse;
2121
import static org.junit.Assert.assertTrue;
2222

23-
import java.io.IOException;
2423
import java.util.List;
2524
import java.util.Set;
2625
import org.apache.hadoop.hbase.HBaseClassTestRule;
@@ -93,15 +92,19 @@ public void testIsDead() {
9392
}
9493

9594
@Test
96-
public void testCrashProcedureReplay() throws IOException {
95+
public void testCrashProcedureReplay() throws Exception {
9796
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
9897
final ProcedureExecutor<MasterProcedureEnv> pExecutor = master.getMasterProcedureExecutor();
9998
ServerCrashProcedure proc =
10099
new ServerCrashProcedure(pExecutor.getEnvironment(), hostname123, false, false);
101100

101+
pExecutor.stop();
102102
ProcedureTestingUtility.submitAndWait(pExecutor, proc);
103-
104103
assertTrue(master.getServerManager().areDeadServersInProgress());
104+
105+
ProcedureTestingUtility.restart(pExecutor);
106+
ProcedureTestingUtility.waitProcedure(pExecutor, proc);
107+
assertFalse(master.getServerManager().areDeadServersInProgress());
105108
}
106109

107110
@Test

0 commit comments

Comments
 (0)