HDFS-16336. De-flake TestRollingUpgrade#testRollback (#3686)

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
Viraj Jasani 2021-11-24 19:24:11 +05:30 committed by GitHub
parent ae3ba45db5
commit e8566b3812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -22,6 +22,7 @@
import java.lang.management.ManagementFactory;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeoutException;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
@ -325,7 +326,7 @@ public void testRollback() throws Exception {
out.write(data, 0, data.length);
out.close();
checkMxBeanIsNull();
waitForNullMxBean();
startRollingUpgrade(foo, bar, file, data, cluster);
checkMxBean();
cluster.getFileSystem().rollEdits();
@ -356,6 +357,18 @@ public void testRollback() throws Exception {
}
}
private void waitForNullMxBean() throws TimeoutException, InterruptedException {
GenericTestUtils.waitFor(() -> {
try {
checkMxBeanIsNull();
return true;
} catch (Throwable t) {
LOG.error("Something went wrong.", t);
return false;
}
}, 100, 8000, "RollingUpgradeStatus is already set");
}
private static void startRollingUpgrade(Path foo, Path bar,
Path file, byte[] data,
MiniDFSCluster cluster) throws IOException {