Search in sources :

Example 96 with JobIdentifier

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();
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Before(org.junit.Before)

Example 97 with JobIdentifier

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);
        }
    }
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Example 98 with JobIdentifier

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())));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Example 99 with JobIdentifier

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)));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 100 with JobIdentifier

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")));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) File(java.io.File) Test(org.junit.Test)

Aggregations

JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)100 Test (org.junit.Test)74 JobInstance (com.thoughtworks.go.domain.JobInstance)17 Pipeline (com.thoughtworks.go.domain.Pipeline)16 File (java.io.File)15 DateTime (org.joda.time.DateTime)12 Stage (com.thoughtworks.go.domain.Stage)9 Before (org.junit.Before)8 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 LogFile (com.thoughtworks.go.server.domain.LogFile)5 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)4 Property (com.thoughtworks.go.domain.Property)3 Username (com.thoughtworks.go.server.domain.Username)3 IOException (java.io.IOException)3 Expectations (org.jmock.Expectations)3 RunIf (com.googlecode.junit.ext.RunIf)2 Tabs (com.thoughtworks.go.config.Tabs)2 Properties (com.thoughtworks.go.domain.Properties)2