Search in sources :

Example 21 with CruiseConfig

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);
}
Also used : CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 22 with CruiseConfig

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);
}
Also used : CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 23 with CruiseConfig

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);
}
Also used : GoCache(com.thoughtworks.go.server.cache.GoCache) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig) Test(org.junit.Test)

Example 24 with CruiseConfig

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();
    }
}
Also used : ArrayList(java.util.ArrayList) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 25 with CruiseConfig

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"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.Test)

Aggregations

CruiseConfig (com.thoughtworks.go.config.CruiseConfig)95 Test (org.junit.Test)77 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)35 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)33 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)32 ServerConfig (com.thoughtworks.go.config.ServerConfig)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)5 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)4 File (java.io.File)4 ConfigCache (com.thoughtworks.go.config.ConfigCache)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)3 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)3 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3