This is an automated email from the ASF dual-hosted git repository.

xtsong pushed a commit to branch release-1.13
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.13 by this push:
     new ac90590  [FLINK-22074][runtime][test] Harden 
FineGrainedSlotManagerTest#testRequirementCheckOnlyTriggeredOnce in case 
deploying on a slow machine
ac90590 is described below

commit ac90590061bdb21bac56247d998aeda1ba6c5e2c
Author: Yangze Guo <[email protected]>
AuthorDate: Sun Apr 25 18:22:57 2021 +0800

    [FLINK-22074][runtime][test] Harden 
FineGrainedSlotManagerTest#testRequirementCheckOnlyTriggeredOnce in case 
deploying on a slow machine
    
    This closes #15751
---
 .../slotmanager/FineGrainedSlotManagerTest.java            | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/FineGrainedSlotManagerTest.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/FineGrainedSlotManagerTest.java
index 1870937..45d06a6 100644
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/FineGrainedSlotManagerTest.java
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/FineGrainedSlotManagerTest.java
@@ -54,6 +54,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
 
 /** Tests of {@link FineGrainedSlotManager}. */
 public class FineGrainedSlotManagerTest extends FineGrainedSlotManagerTestBase 
{
@@ -567,7 +568,7 @@ public class FineGrainedSlotManagerTest extends 
FineGrainedSlotManagerTestBase {
                 final List<CompletableFuture<Void>> checkRequirementFutures = 
new ArrayList<>();
                 checkRequirementFutures.add(new CompletableFuture<>());
                 checkRequirementFutures.add(new CompletableFuture<>());
-                final long requirementCheckDelay = 20;
+                final long requirementCheckDelay = 50;
                 
resourceAllocationStrategyBuilder.setTryFulfillRequirementsFunction(
                         (ignored1, ignored2) -> {
                             if (checkRequirementFutures.get(0).isDone()) {
@@ -588,6 +589,9 @@ public class FineGrainedSlotManagerTest extends 
FineGrainedSlotManagerTestBase {
                                     createResourceRequirementsForSingleSlot();
                             final TaskExecutorConnection 
taskExecutionConnection =
                                     createTaskExecutorConnection();
+                            final CompletableFuture<Void> registrationFuture =
+                                    new CompletableFuture<>();
+                            final long start = System.nanoTime();
                             runInMainThread(
                                     () -> {
                                         getSlotManager()
@@ -600,7 +604,15 @@ public class FineGrainedSlotManagerTest extends 
FineGrainedSlotManagerTestBase {
                                                         new SlotReport(),
                                                         
DEFAULT_TOTAL_RESOURCE_PROFILE,
                                                         
DEFAULT_SLOT_RESOURCE_PROFILE);
+                                        registrationFuture.complete(null);
                                     });
+
+                            assertFutureCompleteAndReturn(registrationFuture);
+                            final long registrationTime = (System.nanoTime() - 
start) / 1_000_000;
+                            assumeTrue(
+                                    "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.",
+                                    registrationTime < requirementCheckDelay);
+
                             
assertFutureCompleteAndReturn(checkRequirementFutures.get(0));
                             
assertFutureNotComplete(checkRequirementFutures.get(1));
 

Reply via email to