Skip to content

Commit 6236473

Browse files
KarmaGYZxintongsong
authored andcommitted
[FLINK-22074][runtime][test] Harden FineGrainedSlotManagerTest#testRequirementCheckOnlyTriggeredOnce in case deploying on a slow machine
This closes #15751
1 parent 4c9ecac commit 6236473

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/FineGrainedSlotManagerTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import static org.junit.Assert.assertFalse;
5555
import static org.junit.Assert.assertThat;
5656
import static org.junit.Assert.assertTrue;
57+
import static org.junit.Assume.assumeTrue;
5758

5859
/** Tests of {@link FineGrainedSlotManager}. */
5960
public class FineGrainedSlotManagerTest extends FineGrainedSlotManagerTestBase {
@@ -567,7 +568,7 @@ public void testRequirementCheckOnlyTriggeredOnce() throws Exception {
567568
final List<CompletableFuture<Void>> checkRequirementFutures = new ArrayList<>();
568569
checkRequirementFutures.add(new CompletableFuture<>());
569570
checkRequirementFutures.add(new CompletableFuture<>());
570-
final long requirementCheckDelay = 20;
571+
final long requirementCheckDelay = 50;
571572
resourceAllocationStrategyBuilder.setTryFulfillRequirementsFunction(
572573
(ignored1, ignored2) -> {
573574
if (checkRequirementFutures.get(0).isDone()) {
@@ -588,6 +589,9 @@ public void testRequirementCheckOnlyTriggeredOnce() throws Exception {
588589
createResourceRequirementsForSingleSlot();
589590
final TaskExecutorConnection taskExecutionConnection =
590591
createTaskExecutorConnection();
592+
final CompletableFuture<Void> registrationFuture =
593+
new CompletableFuture<>();
594+
final long start = System.nanoTime();
591595
runInMainThread(
592596
() -> {
593597
getSlotManager()
@@ -600,7 +604,15 @@ public void testRequirementCheckOnlyTriggeredOnce() throws Exception {
600604
new SlotReport(),
601605
DEFAULT_TOTAL_RESOURCE_PROFILE,
602606
DEFAULT_SLOT_RESOURCE_PROFILE);
607+
registrationFuture.complete(null);
603608
});
609+
610+
assertFutureCompleteAndReturn(registrationFuture);
611+
final long registrationTime = (System.nanoTime() - start) / 1_000_000;
612+
assumeTrue(
613+
"The time of process requirement and register task manager must not take longer than the requirement check delay. If it does, then this indicates a very slow machine.",
614+
registrationTime < requirementCheckDelay);
615+
604616
assertFutureCompleteAndReturn(checkRequirementFutures.get(0));
605617
assertFutureNotComplete(checkRequirementFutures.get(1));
606618

0 commit comments

Comments
 (0)