Skip to content

Commit 49266a6

Browse files
author
eddy.cao
committed
Add UT for thread count check
1 parent a55754c commit 49266a6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,21 @@ public void testCheckpointCancellationDuringUpload() throws Exception {
451451
cluster.transitionToStandby(0);
452452
cluster.transitionToActive(1);
453453

454+
GenericTestUtils.waitFor(new Supplier<Boolean>() {
455+
@Override
456+
public Boolean get() {
457+
int transferThreadCount = 0;
458+
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
459+
ThreadInfo[] threads = threadBean.getThreadInfo(
460+
threadBean.getAllThreadIds(), 1);
461+
for (ThreadInfo thread: threads) {
462+
if (thread.getThreadName().startsWith("TransferFsImageUpload")) {
463+
transferThreadCount++;
464+
}
465+
}
466+
return transferThreadCount == NUM_NNS - 1;
467+
}
468+
}, 1000, 30000);
454469

455470
// Wait to make sure background TransferFsImageUpload thread was cancelled.
456471
// This needs to be done before the next test in the suite starts, so that a

0 commit comments

Comments
 (0)