use of com.epam.pipeline.manager.pipeline.PipelineRunManager in project cloud-pipeline by epam.
the class ResourceMonitoringManagerTest method testPauseOnDemand.
@Test
public void testPauseOnDemand() throws InterruptedException {
when(preferenceManager.getPreference(SystemPreferences.SYSTEM_IDLE_ACTION)).thenReturn(IdleRunAction.PAUSE.name());
LocalDateTime lastNotificationDate = mockAlreadyNotifiedRuns();
Thread.sleep(10);
resourceMonitoringManager.monitorResourceUsage();
verify(pipelineRunManager).updatePipelineRunsLastNotification(runsToUpdateCaptor.capture());
verify(notificationManager).notifyIdleRuns(runsToNotifyCaptor.capture(), eq(NotificationType.IDLE_RUN));
verify(notificationManager).notifyIdleRuns(any(), eq(NotificationType.IDLE_RUN_PAUSED));
List<PipelineRun> updatedRuns = runsToUpdateCaptor.getValue();
Assert.assertEquals(2, updatedRuns.size());
Assert.assertFalse(updatedRuns.stream().anyMatch(r -> lastNotificationDate.equals(r.getLastIdleNotificationTime())));
Assert.assertNull(updatedRuns.stream().filter(r -> r.getPodId().equals(idleOnDemandRun.getPodId())).findFirst().get().getLastIdleNotificationTime());
verify(pipelineRunManager).pauseRun(TEST_IDLE_ON_DEMAND_RUN_ID, true);
verify(pipelineRunManager, never()).pauseRun(TEST_OK_RUN_ID, true);
List<Pair<PipelineRun, Double>> runsToNotify = runsToNotifyCaptor.getValue();
Assert.assertEquals(1, runsToNotify.size());
}
use of com.epam.pipeline.manager.pipeline.PipelineRunManager in project cloud-pipeline by epam.
the class ResourceMonitoringManagerTest method testNotifyTwice.
@Test
public void testNotifyTwice() throws InterruptedException {
when(preferenceManager.getPreference(SystemPreferences.SYSTEM_IDLE_ACTION)).thenReturn(IdleRunAction.NOTIFY.name());
LocalDateTime lastNotificationDate = mockAlreadyNotifiedRuns();
Thread.sleep(10);
resourceMonitoringManager.monitorResourceUsage();
verify(pipelineRunManager).updatePipelineRunsLastNotification(runsToUpdateCaptor.capture());
verify(notificationManager).notifyIdleRuns(runsToNotifyCaptor.capture(), eq(NotificationType.IDLE_RUN));
List<PipelineRun> updatedRuns = runsToUpdateCaptor.getValue();
Assert.assertEquals(2, updatedRuns.size());
Assert.assertFalse(updatedRuns.stream().anyMatch(r -> r.getLastIdleNotificationTime().equals(lastNotificationDate)));
List<Pair<PipelineRun, Double>> runsToNotify = runsToNotifyCaptor.getValue();
Assert.assertEquals(2, runsToNotify.size());
}
Aggregations