use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTimerTest method pipelineWithTimerShouldRunOnlyWithMaterialsWhichChanged_GivenTimerIsSetToTriggerOnlyForNewMaterials.
@Test
public void pipelineWithTimerShouldRunOnlyWithMaterialsWhichChanged_GivenTimerIsSetToTriggerOnlyForNewMaterials() throws Exception {
int i = 1;
String pipelineName = "p1";
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder1");
GitMaterial git2 = u.wf(new GitMaterial("git2"), "folder2");
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("up1", u.m(git1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWithTimer(pipelineName, u.timer("* * * * * ? 2000", true), u.m(git1), u.m(git2), u.m(p1));
u.checkinFile(git1, "g11", temporaryFolder.newFile("blah_g11"), ModifiedAction.added);
u.checkinFile(git2, "g21", temporaryFolder.newFile("blah_g21"), ModifiedAction.added);
Date mduTimeOfG11 = u.d(i++);
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, mduTimeOfG11, "g11");
pipelineTimeline.update();
// Run once with latest, when pipeline schedules due to timer.
buildCauseProducerService.timerSchedulePipeline(p2.config, new ServerHealthStateOperationResult());
assertThat(piplineScheduleQueue.toBeScheduled().size(), is(1));
assertThat(piplineScheduleQueue.toBeScheduled().get(pipelineName).getMaterialRevisions(), isSameMaterialRevisionsAs(u.mrs(u.mr(git1, true, "g11"), u.mr(git2, true, "g21"), u.mr(p1, true, p1_1))));
BuildCause buildCause = piplineScheduleQueue.toBeScheduled().get(pipelineName);
u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g11", "g21", p1_1);
piplineScheduleQueue.finishSchedule(pipelineName, buildCause, buildCause);
// Check in to git2 and run pipeline P1 once before the timer time. Then, timer happens. Shows those two materials in "yellow" (changed), on the UI.
u.checkinFile(git2, "g22", temporaryFolder.newFile("blah_g22"), ModifiedAction.added);
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, mduTimeOfG11, "g11");
pipelineTimeline.update();
try (LogFixture logFixture = logFixtureFor(TimedBuild.class, Level.INFO)) {
buildCauseProducerService.timerSchedulePipeline(p2.config, new ServerHealthStateOperationResult());
assertThat(piplineScheduleQueue.toBeScheduled().size(), is(1));
assertThat(piplineScheduleQueue.toBeScheduled().get(pipelineName).getMaterialRevisions(), isSameMaterialRevisionsAs(u.mrs(u.mr(git1, false, "g11"), u.mr(git2, true, "g22"), u.mr(p1, true, p1_2))));
assertThat(logFixture.contains(Level.INFO, "Skipping scheduling of timer-triggered pipeline 'p1' as it has previously run with the latest material(s)."), is(false));
}
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class BuildCauseProducerServiceWithFlipModificationTest method buildCauseForPipeline.
private BuildCause buildCauseForPipeline() {
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(PIPELINE_NAME);
assertThat("Should be scheduled", buildCause, is(not(nullValue())));
return buildCause;
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class ScheduleServiceIntegrationTest method runAndPass.
private Pipeline runAndPass(PipelineConfig pipelineConfig, int counter) {
BuildCause buildCause = ModificationsMother.modifySomeFiles(pipelineConfig);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
String pipelineName = pipelineConfig.name().toString();
pipelineScheduleQueue.schedule(pipelineName, buildCause);
scheduleService.autoSchedulePipelinesFromRequestBuffer();
Pipeline pipeline = pipelineDao.findPipelineByNameAndCounter(pipelineName, counter);
pipeline = pipelineDao.loadAssociations(pipeline, pipelineName);
return pipeline;
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldCreateJobsMatchingRealAgentsIfRunOnAllAgentsIsSet.
@Test
public void shouldCreateJobsMatchingRealAgentsIfRunOnAllAgentsIsSet() {
JobConfigs jobConfigs = new JobConfigs();
ArtifactConfigs artifactConfigs = new ArtifactConfigs();
ArtifactPropertiesConfig generators = new ArtifactPropertiesConfig();
generators.add(new ArtifactPropertyConfig("property-name", "artifact-path", "artifact-xpath"));
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test-job"), new ResourceConfigs(), artifactConfigs, generators);
jobConfig.setRunOnAllAgents(true);
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.addAgent("localhost", "uuid1");
configFileEditor.addAgent("localhost", "uuid2");
configFileEditor.addAgent("localhost", "uuid3");
configFileEditor.addAgentToEnvironment("env", "uuid1");
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.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("test-job", 1)))));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("test-job", 2)))));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("test-job", 3)))));
assertThat(plans.size(), is(3));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldClearMostRecentScheduledIfPipelineIsDeleted.
@Test
public void shouldClearMostRecentScheduledIfPipelineIsDeleted() {
BuildCause buildCause = BuildCause.createWithEmptyModifications();
queue.schedule("cruise", buildCause);
queue.finishSchedule("cruise", buildCause, newCause);
queue.clearPipeline("cruise");
assertThat(queue.mostRecentScheduled("cruise").hasNeverRun(), is(true));
}
Aggregations