use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldNotTrackConsoleActivityFor_completedJob.
@Test
public void shouldNotTrackConsoleActivityFor_completedJob() {
JobIdentifier jobId = new JobIdentifier("foo-pipeline", 10, "foo-10", "bar-stage", "20", "baz-build");
JobInstance job = buildingInstance(jobId);
listener.jobStatusChanged(job);
Date jobStartAndCompleteTime = new Date();
when(timeProvider.currentTimeMillis()).thenReturn(jobStartAndCompleteTime.getTime());
consoleActivityMonitor.consoleUpdatedFor(jobId);
job.completing(JobResult.Passed);
job.completed(new Date());
listener.jobStatusChanged(job);
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime().plusDays(10).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verifyNoMoreInteractions(jobInstanceService);
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldClearServerHealthMessageForAnyJobCancelledExternally.
@Test
public void shouldClearServerHealthMessageForAnyJobCancelledExternally() {
DateTime now = new DateTime();
when(timeProvider.currentTimeMillis()).thenReturn(now.getMillis());
JobIdentifier unresponsiveJob = new JobIdentifier("foo", 12, "foo-10", "stage", "2", "job", 20l);
JobInstance job = buildingInstance(unresponsiveJob);
listener.jobStatusChanged(job);
job.cancel();
listener.jobStatusChanged(job);
verify(serverHealthService).removeByScope(HealthStateScope.forJob("foo", "stage", "job"));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldCancelUnresponsiveJobs.
@Test
public void shouldCancelUnresponsiveJobs() {
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);
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleServiceTest method shouldCreateTemporaryConsoleFileAndMoveIfItDoesNotExist.
@Test
public void shouldCreateTemporaryConsoleFileAndMoveIfItDoesNotExist() throws Exception {
JobIdentifier jobIdentifier = JobIdentifierMother.anyBuildIdentifier();
File temporaryConsoleLog = new File(testFolder.getRoot(), "temporary_console.log");
File finalConsoleLog = new File(testFolder.getRoot(), "final_console.log");
when(chooser.temporaryConsoleFile(jobIdentifier)).thenReturn(temporaryConsoleLog);
when(chooser.findArtifact(jobIdentifier, getConsoleOutputFolderAndFileName())).thenReturn(finalConsoleLog);
service.moveConsoleArtifacts(jobIdentifier);
assertThat(temporaryConsoleLog.exists(), is(false));
assertThat(finalConsoleLog.exists(), is(true));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleServiceTest method shouldMoveConsoleArtifacts.
@Test
public void shouldMoveConsoleArtifacts() throws Exception {
JobIdentifier jobIdentifier = JobIdentifierMother.anyBuildIdentifier();
File temporaryConsoleLog = testFolder.newFile("temporary_console.log");
File finalConsoleLog = new File(testFolder.getRoot(), "final_console.log");
when(chooser.temporaryConsoleFile(jobIdentifier)).thenReturn(temporaryConsoleLog);
when(chooser.findArtifact(jobIdentifier, getConsoleOutputFolderAndFileName())).thenReturn(finalConsoleLog);
service.moveConsoleArtifacts(jobIdentifier);
assertThat(temporaryConsoleLog.exists(), is(false));
assertThat(finalConsoleLog.exists(), is(true));
}
Aggregations