use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class UpdatePipelineConfigCommandTest method shouldInvokeUpdateMethodOfCruiseConfig.
@Test
public void shouldInvokeUpdateMethodOfCruiseConfig() throws Exception {
UpdatePipelineConfigCommand command = new UpdatePipelineConfigCommand(goConfigService, null, pipelineConfig, username, "stale_md5", localizedOperationResult);
CruiseConfig cruiseConfig = mock(CruiseConfig.class);
when(goConfigService.findGroupNameByPipeline(pipelineConfig.name())).thenReturn("group1");
command.update(cruiseConfig);
verify(cruiseConfig).update("group1", pipelineConfig.name().toString(), pipelineConfig);
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class CcTrayActivityListenerTest method onIntializationAndStartOfDaemon_ShouldRegisterAListener_WhichInvokesConfigChangeHandler_WhenConfigChanges.
@Test
public void onIntializationAndStartOfDaemon_ShouldRegisterAListener_WhichInvokesConfigChangeHandler_WhenConfigChanges() throws Exception {
CruiseConfig aConfig = GoConfigMother.defaultCruiseConfig();
CcTrayConfigChangeHandler handler = mock(CcTrayConfigChangeHandler.class);
CcTrayActivityListener listener = new CcTrayActivityListener(goConfigService, null, null, handler);
listener.initialize();
listener.startDaemon();
listener.onConfigChange(aConfig);
waitForProcessingToHappen();
verify(handler).call(aConfig);
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class BaseUrlChangeListenerTest method shouldNotFlushCacheWhenBaseUrlConfigIsNotChanged.
@Test
public void shouldNotFlushCacheWhenBaseUrlConfigIsNotChanged() {
GoCache cache = mock(GoCache.class);
BaseUrlChangeListener listener = new BaseUrlChangeListener(new ServerSiteUrlConfig(""), new ServerSiteUrlConfig(""), cache);
CruiseConfig newCruiseConfig = new BasicCruiseConfig();
newCruiseConfig.setServerConfig(serverConfigWith("", ""));
listener.onConfigChange(newCruiseConfig);
verifyZeroInteractions(cache);
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class ValueStreamMapPerformanceTest method shouldTestVSMForNPipelines.
@Test
public void shouldTestVSMForNPipelines() throws Exception {
final int numberOfDownstreamPipelines = 5;
final CruiseConfig cruiseConfig = setupVSM(numberOfDownstreamPipelines);
ArrayList<Thread> ts = new ArrayList<>();
int numberOfParallelRequests = 10;
for (int i = 0; i < numberOfParallelRequests; i++) {
final int finalI = i;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(5000);
doRun(numberOfDownstreamPipelines, cruiseConfig, "Thread" + finalI);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}, "Thread" + i);
ts.add(t);
}
for (Thread t : ts) {
t.start();
}
for (Thread t : ts) {
t.join();
}
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations.
@Test
public void shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations() {
ScheduleTestUtil u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
int i = 1;
GitMaterial git1 = u.wf(new GitMaterial("git"), "folder1");
u.checkinInOrder(git1, "g1");
GitMaterial git2 = u.wf(new GitMaterial("git"), "folder2");
ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("P", u.m(git1), u.m(git2));
CruiseConfig cruiseConfig = goConfigDao.load();
u.checkinInOrder(git1, u.d(i++), "g2");
u.runAndPass(p, "g1", "g2");
u.runAndPass(p, "g2", "g1");
PipelineTimeline timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
timeline.updateTimelineOnInit();
List<PipelineTimelineEntry> timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
List<PipelineTimelineEntry.Revision> flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g1"));
assertThat(flyweightsRevs.get(1).revision, is("g2"));
assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g2"));
assertThat(flyweightsRevs.get(1).revision, is("g1"));
MaterialConfigs materials = CLONER.deepClone(p.config.materialConfigs());
Collections.reverse(materials);
configHelper.setMaterialConfigForPipeline("P", materials.toArray(new MaterialConfig[0]));
goConfigDao.load();
timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
timeline.updateTimelineOnInit();
timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g1"));
assertThat(flyweightsRevs.get(1).revision, is("g2"));
assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g2"));
assertThat(flyweightsRevs.get(1).revision, is("g1"));
}
Aggregations