use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class TestSuiteTest method testContainsTestName.
@Test
public void testContainsTestName() {
testSuite.addTest("testB", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
testSuite.addTest("testA", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
assertThat(testSuite.contains("testA"), is(true));
assertThat(testSuite.contains("testB"), is(true));
assertThat(testSuite.contains("testC"), is(false));
assertThat(testSuite.contains(""), is(false));
assertThat(testSuite.contains(null), is(false));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldOnlyMonitorConsoleActivityForBuildingJobs.
@Test
public void shouldOnlyMonitorConsoleActivityForBuildingJobs() {
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1971, 1, 1, 0, 55, 59, 0).getMillis());
JobIdentifier unresponsiveJob = new JobIdentifier("pipelines", 10, "label-10", "stage", "3", "job", 25l);
consoleActivityMonitor.consoleUpdatedFor(unresponsiveJob);
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 5, 0, 0).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verifyNoMoreInteractions(jobInstanceService);
verifyNoMoreInteractions(scheduleService);
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldNotCancelJobIfJobTimeOutIsSetTo0.
@Test
public void shouldNotCancelJobIfJobTimeOutIsSetTo0() {
JobIdentifier unresponsiveJob = new JobIdentifier("pipelines", 10, "label-10", "stage", "3", "job", 25l);
listener.jobStatusChanged(buildingInstance(unresponsiveJob));
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1971, 1, 1, 0, 55, 59, 0).getMillis());
consoleActivityMonitor.consoleUpdatedFor(unresponsiveJob);
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 1, 0, 0).getMillis());
when(goConfigService.canCancelJobIfHung(unresponsiveJob)).thenReturn(false);
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verify(scheduleService, never()).cancelJob(unresponsiveJob);
verifyNoMoreInteractions(jobInstanceService);
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldSetServerHealthMessageWhenJobSeemsUnresponsive.
@Test
public void shouldSetServerHealthMessageWhenJobSeemsUnresponsive() {
DateTime now = new DateTime();
when(timeProvider.currentTimeMillis()).thenReturn(now.getMillis());
JobIdentifier job = new JobIdentifier("foo", 12, "foo-10", "stage", "2", "job", 20l);
listener.jobStatusChanged(buildingInstance(job));
// just over warning time limit i.e. 2 minutes
when(timeProvider.currentTimeMillis()).thenReturn(now.plusMinutes(2).plusSeconds(1).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verify(serverHealthService).update(ServerHealthState.warningWithHtml("Job 'foo/stage/job' is not responding", "Job <a href='/go/tab/build/detail/foo/12/stage/2/job'>foo/stage/job</a> is currently running but has not shown any console activity in the last 2 minute(s). This job may be hung.", HealthStateType.general(HealthStateScope.forJob("foo", "stage", "job"))));
// after 4 minutes
when(timeProvider.currentTimeMillis()).thenReturn(now.plusMinutes(4).plusSeconds(1).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verify(serverHealthService).update(ServerHealthState.warningWithHtml("Job 'foo/stage/job' is not responding", "Job <a href='/go/tab/build/detail/foo/12/stage/2/job'>foo/stage/job</a> is currently running but has not shown any console activity in the last 4 minute(s). This job may be hung.", HealthStateType.general(HealthStateScope.forJob("foo", "stage", "job"))));
// 6 hours
when(goConfigService.getUnresponsiveJobTerminationThreshold(any(JobIdentifier.class))).thenReturn(360 * 60 * 1000L);
// after 62 minutes
when(timeProvider.currentTimeMillis()).thenReturn(now.plusHours(1).plusMinutes(2).plusSeconds(1).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verify(serverHealthService).update(ServerHealthState.warningWithHtml("Job 'foo/stage/job' is not responding", "Job <a href='/go/tab/build/detail/foo/12/stage/2/job'>foo/stage/job</a> is currently running but has not shown any console activity in the last 62 minute(s). This job may be hung.", HealthStateType.general(HealthStateScope.forJob("foo", "stage", "job"))));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldCancelUnresponsiveJobAndLetOtherJobComplete.
@Test
public void shouldCancelUnresponsiveJobAndLetOtherJobComplete() {
JobIdentifier unresponsiveJob = new JobIdentifier("pipelines", 10, "label-10", "stage", "3", "job", 25l);
listener.jobStatusChanged(buildingInstance(unresponsiveJob));
JobIdentifier responsiveJob = new JobIdentifier("foo", 12, "foo-10", "stage", "2", "job", 20l);
listener.jobStatusChanged(buildingInstance(responsiveJob));
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1971, 1, 1, 0, 55, 59, 0).getMillis());
consoleActivityMonitor.consoleUpdatedFor(unresponsiveJob);
consoleActivityMonitor.consoleUpdatedFor(responsiveJob);
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 0, 0, 0).getMillis());
consoleActivityMonitor.consoleUpdatedFor(responsiveJob);
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 1, 0, 0).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verify(scheduleService).cancelJob(unresponsiveJob);
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verifyNoMoreInteractions(jobInstanceService);
}
Aggregations