Skip to content

Commit 7b0d179

Browse files
committed
YARN-11390. TestResourceTrackerService.testNodeRemovalNormally: Shutdown nodes should be 0 now expected: <1> but was: <0>
- The hardcoded sleep what was used in the test was not the most stable solution - It was replaced with a polling assert
1 parent 5fc63f9 commit 7b0d179

File tree

1 file changed

+7
-8
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager

1 file changed

+7
-8
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.util.concurrent.ConcurrentMap;
6464
import java.util.concurrent.CountDownLatch;
6565
import java.util.concurrent.TimeUnit;
66+
import java.util.concurrent.TimeoutException;
6667
import java.util.concurrent.atomic.AtomicInteger;
6768
import java.util.function.Supplier;
6869
import javax.xml.parsers.DocumentBuilderFactory;
@@ -2961,17 +2962,15 @@ protected ResourceTrackerService createResourceTrackerService() {
29612962
}
29622963

29632964
private void pollingAssert(Supplier<Boolean> supplier, String message)
2964-
throws InterruptedException {
2965-
pollingAssert(supplier, true, message);
2965+
throws InterruptedException, TimeoutException {
2966+
GenericTestUtils.waitFor(supplier,
2967+
100, 10_000, message);
29662968
}
29672969

29682970
private <T> void pollingAssert(Supplier<T> supplier, T expected, String message)
2969-
throws InterruptedException {
2970-
long timeOut = System.currentTimeMillis() + 10_000;
2971-
while (System.currentTimeMillis() < timeOut && !Objects.equals(expected, supplier.get())) {
2972-
Thread.sleep(100);
2973-
}
2974-
Assert.assertEquals(message, expected, supplier.get());
2971+
throws InterruptedException, TimeoutException {
2972+
GenericTestUtils.waitFor(() -> Objects.equals(supplier.get(), expected),
2973+
100, 10_000, message);
29752974
}
29762975

29772976
/**

0 commit comments

Comments
 (0)