Search in sources :

Example 51 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class ReportTest method encodeAndDecodeAsMessageData.

@Test
public void encodeAndDecodeAsMessageData() throws Exception {
    AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("HostName", "ipAddress", "uuid"), AgentRuntimeStatus.Idle, null, null, true);
    JobIdentifier jobIdentifier = new JobIdentifier("pipeline", 1, "pipelinelabel", "stagename", "1", "job", 1L);
    Report report = new Report(info, jobIdentifier, JobResult.Passed);
    assertThat(MessageEncoding.decodeData(MessageEncoding.encodeData(report), Report.class), is(report));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Example 52 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class SleepWork method doWork.

@Override
public void doWork(EnvironmentVariableContext environmentVariableContext, AgentWorkContext agentWorkContext) {
    cancelLatch = new CountDownLatch(1);
    agentWorkContext.getAgentRuntimeInfo().busy(new AgentBuildingInfo("sleepwork", "sleepwork1"));
    boolean canceled = false;
    DefaultGoPublisher goPublisher = new DefaultGoPublisher(agentWorkContext.getArtifactsManipulator(), new JobIdentifier(), agentWorkContext.getRepositoryRemote(), agentWorkContext.getAgentRuntimeInfo(), "utf-8");
    try {
        if (this.sleepInMilliSeconds > 0) {
            canceled = cancelLatch.await(this.sleepInMilliSeconds, TimeUnit.MILLISECONDS);
        }
        String result = canceled ? "done_canceled" : "done";
        agentWorkContext.getArtifactsManipulator().setProperty(null, new Property(name + "_result", result));
        SystemEnvironment systemEnvironment = new SystemEnvironment();
        if (systemEnvironment.isConsoleLogsThroughWebsocketEnabled() && systemEnvironment.isWebsocketsForAgentsEnabled()) {
            goPublisher.consumeLine(format("Sleeping for %s milliseconds", this.sleepInMilliSeconds));
        }
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) CountDownLatch(java.util.concurrent.CountDownLatch) Property(com.thoughtworks.go.domain.Property)

Example 53 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class FailingTestsInPipelineTest method shouldRemoveDuplicate.

@Test
public void shouldRemoveDuplicate() {
    failingTests.add("suiteA", "testA", TestStatus.Error, new JobIdentifier("", 3, "", "", "", "job-1"));
    failingTests.add("suiteA", "testB", TestStatus.Error, new JobIdentifier("", 3, "", "", "", "job-1"));
    FailingTestsInPipeline failingTests1 = new FailingTestsInPipeline("1.3", 3);
    failingTests1.add("suiteA", "testA", TestStatus.Error, new JobIdentifier("", 4, "", "", "", "job-1"));
    failingTests1.add("suiteA", "testB", TestStatus.Error, new JobIdentifier("", 4, "", "", "", "job-2"));
    failingTests.removeDuplicateTestEntries(failingTests1);
    assertThat(failingTests.failingSuites().size(), is(1));
    List<TestInformation> tests = failingTests.failingSuites().get(0).tests();
    assertThat(tests.size(), is(1));
    assertThat(tests.get(0).getName(), is("testB"));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Example 54 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class FailingTestsInPipelineTest method shouldOrderSuitesAlphabetically.

@Test
public void shouldOrderSuitesAlphabetically() throws Exception {
    failingTests.add("suiteB", "testA", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
    failingTests.add("suiteA", "testA", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
    failingTests.add("suiteZ", "testA", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
    failingTests.add("suiteD", "testA", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
    List<TestSuite> suites = failingTests.failingSuites();
    assertThat(suites.size(), is(4));
    assertThat(suites.get(0).fullName(), is("suiteA"));
    assertThat(suites.get(1).fullName(), is("suiteB"));
    assertThat(suites.get(2).fullName(), is("suiteD"));
    assertThat(suites.get(3).fullName(), is("suiteZ"));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Example 55 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class StageTestRunsTest method removeDuplicateTestEntriesFromNonAdjacentRuns.

@Test
public void removeDuplicateTestEntriesFromNonAdjacentRuns() throws Exception {
    StageTestRuns stageTestRuns = new StageTestRuns(999, 0, 0);
    JobIdentifier jobIdentifier = new JobIdentifier(null, 1, null, null, null, "job1");
    stageTestRuns.add(10, "1.0", "suite1", "test1-2", TestStatus.Failure, jobIdentifier);
    stageTestRuns.add(10, "1.0", "suite1", "test1-1", TestStatus.Error, jobIdentifier);
    stageTestRuns.add(11, "1.1", "suite1", "test1-1", TestStatus.Error, jobIdentifier);
    stageTestRuns.add(9, "0.9", "suite1", "test1-2", TestStatus.Failure, jobIdentifier);
    stageTestRuns.removeDuplicateTestEntries();
    FailingTestsInPipeline pipeline10 = stageTestRuns.failingTestsInPipelines().get(0);
    FailingTestsInPipeline pipeline11 = stageTestRuns.failingTestsInPipelines().get(1);
    FailingTestsInPipeline pipeline09 = stageTestRuns.failingTestsInPipelines().get(2);
    assertThat(pipeline10.failingSuites().size(), is(1));
    assertThat(pipeline10.failingSuites().get(0).tests().size(), is(1));
    assertThat(pipeline11.failingSuites().size(), is(1));
    assertThat(pipeline11.failingSuites().get(0).tests().size(), is(1));
    assertThat(pipeline09.failingSuites().size(), is(0));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Aggregations

JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)113 Test (org.junit.Test)85 File (java.io.File)16 JobInstance (com.thoughtworks.go.domain.JobInstance)15 Pipeline (com.thoughtworks.go.domain.Pipeline)13 DateTime (org.joda.time.DateTime)12 Before (org.junit.Before)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 Stage (com.thoughtworks.go.domain.Stage)6 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)5 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)5 AgentMetadata (com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata)5 IOException (java.io.IOException)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Property (com.thoughtworks.go.domain.Property)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 RunIf (com.googlecode.junit.ext.RunIf)2 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)2 HeaderConstraint (com.thoughtworks.go.server.security.HeaderConstraint)2