Search in sources :

Example 96 with BuildCause

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()));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) File(java.io.File) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 97 with BuildCause

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));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 98 with BuildCause

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

Example 99 with BuildCause

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

Example 100 with BuildCause

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

Aggregations

BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)142 Test (org.junit.Test)108 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)35 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)30 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)27 TimeProvider (com.thoughtworks.go.util.TimeProvider)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Modification (com.thoughtworks.go.domain.materials.Modification)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)15 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)14 Date (java.util.Date)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)10 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)10 Username (com.thoughtworks.go.server.domain.Username)10