Skip to content

Commit e8566b3

Browse files
authored
HDFS-16336. De-flake TestRollingUpgrade#testRollback (#3686)
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
1 parent ae3ba45 commit e8566b3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.lang.management.ManagementFactory;
2323
import java.util.concurrent.CountDownLatch;
2424
import java.util.concurrent.ThreadLocalRandom;
25+
import java.util.concurrent.TimeoutException;
2526

2627
import javax.management.AttributeNotFoundException;
2728
import javax.management.InstanceNotFoundException;
@@ -325,7 +326,7 @@ public void testRollback() throws Exception {
325326
out.write(data, 0, data.length);
326327
out.close();
327328

328-
checkMxBeanIsNull();
329+
waitForNullMxBean();
329330
startRollingUpgrade(foo, bar, file, data, cluster);
330331
checkMxBean();
331332
cluster.getFileSystem().rollEdits();
@@ -356,6 +357,18 @@ public void testRollback() throws Exception {
356357
}
357358
}
358359

360+
private void waitForNullMxBean() throws TimeoutException, InterruptedException {
361+
GenericTestUtils.waitFor(() -> {
362+
try {
363+
checkMxBeanIsNull();
364+
return true;
365+
} catch (Throwable t) {
366+
LOG.error("Something went wrong.", t);
367+
return false;
368+
}
369+
}, 100, 8000, "RollingUpgradeStatus is already set");
370+
}
371+
359372
private static void startRollingUpgrade(Path foo, Path bar,
360373
Path file, byte[] data,
361374
MiniDFSCluster cluster) throws IOException {

0 commit comments

Comments
 (0)