use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class RestfulService method findJob.
/**
* buildId should only be given when caller is absolutely sure about the job instance
* (makes sense in agent-uploading artifacts/properties scenario because agent won't run a job if its copied over(it only executes real jobs)) -JJ
*/
public JobIdentifier findJob(String pipelineName, String counterOrLabel, String stageName, String stageCounter, String buildName, Long buildId) {
JobConfigIdentifier jobConfig = goConfigService.translateToActualCase(new JobConfigIdentifier(pipelineName, stageName, buildName));
Pipeline pipeline = pipelineService.findPipelineByCounterOrLabel(jobConfig.getPipelineName(), counterOrLabel);
stageCounter = StringUtils.isEmpty(stageCounter) ? JobIdentifier.LATEST : stageCounter;
StageIdentifier stageIdentifier = translateStageCounter(pipeline.getIdentifier(), jobConfig.getStageName(), stageCounter);
JobIdentifier jobId;
if (buildId == null) {
jobId = jobResolverService.actualJobIdentifier(new JobIdentifier(stageIdentifier, jobConfig.getJobName()));
} else {
jobId = new JobIdentifier(stageIdentifier, jobConfig.getJobName(), buildId);
}
if (jobId == null) {
//fix for #5739
throw new JobNotFoundException(pipelineName, stageName, buildName);
}
return jobId;
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ShineDaoIntegrationTest method shouldHandleExceptionsWhenTryingToPullUpTrace.
@Test
public void shouldHandleExceptionsWhenTryingToPullUpTrace() throws Exception {
stageId = failureSetup.setupPipelineInstance(false, null, goURLRepository).stageId;
FailureDetails details = shineDao.failureDetailsForTest(new JobIdentifier(stageId, "job1"), "testSuite1", "test1", result);
assertThat(details.getMessage(), is("NOT_YET_AVAILABLE"));
assertThat(details.getStackTrace(), is("NOT_YET_AVAILABLE"));
assertThat("not successful", result.isSuccessful(), is(false));
assertThat(result.replacementContent(localizer), is("Unable to retrieve failure results."));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ShineDaoIntegrationTest method shouldBeAbleToPullUpStackTrace.
@Test
public void shouldBeAbleToPullUpStackTrace() {
FailureDetails failureDetails = shineDao.failureDetailsForTest(new JobIdentifier(stageId, "WinBuild"), "testSuite1", "test1", result);
assertThat(failureDetails.getMessage(), is("Something assert failed..."));
assertThat(failureDetails.getStackTrace(), is("junit.framework.AssertionFailedError: Something assert failed..."));
failureDetails = shineDao.failureDetailsForTest(new JobIdentifier(stageId, "WinBuild"), "testSuite1", "test2", result);
assertThat(failureDetails.getMessage(), is("Something went wrong"));
assertThat(failureDetails.getStackTrace(), is("com.foo.MyException: Something went wrong..."));
failureDetails = shineDao.failureDetailsForTest(new JobIdentifier(stageId, "NixBuild"), "testSuite1", "test1", result);
assertThat(failureDetails.getMessage(), is("Something assert failed..."));
assertThat(failureDetails.getStackTrace(), is("junit.framework.AssertionFailedError: Something assert failed..."));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class StageNotificationServiceTest method shouldSendEmailWithFailureDetails.
@Test
public void shouldSendEmailWithFailureDetails() throws Exception {
final String expectedBaseUrl = String.format("http://test.host:8153");
String jezMail = prepareOneMatchedUser();
final Date date = new Date();
stubPipelineAndStage(date);
final TestSuite suite1 = new TestSuite("com.thoughtworks.go.FailOne");
suite1.addTest("shouldCompile", TestStatus.Error, new JobIdentifier(stageIdentifier, "compile"));
suite1.addTest("shouldPass", TestStatus.Failure, new JobIdentifier(stageIdentifier, "test"));
suite1.addTest("shouldPass", TestStatus.Failure, new JobIdentifier(stageIdentifier, "twist"));
suite1.addTest("shouldCompile2", TestStatus.Failure, new JobIdentifier(stageIdentifier, "compile"));
final TestSuite suite2 = new TestSuite("com.thoughtworks.go.FailTwo");
suite2.addTest("shouldCompile", TestStatus.Error, new JobIdentifier(stageIdentifier, "test"));
suite2.addTest("shouldTest", TestStatus.Failure, new JobIdentifier(stageIdentifier, "test"));
when(serverConfigService.siteUrlFor(anyString(), eq(false))).thenAnswer(new Answer<String>() {
public String answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
return morphURl((String) args[0], expectedBaseUrl);
}
});
when(systemEnvironment.isShineEnabled()).thenReturn(true);
when(shineDao.failedTestsFor(stageIdentifier)).thenReturn(Arrays.asList(suite1, suite2));
stageNotificationService.sendNotifications(stageIdentifier, StageEvent.Fails, new Username(new CaseInsensitiveString("loser")));
String body = inMemoryEmailNotificationTopic.getBody(jezMail);
assertThat(body, containsString(StageNotificationService.FAILED_TEST_SECTION));
String restOfThebody = textAfter(body, StageNotificationService.FAILED_TEST_SECTION);
String failuresText = restOfThebody.substring(0, restOfThebody.indexOf(StageNotificationService.MATERIAL_SECTION_HEADER));
assertEquals("\n\nThe following tests failed in pipeline 'go' (instance 'go-1'):\n\n" + "* com.thoughtworks.go.FailOne\n" + " shouldCompile\n" + " Errored on 'compile' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/compile)\n" + " shouldCompile2\n" + " Failed on 'compile' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/compile)\n" + " shouldPass\n" + " Failed on 'test' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/test)\n" + " Failed on 'twist' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/twist)\n" + "\n\n* com.thoughtworks.go.FailTwo\n" + " shouldCompile\n" + " Errored on 'test' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/test)\n" + " shouldTest\n" + " Failed on 'test' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/test)\n\n\n", failuresText);
}
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"));
}
Aggregations