Search in sources :

Example 1 with TestingMaterial

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();
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 2 with TestingMaterial

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)))));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Material(com.thoughtworks.go.domain.materials.Material) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Test(org.junit.Test)

Example 3 with TestingMaterial

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Material(com.thoughtworks.go.domain.materials.Material) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 4 with TestingMaterial

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();
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Material(com.thoughtworks.go.domain.materials.Material) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 5 with TestingMaterial

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Material(com.thoughtworks.go.domain.materials.Material) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Test(org.junit.Test)

Aggregations

MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)5 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 TestingMaterial (com.thoughtworks.go.domain.materials.TestingMaterial)5 TimeProvider (com.thoughtworks.go.util.TimeProvider)5 Test (org.junit.Test)5 Material (com.thoughtworks.go.domain.materials.Material)4