Skip to content

Commit

Permalink
[FLINK-21879][tests] Harden ActiveResourceManagerTest.testWorkerRegis…
Browse files Browse the repository at this point in the history
…trationTimeoutNotCountingAllocationTime

Hardens the ActiveResourceManagerTest.testWorkerRegistrationTimeoutNotCountingAllocationTime by introducing
the assumption that the registration is faster than the start worker timeout.

This closes apache#15474.
  • Loading branch information
tillrohrmann committed Apr 6, 2021
1 parent 4ffcafd commit 97f3330
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

/** Tests for {@link ActiveResourceManager}. */
public class ActiveResourceManagerTest extends TestLogger {
Expand Down Expand Up @@ -782,11 +783,19 @@ public void testWorkerRegistrationTimeoutNotCountingAllocationTime() throws Exce
fail();
}

final long start = System.nanoTime();

runInMainThread(() -> requestResourceFuture.complete(tmResourceId));

// worker registered, verify not released due to timeout
CompletableFuture<RegistrationResponse> registerTaskExecutorFuture =
registerTaskExecutor(tmResourceId);

final long registrationTime = (System.nanoTime() - start) / 1_000_000;

assumeTrue(
"The registration must not take longer than the start worker timeout. If it does, then this indicates a very slow machine.",
registrationTime < TESTING_START_WORKER_TIMEOUT_MS);
assertThat(
registerTaskExecutorFuture.get(TIMEOUT_SEC, TimeUnit.SECONDS),
instanceOf(RegistrationResponse.Success.class));
Expand Down

0 comments on commit 97f3330

Please sign in to comment.