use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class DirectoryReaderTest method setUp.
@Before
public void setUp() throws IOException {
testFolder = TestFileUtil.createTempFolder("testFiles");
jobIdentifier = new JobIdentifier("pipelineName", -1, "LATEST", "stageName", "LATEST", "buildName", 123L);
folderRoot = "/" + testFolder.getName();
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ConsoleActivityMonitor method cancelUnresponsiveJobs.
public void cancelUnresponsiveJobs(ScheduleService scheduleService) {
long currentTime = timeProvider.currentTimeMillis();
for (Map.Entry<JobIdentifier, Long> jobTimeEntry : jobLastActivityMap.entrySet()) {
long difference = currentTime - jobTimeEntry.getValue();
JobIdentifier jobIdentifier = jobTimeEntry.getKey();
if (shouldCancelHungJob(jobIdentifier, difference)) {
scheduleService.cancelJob(jobIdentifier);
try {
consoleService.appendToConsoleLog(jobIdentifier, String.format("Go cancelled this job as it has not generated any console output for more than %s minute(s)", inMinutes(jobTerminationThreshold(jobIdentifier))));
} catch (Exception e) {
LOGGER.error(String.format("Failed to update console log with reason for cancelling hung job '%s'", jobIdentifier.buildLocator()), e);
}
this.jobLastActivityMap.remove(jobIdentifier);
removeHungJobWarning(jobIdentifier);
LOGGER.info(String.format("Cancelled hung job '%s' as it was hung for more than '%s' minutes", jobIdentifier.buildLocator(), inMinutes(difference)));
} else if (difference > warningThreshold) {
LOGGER.info(String.format("Job '%s' has not updated console log for more than '%s' minutes", jobIdentifier.buildLocator(), inMinutes(difference)));
removeHungJobWarning(jobIdentifier);
addJobHungWarning(jobIdentifier, difference);
}
}
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ArtifactDirectoryChooserTest method shouldReturnAUniqueLocationForConsoleFilesWithDifferentJobIdentifiers.
@Test
public void shouldReturnAUniqueLocationForConsoleFilesWithDifferentJobIdentifiers() throws Exception {
JobIdentifier jobIdentifier = JobIdentifierMother.jobIdentifier("come", 1, "together", "1", "right");
JobIdentifier anotherJobIdentifier = JobIdentifierMother.jobIdentifier("come", 1, "together", "2", "now");
assertThat(chooser.temporaryConsoleFile(jobIdentifier).getPath(), not(equalToIgnoringCase(chooser.temporaryConsoleFile(anotherJobIdentifier).getPath())));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ArtifactDirectoryChooserTest method shouldFetchATemporaryConsoleOutLocation.
@Test
public void shouldFetchATemporaryConsoleOutLocation() throws Exception {
File consoleFile = chooser.temporaryConsoleFile(new JobIdentifier("cruise", 1, "1.1", "dev", "2", "linux-firefox", null));
String filePathSeparator = System.getProperty("file.separator");
assertThat(consoleFile.getPath(), is(String.format("data%sconsole%sd0132b209429f7dc5b9ffffe87b02a7c.log", filePathSeparator, filePathSeparator)));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class PathBasedArtifactsLocatorTest method shouldUsePipelineCounterForArtifactDirectory.
@Test
public void shouldUsePipelineCounterForArtifactDirectory() {
PathBasedArtifactsLocator locator = new PathBasedArtifactsLocator(new File("root"));
File directory = locator.directoryFor(new JobIdentifier("cruise", 1, "1.1", "dev", "2", "linux-firefox", null));
assertThat(directory, is(new File("root/pipelines/cruise/1/dev/2/linux-firefox")));
}
Aggregations