Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
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 {
Expand Down Expand Up @@ -567,7 +568,7 @@ public void testRequirementCheckOnlyTriggeredOnce() throws Exception {
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()) {
Expand All @@ -588,6 +589,9 @@ public void testRequirementCheckOnlyTriggeredOnce() throws Exception {
createResourceRequirementsForSingleSlot();
final TaskExecutorConnection taskExecutionConnection =
createTaskExecutorConnection();
final CompletableFuture<Void> registrationFuture =
new CompletableFuture<>();
final long start = System.nanoTime();
runInMainThread(
() -> {
getSlotManager()
Expand All @@ -600,7 +604,15 @@ public void testRequirementCheckOnlyTriggeredOnce() throws Exception {
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));

Expand Down