reswqa commented on code in PR #19840: URL: https://github.com/apache/flink/pull/19840#discussion_r901274198
########## flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/DeclarativeSlotManagerTest.java: ########## @@ -1449,20 +1449,70 @@ public void testProcessResourceRequirementsWithDelay() throws Exception { final JobID jobId = new JobID(); slotManager.processResourceRequirements(createResourceRequirements(jobId, 1)); - Assertions.assertEquals(0, allocatedResourceCounter.get()); - Assertions.assertEquals( - 1, scheduledExecutor.getActiveNonPeriodicScheduledTask().size()); + Assertions.assertThat(allocatedResourceCounter.get()).isEqualTo(0); + Assertions.assertThat(scheduledExecutor.getActiveNonPeriodicScheduledTask().size()) + .isEqualTo(1); final ScheduledFuture<?> future = scheduledExecutor.getActiveNonPeriodicScheduledTask().iterator().next(); - Assertions.assertEquals(delay.toMillis(), future.getDelay(TimeUnit.MILLISECONDS)); + Assertions.assertThat(future.getDelay(TimeUnit.MILLISECONDS)) + .isEqualTo(delay.toMillis()); // the second request is skipped slotManager.processResourceRequirements(createResourceRequirements(jobId, 1)); - Assertions.assertEquals( - 1, scheduledExecutor.getActiveNonPeriodicScheduledTask().size()); + Assertions.assertThat(scheduledExecutor.getActiveNonPeriodicScheduledTask().size()) + .isEqualTo(1); scheduledExecutor.triggerNonPeriodicScheduledTask(); - Assertions.assertEquals(1, allocatedResourceCounter.get()); + Assertions.assertThat(allocatedResourceCounter.get()).isEqualTo(1); + } + } + + @Test + public void testProcessResourceRequirementsWithLongDelay() throws Exception { + final ResourceTracker resourceTracker = new DefaultResourceTracker(); + final AtomicInteger allocatedResourceCounter = new AtomicInteger(0); + final ManuallyTriggeredScheduledExecutor scheduledExecutor = + new ManuallyTriggeredScheduledExecutor(); + final Duration longDelay = Duration.ofSeconds(1); + final Duration delay = Duration.ofMillis(500); + try (final DeclarativeSlotManager slotManager = + createDeclarativeSlotManagerBuilder(scheduledExecutor) + .setResourceTracker(resourceTracker) + .setRequirementCheckDelay(delay) + .setRequirementCheckLongDelay(longDelay) + .buildAndStartWithDirectExec( + ResourceManagerId.generate(), + new TestingResourceActionsBuilder() + .setAllocateResourceConsumer( + workerResourceSpec -> + allocatedResourceCounter.getAndIncrement()) + .build())) { + + final JobID jobId = new JobID(); + + slotManager.enlargeRequirementsCheckDelayOnce(); + + slotManager.processResourceRequirements(createResourceRequirements(jobId, 1)); + + Assertions.assertThat(allocatedResourceCounter.get()).isEqualTo(0); + Assertions.assertThat(scheduledExecutor.getActiveNonPeriodicScheduledTask().size()) Review Comment: ```suggestion Assertions.assertThat(scheduledExecutor.getActiveNonPeriodicScheduledTask()).hasSize(1); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org