use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class TestFailureSetup method setupPipelineInstnace.
private SavedStage setupPipelineInstnace(final boolean failStage, final String overriddenLabel, final List<Modification> modifications, final TestResultsStubbing test, final Date latestTransitionDate) {
return (SavedStage) transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
MaterialInstance materialInstance = materialRepository.findOrCreateFrom(hgMaterial);
for (Modification mod : modifications) {
mod.setMaterialInstance(materialInstance);
}
MaterialRevision rev = new MaterialRevision(hgMaterial, modifications);
materialRepository.saveMaterialRevision(rev);
Pipeline pipeline = PipelineMother.schedule(pipelineConfig, BuildCause.createManualForced(new MaterialRevisions(rev), new Username(new CaseInsensitiveString("loser"))));
if (overriddenLabel != null) {
pipeline.setLabel(overriddenLabel);
}
for (JobInstance instance : pipeline.getStages().get(0).getJobInstances()) {
for (JobStateTransition jobStateTransition : instance.getTransitions()) {
jobStateTransition.setStateChangeTime(latestTransitionDate);
}
}
dbHelper.save(pipeline);
Stage barStage = pipeline.getFirstStage();
if (failStage) {
dbHelper.failStage(barStage, latestTransitionDate);
}
test.stub(barStage);
pipelineTimeline.update();
return new SavedStage(pipeline);
}
});
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class AgentAssignmentTest method shouldIgnoreScheduledJob.
@Test
public void shouldIgnoreScheduledJob() {
JobInstance scheduled = JobInstanceMother.scheduled("dev");
agentAssignment.jobStatusChanged(scheduled);
assertThat(agentAssignment.latestActiveJobOnAgent("uuid"), Is.is(nullValue()));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class AgentAssignmentTest method shouldGetLatestActiveJobOnAgentFromDatabase.
@Test
public void shouldGetLatestActiveJobOnAgentFromDatabase() {
Pipeline pipeline = fixture.createPipelineWithFirstStageAssigned("uuid");
JobInstance expected = pipeline.getFirstStage().getJobInstances().first();
assertThat(agentAssignment.latestActiveJobOnAgent("uuid").getId(), Is.is(expected.getId()));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class AgentAssignmentTest method shouldReturnNullIfNoActiveJobOnAgent.
@Test
public void shouldReturnNullIfNoActiveJobOnAgent() {
JobInstance completed = JobInstanceMother.passed("dev");
completed.setAgentUuid("uuid");
agentAssignment.jobStatusChanged(completed);
assertThat(agentAssignment.latestActiveJobOnAgent("uuid"), is(nullValue()));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobInstanceModelTest method job.
private JobInstanceModel job(int elapsedSeconds, int etaSeconds) {
TestingClock clock = new TestingClock();
JobInstance instance = JobInstanceMother.building("job", clock.currentTime());
instance.setClock(clock);
clock.addSeconds(elapsedSeconds);
return new JobInstanceModel(instance, new JobDurationStrategy.ConstantJobDuration(etaSeconds * 1000));
}
Aggregations