use of com.thoughtworks.go.domain.materials.TestingMaterial in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldForceStagePlanWithModificationsSinceLast.
@Test
public void shouldForceStagePlanWithModificationsSinceLast() throws Exception {
Pipeline completedMingle = scheduleAndCompleteInitialPipelines();
pipelineDao.loadPipeline(completedMingle.getId());
TestingMaterial testingMaterial = new TestingMaterial();
mingleConfig.setMaterialConfigs(new MaterialConfigs(testingMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(testingMaterial, testingMaterial.modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createManualForced(revisions, Username.ANONYMOUS);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline forcedPipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineService.save(forcedPipeline);
verifyMingleScheduledWithModifications();
}
use of com.thoughtworks.go.domain.materials.TestingMaterial in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldScheduleMultipleJobsWhenToBeRunMultipleInstance.
@Test
public void shouldScheduleMultipleJobsWhenToBeRunMultipleInstance() throws Exception {
configHelper.setRunMultipleInstance(CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", 2);
Material stubMaterial = new TestingMaterial();
evolveConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY, environmentConfigService.agentsForPipeline(evolveConfig.name())), md5, new TimeProvider());
pipelineService.save(pipeline);
Stage instance = scheduleService.scheduleStage(pipeline, STAGE_NAME, "anyone", new ScheduleService.NewStageInstanceCreator(goConfigService), new ScheduleService.ExceptioningErrorHandler());
JobInstances scheduledJobs = instance.getJobInstances();
assertThat(scheduledJobs.size(), is(2));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
}
use of com.thoughtworks.go.domain.materials.TestingMaterial in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldLockPipelineWhenSchedulingIt.
@Test
public void shouldLockPipelineWhenSchedulingIt() throws Exception {
scheduleAndCompleteInitialPipelines();
configHelper.lockPipeline("mingle");
Material stubMaterial = new TestingMaterial();
mingleConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
assertThat(pipelineLockService.isLocked("mingle"), is(false));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineService.save(pipeline);
assertThat(pipelineLockService.isLocked("mingle"), is(true));
}
use of com.thoughtworks.go.domain.materials.TestingMaterial in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldScheduleStageAfterModifications.
@Test
public void shouldScheduleStageAfterModifications() throws Exception {
scheduleAndCompleteInitialPipelines();
Material stubMaterial = new TestingMaterial();
mingleConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineService.save(pipeline);
verifyMingleScheduledWithModifications();
}
use of com.thoughtworks.go.domain.materials.TestingMaterial in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldScheduleJobForAllAgentsWhenToBeRunOnAllAgents.
@Test
public void shouldScheduleJobForAllAgentsWhenToBeRunOnAllAgents() throws Exception {
configHelper.addAgent("localhost", "uuid1");
configHelper.addAgent("localhost", "uuid2");
configHelper.addAgent("localhost", "uuid3");
configHelper.addAgentToEnvironment("dev", "uuid1");
configHelper.setRunOnAllAgents(CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", true);
Material stubMaterial = new TestingMaterial();
evolveConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY, environmentConfigService.agentsForPipeline(evolveConfig.name())), md5, new TimeProvider());
pipelineService.save(pipeline);
Stage instance = scheduleService.scheduleStage(pipeline, STAGE_NAME, "anyone", new ScheduleService.NewStageInstanceCreator(goConfigService), new ScheduleService.ExceptioningErrorHandler());
JobInstances scheduledJobs = instance.getJobInstances();
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("agentUuid", is("uuid2"))));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("agentUuid", is("uuid3"))));
assertThat(scheduledJobs.size(), is(2));
}
Aggregations