Skip to content

Commit 19263fa

Browse files
sunhellykgeisz
authored andcommitted
HBASE-29724: Backport "HBASE-25334: TestRSGroupsFallback.testFallback is flaky" into branch-2 and branch-2.6
1 parent 1da3ccb commit 19263fa

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
3434
import org.apache.hadoop.hbase.testclassification.MediumTests;
3535
import org.apache.hadoop.hbase.util.Bytes;
36-
import org.apache.hadoop.hbase.util.JVMClusterUtil;
3736
import org.junit.After;
3837
import org.junit.AfterClass;
3938
import org.junit.Before;
@@ -101,32 +100,28 @@ public void testFallback() throws Exception {
101100
assertRegionsInGroup(tableName, FALLBACK_GROUP);
102101

103102
// 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));
109-
assertTrue(master.balance().isBalancerRan());
103+
TEST_UTIL.getMiniHBaseCluster().startRegionServerAndWait(60000);
104+
assertTrue(MASTER.balance());
110105
assertRegionsInGroup(tableName, RSGroupInfo.DEFAULT_GROUP);
111106

112107
// add a new server to test group, regions move back
113108
t = TEST_UTIL.getMiniHBaseCluster().startRegionServerAndWait(60000);
114109
rsGroupAdmin.moveServers(
115110
Collections.singleton(t.getRegionServer().getServerName().getAddress()), groupName);
116-
assertTrue(master.balance().isBalancerRan());
111+
assertTrue(MASTER.balance());
117112
assertRegionsInGroup(tableName, groupName);
118113

119114
TEST_UTIL.deleteTable(tableName);
120115
}
121116

122-
private void assertRegionsInGroup(TableName tableName, String group) throws IOException {
117+
private void assertRegionsInGroup(TableName table, String group) throws IOException {
123118
ProcedureTestingUtility
124119
.waitAllProcedures(TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor());
125-
RSGroupInfo groupInfo = rsGroupAdmin.getRSGroupInfo(group);
126-
master.getAssignmentManager().getRegionStates().getRegionsOfTable(tableName).forEach(region -> {
127-
Address regionOnServer = master.getAssignmentManager().getRegionStates()
120+
RSGroupInfo rsGroup = ADMIN.getRSGroup(group);
121+
MASTER.getAssignmentManager().getRegionStates().getRegionsOfTable(table).forEach(region -> {
122+
Address regionOnServer = MASTER.getAssignmentManager().getRegionStates()
128123
.getRegionAssignments().get(region).getAddress();
129-
assertTrue(groupInfo.getServers().contains(regionOnServer));
124+
assertTrue(rsGroup.getServers().contains(regionOnServer));
130125
});
131126
}
132127

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)