Search in sources :

Example 16 with ScheduleOptions

use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.

the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldSchedulePipelineWhenPartIsInvalid_AndManuallyTriggered.

@Test
public void shouldSchedulePipelineWhenPartIsInvalid_AndManuallyTriggered() throws Exception {
    List<Modification> lastPush = configTestRepo.addCodeToRepositoryAndPush(fileName, "added broken config file", "bad bad config");
    materialUpdateService.updateMaterial(material);
    waitForMaterialNotInProgress();
    assertThat(goRepoConfigDataSource.latestParseHasFailedForMaterial(material.config()), is(true));
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    Map<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(5);
    assertThat(afterLoad.keySet(), hasItem(PIPELINE_NAME));
    BuildCause cause = afterLoad.get(PIPELINE_NAME);
    assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
    PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
    RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
    String lastValidPushedRevision = this.firstRevisions.latestRevision();
    assertThat("revisionOfPipelineConfigOriginShouldMatchLastValidPushedCommit", configOriginAfterSchedule.getRevision(), is(lastValidPushedRevision));
    assertThat("buildCauseRevisionShouldMatchLastPushedCommit", cause.getMaterialRevisions().latestRevision(), is(lastPush.get(0).getRevision()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) HashMap(java.util.HashMap) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 17 with ScheduleOptions

use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationTest method shouldScheduleANewPipelineWhenManuallyTrigeredWithNoChanges.

@Test
public void shouldScheduleANewPipelineWhenManuallyTrigeredWithNoChanges() throws Exception {
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(MINGLE_PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    assertThat(scheduleHelper.waitForAnyScheduled(5).keySet(), hasItem(MINGLE_PIPELINE_NAME));
}
Also used : ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) HashMap(java.util.HashMap) StringContains.containsString(org.hamcrest.core.StringContains.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.Test)

Example 18 with ScheduleOptions

use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationTest method manualSchedulePipeline_canProduceShouldNotgetIntoCyclicLoopWithTriggerMonitor.

@Test
public void manualSchedulePipeline_canProduceShouldNotgetIntoCyclicLoopWithTriggerMonitor() throws Exception {
    OperationResult operationResult = new ServerHealthStateOperationResult();
    buildCauseProducer.manualProduceBuildCauseAndSave(MINGLE_PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(), operationResult);
    scheduleHelper.waitForAnyScheduled(5);
    assertThat(operationResult.canContinue(), is(true));
}
Also used : ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) OperationResult(com.thoughtworks.go.server.service.result.OperationResult) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.Test)

Example 19 with ScheduleOptions

use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.

the class BuildCauseProducerServiceWithFlipModificationTest method shouldHaveModificationChangedAsFalseWhenForceBuildWithoutModification.

@Test
public void shouldHaveModificationChangedAsFalseWhenForceBuildWithoutModification() throws Exception {
    mingleConfig = configHelper.addPipeline(PIPELINE_NAME, STAGE_NAME, svnMaterialConfig, "unit", "functional");
    consume(buildCause());
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, new Username(new CaseInsensitiveString("pavan")), new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    verifyBuildCauseHasModificationsWith(pipelineScheduleQueue.toBeScheduled(), false);
}
Also used : ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) HashMap(java.util.HashMap) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 20 with ScheduleOptions

use of com.thoughtworks.go.server.scheduling.ScheduleOptions in project gocd by gocd.

the class BuildCauseProducerServiceWithFlipModificationTest method shouldHaveModificationChangedAsTrueForNewRevisions.

@Test
public void shouldHaveModificationChangedAsTrueForNewRevisions() throws Exception {
    mingleConfig = configHelper.addPipeline(PIPELINE_NAME, STAGE_NAME, svnMaterialConfig, "unit", "functional");
    consume(buildCause());
    svnRepository.checkInOneFile("abc");
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, new Username(new CaseInsensitiveString("pavan")), new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    verifyBuildCauseHasModificationsWith(pipelineScheduleQueue.toBeScheduled(), true);
}
Also used : ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) HashMap(java.util.HashMap) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

ScheduleOptions (com.thoughtworks.go.server.scheduling.ScheduleOptions)20 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)16 HashMap (java.util.HashMap)14 Test (org.junit.Test)14 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)6 Modification (com.thoughtworks.go.domain.materials.Modification)6 Username (com.thoughtworks.go.server.domain.Username)6 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 StringContains.containsString (org.hamcrest.core.StringContains.containsString)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)2 PipelineScheduleOptions (com.thoughtworks.go.server.domain.PipelineScheduleOptions)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 Filter (com.thoughtworks.go.config.materials.Filter)1 IgnoredFiles (com.thoughtworks.go.config.materials.IgnoredFiles)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1