use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldNotTriggerPipelineWhenItHasAlreadyRunWithPeggedRevisions.
@Test
public void shouldNotTriggerPipelineWhenItHasAlreadyRunWithPeggedRevisions() throws Exception {
// p1 <- SVN
// | /
// v v
// p2 <- git
SvnMaterial svn = u.wf(new SvnMaterial("url", "username", "password", false), "folder1");
u.checkinInOrder(svn, "s1", "s2");
GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
u.checkinFile(git, "g1", new File("some_file.txt"), ModifiedAction.modified);
u.checkinFile(git, "g2", new File("some_new_file.txt"), ModifiedAction.modified);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(svn));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1), u.m(svn), u.m(git));
String p1_1 = u.runAndPass(p1, "s1");
String p2_1 = u.runAndPass(p2, p1_1, "s1", "g1");
String p2_2 = u.runAndPass(p2, p1_1, "s1", "g2");
MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, true, "s2"), u.mr(git, true, "g2") });
MaterialRevisions previousRevisions = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, true, "s1"), u.mr(git, true, "g1") });
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p2.config.name().toString(), systemEnvironment, materialChecker, serverHealthService);
pipelineTimeline.update();
BuildCause buildCause = autoBuild.onModifications(given, false, previousRevisions);
assertThat(buildCause, is(nullValue()));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsIntegrationTest method shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid.
@Test
public void shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid() throws Exception {
AgentConfig agentConfig = AgentMother.localAgent();
AgentInstance instance = agent(agentConfig);
BuildCause buildCause = modifySomeFiles(evolveConfig);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
buildAssignmentService.onTimer();
Stage stage = pipeline.getFirstStage();
JobInstance jobInstance = stage.getJobInstances().get(0);
jobInstance.setAgentUuid(agentConfig.getUuid());
jobInstance.changeState(JobState.Building);
pipelineDao.saveWithStages(pipeline);
buildAssignmentService.onTimer();
buildAssignmentService.assignWorkToAgent(instance);
buildAssignmentService.onTimer();
buildAssignmentService.assignWorkToAgent(instance);
final Stage reloadedStage = stageDao.stageById(stage.getId());
final JobInstance rescheduledJob = reloadedStage.getJobInstances().getByName(jobInstance.getName());
assertThat(rescheduledJob.getState(), is(JobState.Assigned));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldLogWithInfoIfPipelineISScheduled.
@Test
public void shouldLogWithInfoIfPipelineISScheduled() throws Exception {
try (LogFixture logging = logFixtureFor(PipelineScheduleQueue.class, Level.DEBUG)) {
JobConfigs jobConfigs = new JobConfigs();
Resources resources = new Resources(new Resource("resource1"));
ArtifactPlans artifactPlans = new ArtifactPlans();
ArtifactPropertiesGenerators generators = new ArtifactPropertiesGenerators();
generators.add(new ArtifactPropertiesGenerator("property-name", "artifact-path", "artifact-xpath"));
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test-job"), resources, artifactPlans, generators);
jobConfigs.add(jobConfig);
StageConfig stage = new StageConfig(new CaseInsensitiveString("test-stage"), jobConfigs);
MaterialConfigs materialConfigs = new MaterialConfigs(MaterialConfigsMother.dependencyMaterialConfig());
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("test-pipeline"), materialConfigs, stage);
configFileEditor.addPipeline(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stage.name()));
BuildCause cause = modifySomeFiles(pipelineConfig, ModificationsMother.nextRevision());
saveRev(cause);
queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
assertThat(logging.getLog(), containsString("[Pipeline Schedule] Successfully scheduled pipeline test-pipeline, buildCause:[ModificationBuildCause: triggered by " + cause.getMaterialRevisions().latestRevision() + "]"));
}
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldCreateMultipleJobsIfRunMultipleInstanceIsSet.
@Test
public void shouldCreateMultipleJobsIfRunMultipleInstanceIsSet() throws Exception {
JobConfigs jobConfigs = new JobConfigs();
ArtifactPropertiesGenerators generators = new ArtifactPropertiesGenerators();
generators.add(new ArtifactPropertiesGenerator("property-name", "artifact-path", "artifact-xpath"));
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test-job"), new Resources(), new ArtifactPlans(), generators);
jobConfig.setRunInstanceCount(3);
jobConfigs.add(jobConfig);
StageConfig stage = new StageConfig(new CaseInsensitiveString("test-stage"), jobConfigs);
MaterialConfigs materialConfigs = new MaterialConfigs(MaterialConfigsMother.dependencyMaterialConfig());
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("test-pipeline"), materialConfigs, stage);
BuildCause cause = modifySomeFiles(pipelineConfig, ModificationsMother.nextRevision());
saveRev(cause);
configFileEditor.addPipeline(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stage.name()));
queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), configFileEditor.currentConfig().agents()), "md5-test", new TimeProvider());
List<JobPlan> plans = jobService.orderedScheduledBuilds();
assertThat(plans.size(), is(3));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("test-job", 1)))));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("test-job", 2)))));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("test-job", 3)))));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldNotBeCanceledWhenForcingBuildTwice.
@Test
public void shouldNotBeCanceledWhenForcingBuildTwice() throws Exception {
PipelineConfig pipelineConfig = fixture.pipelineConfig();
BuildCause cause = forceBuild(pipelineConfig);
saveRev(cause);
queue.finishSchedule(fixture.pipelineName, cause, newCause);
queue.schedule(fixture.pipelineName, cause);
assertThat(pipelineDao.mostRecentLabel(fixture.pipelineName), is(nullValue()));
assertThat(fixture.pipelineName, is(scheduledOn(queue)));
assertThat(queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider()), is(not(nullValue())));
assertThat(pipelineDao.mostRecentLabel(fixture.pipelineName), is("label-1"));
}
Aggregations