Search in sources :

Example 11 with ScheduleOptions

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

the class BuildCauseProducerServiceIntegrationTest method shouldSchedulePipelineWithManualFirstStageWhenManuallyTriggered.

@Test
public void shouldSchedulePipelineWithManualFirstStageWhenManuallyTriggered() throws Exception {
    configHelper.configureStageAsManualApproval(MINGLE_PIPELINE_NAME, STAGE_NAME);
    svnRepository.checkInOneFile("a.java");
    materialDatabaseUpdater.updateMaterial(svnRepository.material());
    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());
    Map<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(5);
    assertThat(afterLoad.keySet(), hasItem(MINGLE_PIPELINE_NAME));
    BuildCause cause = afterLoad.get(MINGLE_PIPELINE_NAME);
    assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
}
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) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 12 with ScheduleOptions

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

the class BuildCauseProducerServiceIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    new HgTestRepo("testHgRepo", temporaryFolder);
    svnRepository = new SvnTestRepo(temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    repository = new SvnCommand(null, svnRepository.projectRepositoryUrl());
    PipelineConfig goParentPipelineConfig = configHelper.addPipeline(GO_PIPELINE_UPSTREAM, STAGE_NAME, new MaterialConfigs(new GitMaterialConfig("foo-bar")), "unit");
    goPipelineConfig = configHelper.addPipeline(GO_PIPELINE_NAME, STAGE_NAME, repository, "unit");
    svnMaterialRevs = new MaterialRevisions();
    svnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
    svnMaterialRevs.addRevision(svnMaterial, svnMaterial.latestModification(null, new ServerSubprocessExecutionContext(goConfigService, new SystemEnvironment())));
    final MaterialRevisions materialRevisions = new MaterialRevisions();
    SvnMaterial anotherSvnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
    materialRevisions.addRevision(anotherSvnMaterial, anotherSvnMaterial.latestModification(null, subprocessExecutionContext));
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            materialRepository.save(svnMaterialRevs);
        }
    });
    BuildCause buildCause = BuildCause.createWithModifications(svnMaterialRevs, "");
    mingleConfig = configHelper.addPipeline(MINGLE_PIPELINE_NAME, STAGE_NAME, repository, new Filter(new IgnoredFiles("**/*.doc")), "unit", "functional");
    latestPipeline = PipelineMother.schedule(this.mingleConfig, buildCause);
    latestPipeline = pipelineDao.saveWithStages(latestPipeline);
    dbHelper.passStage(latestPipeline.getStages().first());
    pipelineScheduleQueue.clear();
    result = new HttpOperationResult();
    scheduleOptions = new ScheduleOptions();
    u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    materialForManualTriggerPipeline = u.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
    u.checkinInOrder(materialForManualTriggerPipeline, u.d(1), "s1");
    manualTriggerPipeline = configHelper.addPipeline(UUID.randomUUID().toString(), STAGE_NAME, materialForManualTriggerPipeline.config(), "build");
    username = Username.ANONYMOUS;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) TransactionStatus(org.springframework.transaction.TransactionStatus) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Before(org.junit.Before)

Example 13 with ScheduleOptions

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

the class ScheduleServiceIntegrationTest method manualSchedule.

private Pipeline manualSchedule(String pipelineName) {
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    final HashMap<String, String> secureEnvironmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(pipelineName, new Username(new CaseInsensitiveString("some user name")), new ScheduleOptions(revisions, environmentVariables, secureEnvironmentVariables), new ServerHealthStateOperationResult());
    scheduleService.autoSchedulePipelinesFromRequestBuffer();
    return pipelineService.mostRecentFullPipelineByName(pipelineName);
}
Also used : ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) Username(com.thoughtworks.go.server.domain.Username) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)

Example 14 with ScheduleOptions

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

the class ScheduleServiceRunOnAllAgentIntegrationTest method manualSchedule.

private Pipeline manualSchedule(String pipelineName) {
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(pipelineName, new Username(new CaseInsensitiveString("some user name")), new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    scheduleService.autoSchedulePipelinesFromRequestBuffer();
    return pipelineService.mostRecentFullPipelineByName(pipelineName);
}
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)

Example 15 with ScheduleOptions

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

the class PipelineSchedulerIntegrationTest method shouldPassOverriddenEnvironmentVariablesForScheduling.

@Test
public void shouldPassOverriddenEnvironmentVariablesForScheduling() {
    final ScheduleOptions scheduleOptions = new ScheduleOptions(new HashMap<>(), Collections.singletonMap("KEY", "value"), new HashMap<>());
    HttpOperationResult operationResult = new HttpOperationResult();
    goConfigService.pipelineConfigNamed(new CaseInsensitiveString(PIPELINE_MINGLE)).setVariables(env("KEY", "somejunk"));
    serverHealthService.update(ServerHealthState.failToScheduling(HealthStateType.general(HealthStateScope.forPipeline(PIPELINE_MINGLE)), PIPELINE_MINGLE, "should wait till cleared"));
    pipelineScheduler.manualProduceBuildCauseAndSave(PIPELINE_MINGLE, Username.ANONYMOUS, scheduleOptions, operationResult);
    assertThat(operationResult.message(), operationResult.canContinue(), is(true));
    Assertions.waitUntil(Timeout.ONE_MINUTE, new Assertions.Predicate() {

        public boolean call() throws Exception {
            return serverHealthService.filterByScope(HealthStateScope.forPipeline(PIPELINE_MINGLE)).size() == 0;
        }
    });
    BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(PIPELINE_MINGLE);
    EnvironmentVariables overriddenVariables = buildCause.getVariables();
    assertThat(overriddenVariables, is(new EnvironmentVariables(Arrays.asList(new EnvironmentVariable("KEY", "value")))));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) Assertions(com.thoughtworks.go.utils.Assertions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) IOException(java.io.IOException) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

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