use of com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage in project gocd by gocd.
the class BuildCauseProducerServiceTest method manualTrigger_shouldNotUpdatePipelineConfigWhenConfigRepoIsNotInMaterials.
@Test
public void manualTrigger_shouldNotUpdatePipelineConfigWhenConfigRepoIsNotInMaterials() {
HgMaterial material1 = new HgMaterial("url", null);
HgMaterialConfig materialConfig1 = new HgMaterialConfig("url", null);
HgMaterialConfig materialConfig2 = new HgMaterialConfig("url2", null);
pipelineConfig.addMaterialConfig(materialConfig1);
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig2, "plug"), "revision1"));
when(materialConfigConverter.toMaterial(materialConfig1)).thenReturn(material1);
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(new HashMap<>(), new HashMap<>(), new HashMap<>()), new ServerHealthStateOperationResult());
verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
MaterialUpdateStatusListener statusListener = extractMaterialListenerInstanceFromRegisterCall();
statusListener.onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material1, 0));
verify(mockMaterialUpdateStatusNotifier).removeListenerFor(pipelineConfig);
verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
}
use of com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldScheduleAPipelineWithLatestRevisionOfAssociatedMaterial.
@Test
public void shouldScheduleAPipelineWithLatestRevisionOfAssociatedMaterial() {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline %s accepted", pipelineName)));
assertThat(result.httpCode(), is(202));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(true));
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 1));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
assertThat(buildCause.getApprover(), is(CaseInsensitiveString.str(admin.getUsername())));
assertThat(buildCause.getMaterialRevisions().findRevisionFor(pipelineConfig.materialConfigs().first()).getLatestRevisionString(), is("s3"));
assertThat(buildCause.getBuildCauseMessage(), is("Forced by admin1"));
assertTrue(buildCause.getVariables().isEmpty());
}
use of com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldScheduleAPipelineWithTheProvidedEnvironmentVariables.
@Test
public void shouldScheduleAPipelineWithTheProvidedEnvironmentVariables() throws IOException {
pipelineConfig.addEnvironmentVariable("ENV_VAR1", "VAL1");
pipelineConfig.addEnvironmentVariable("ENV_VAR2", "VAL2");
pipelineConfig.addEnvironmentVariable(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR1", "SECURE_VAL", true));
pipelineConfig.addEnvironmentVariable(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR2", "SECURE_VAL2", true));
pipelineConfigService.updatePipelineConfig(admin, pipelineConfig, entityHashingService.md5ForEntity(pipelineConfig), new HttpLocalizedOperationResult());
Integer pipelineCounterBefore = pipelineSqlMapDao.getCounterForPipeline(pipelineName);
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineScheduleOptions.getAllEnvironmentVariables().add(new EnvironmentVariableConfig(new GoCipher(), "ENV_VAR1", "overridden_value", false));
pipelineScheduleOptions.getAllEnvironmentVariables().add(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR1", "overridden_secure_value", true));
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline %s accepted", pipelineName)));
assertThat(result.httpCode(), is(202));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(true));
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 1));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
assertThat(buildCause.getApprover(), is(CaseInsensitiveString.str(admin.getUsername())));
assertThat(buildCause.getMaterialRevisions().findRevisionFor(pipelineConfig.materialConfigs().first()).getLatestRevisionString(), is("s3"));
assertThat(buildCause.getBuildCauseMessage(), is("Forced by admin1"));
assertThat(buildCause.getVariables().size(), is(2));
EnvironmentVariable plainTextVariable = (EnvironmentVariable) CollectionUtils.find(buildCause.getVariables(), new Predicate() {
@Override
public boolean evaluate(Object o) {
EnvironmentVariable variable = (EnvironmentVariable) o;
return variable.getName().equals("ENV_VAR1");
}
});
EnvironmentVariable secureVariable = (EnvironmentVariable) CollectionUtils.find(buildCause.getVariables(), new Predicate() {
@Override
public boolean evaluate(Object o) {
EnvironmentVariable variable = (EnvironmentVariable) o;
return variable.getName().equals("SECURE_VAR1");
}
});
assertThat(plainTextVariable.getValue(), is("overridden_value"));
assertThat(secureVariable.getValue(), is("overridden_secure_value"));
assertThat(secureVariable.isSecure(), is(true));
scheduleService.autoSchedulePipelinesFromRequestBuffer();
Integer pipelineCounterAfter = pipelineSqlMapDao.getCounterForPipeline(pipelineName);
assertThat(pipelineCounterAfter, is(pipelineCounterBefore + 1));
BuildCause buildCauseOfLatestRun = pipelineSqlMapDao.findBuildCauseOfPipelineByNameAndCounter(pipelineName, pipelineCounterAfter);
assertThat(buildCauseOfLatestRun, is(buildCause));
}
use of com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldScheduleAPipelineWithTheProvidedEncryptedEnvironmentVariable.
@Test
public void shouldScheduleAPipelineWithTheProvidedEncryptedEnvironmentVariable() throws InvalidCipherTextException {
pipelineConfig.addEnvironmentVariable(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR1", "SECURE_VAL", true));
pipelineConfigService.updatePipelineConfig(admin, pipelineConfig, entityHashingService.md5ForEntity(pipelineConfig), new HttpLocalizedOperationResult());
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
String overriddenEncryptedValue = new GoCipher().encrypt("overridden_value");
pipelineScheduleOptions.getAllEnvironmentVariables().add(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR1", overriddenEncryptedValue));
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 1));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
EnvironmentVariable secureVariable = (EnvironmentVariable) CollectionUtils.find(buildCause.getVariables(), new Predicate() {
@Override
public boolean evaluate(Object o) {
EnvironmentVariable variable = (EnvironmentVariable) o;
return variable.getName().equals("SECURE_VAR1");
}
});
assertThat(secureVariable.getValue(), is("overridden_value"));
assertThat(secureVariable.isSecure(), is(true));
}
use of com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldScheduleAPipelineWithTheProvidedMaterialRevisions.
@Test
public void shouldScheduleAPipelineWithTheProvidedMaterialRevisions() throws IOException {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
String peggedRevision = "s2";
MaterialForScheduling material = new MaterialForScheduling(pipelineConfig.materialConfigs().first().getFingerprint(), peggedRevision);
pipelineScheduleOptions.getMaterials().add(material);
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline %s accepted", pipelineName)));
assertThat(result.httpCode(), is(202));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(true));
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 1));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
assertThat(buildCause.getApprover(), is(CaseInsensitiveString.str(admin.getUsername())));
assertThat(buildCause.getMaterialRevisions().findRevisionFor(pipelineConfig.materialConfigs().first()).getLatestRevisionString(), is("s2"));
assertThat(buildCause.getBuildCauseMessage(), is("Forced by admin1"));
assertTrue(buildCause.getVariables().isEmpty());
}
Aggregations