Search in sources :

Example 76 with JobInstance

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);
        }
    });
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) JobInstance(com.thoughtworks.go.domain.JobInstance) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TransactionStatus(org.springframework.transaction.TransactionStatus) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) JobStateTransition(com.thoughtworks.go.domain.JobStateTransition) TransactionCallback(org.springframework.transaction.support.TransactionCallback) Username(com.thoughtworks.go.server.domain.Username) Stage(com.thoughtworks.go.domain.Stage) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 77 with JobInstance

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

Example 78 with JobInstance

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

Example 79 with JobInstance

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

Example 80 with JobInstance

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));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobDurationStrategy(com.thoughtworks.go.server.domain.JobDurationStrategy) TestingClock(com.thoughtworks.go.util.TestingClock)

Aggregations

JobInstance (com.thoughtworks.go.domain.JobInstance)82 Test (org.junit.Test)56 Stage (com.thoughtworks.go.domain.Stage)16 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)15 Pipeline (com.thoughtworks.go.domain.Pipeline)15 JobInstances (com.thoughtworks.go.domain.JobInstances)12 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)7 Agent (com.thoughtworks.go.server.domain.Agent)6 Gson (com.google.gson.Gson)5 Stages (com.thoughtworks.go.domain.Stages)5 Map (java.util.Map)5 DurationBean (com.thoughtworks.go.dto.DurationBean)4 DateTime (org.joda.time.DateTime)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Resource (com.thoughtworks.go.config.Resource)3 DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)3 JobInstanceModel (com.thoughtworks.go.server.ui.JobInstanceModel)3