use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldIncludeBuildLocatorForDisplay.
@Test
public void shouldIncludeBuildLocatorForDisplay() throws Exception {
JobInstance instance = JobInstanceMother.completed("job-%", JobResult.Passed);
instance.setIdentifier(new JobIdentifier("cruise-%", 1, "label-1", "dev-%", "1", "job-%", -1L));
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance);
Map json = presenter.toJsonHash();
assertThat(JsonUtils.from(json).getString("buildLocatorForDisplay"), is("cruise-%/label-1/dev-%/1/job-%"));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldNotCancelCompletedJob_becauseOfActivityAfterCompletion.
@Test
public void shouldNotCancelCompletedJob_becauseOfActivityAfterCompletion() {
DateTime now = new DateTime();
when(timeProvider.currentTimeMillis()).thenReturn(now.getMillis());
JobIdentifier jobId = new JobIdentifier("foo-pipeline", 10, "foo-10", "bar-stage", "20", "baz-build");
JobInstance job = buildingInstance(jobId);
listener.jobStatusChanged(job);
job.completing(JobResult.Passed);
job.completed(new Date());
listener.jobStatusChanged(job);
// Once a job is completed we should not track the console updates.
consoleActivityMonitor.consoleUpdatedFor(jobId);
when(timeProvider.currentTimeMillis()).thenReturn(now.plusDays(10).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verifyNoMoreInteractions(jobInstanceService);
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class ConsoleActivityMonitorTest method buildingInstance.
private JobInstance buildingInstance(JobIdentifier responsiveJob) {
JobInstance respJobInstance = new JobInstance();
respJobInstance.setIdentifier(responsiveJob);
respJobInstance.setState(JobState.Building);
return respJobInstance;
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldClearServerHealthMessageForARescheduledJob.
@Test
public void shouldClearServerHealthMessageForARescheduledJob() {
JobIdentifier rescheduledJobIdentifier = new JobIdentifier("foo", 10, "label-10", "stage", "3", "job", 10l);
JobInstance jobInstance = new JobInstance();
jobInstance.setIdentifier(rescheduledJobIdentifier);
jobInstance.setState(JobState.Rescheduled);
listener.jobStatusChanged(jobInstance);
verify(serverHealthService).removeByScope(HealthStateScope.forJob("foo", "stage", "job"));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobInstanceStatusMonitorTest method shouldSendCancelMessageIfJobIsCancelled.
@Test
public void shouldSendCancelMessageIfJobIsCancelled() throws Exception {
AgentConfig agentConfig = AgentMother.remoteAgent();
configHelper.addAgent(agentConfig);
fixture.createPipelineWithFirstStageScheduled();
AgentRuntimeInfo info = AgentRuntimeInfo.fromServer(agentConfig, true, "location", 1000000l, "OS", false);
info.setCookie("cookie");
agentRemoteHandler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
buildAssignmentService.onTimer();
assertThat(agent.messages.size(), is(1));
Work work = MessageEncoding.decodeWork(agent.messages.get(0).getData());
assertThat(work, instanceOf(BuildWork.class));
BuildAssignment assignment = ((BuildWork) work).getAssignment();
final JobInstance instance = jobInstanceService.buildByIdWithTransitions(assignment.getJobIdentifier().getBuildId());
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
jobInstanceService.cancelJob(instance);
}
});
assertThat(agent.messages.size(), is(2));
assertThat(agent.messages.get(1).getAction(), is(Action.cancelBuild));
}
Aggregations