use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class CachedGoConfigIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
configHelper = new GoConfigFileHelper(DEFAULT_XML_WITH_2_AGENTS);
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
configHelper.onSetUp();
externalConfigRepo = temporaryFolder.newFolder();
latestCommit = setupExternalConfigRepo(externalConfigRepo);
configHelper.addConfigRepo(new ConfigRepoConfig(new GitMaterialConfig(externalConfigRepo.getAbsolutePath()), XmlPartialConfigProvider.providerName));
goConfigService.forceNotifyListeners();
configRepo = configWatchList.getCurrentConfigRepos().get(0);
cachedGoPartials.clear();
configHelper.addAgent("hostname1", "uuid1");
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method setup.
@Before
public void setup() throws Exception {
diskSpaceSimulator = new DiskSpaceSimulator();
hgRepo = new HgTestRepo("testHgRepo");
dbHelper.onSetUp();
configHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
materialConfig = hgRepo.materialConfig();
configHelper.addConfigRepo(new ConfigRepoConfig(materialConfig, "gocd-xml"));
logger = mock(MDUPerformanceLogger.class);
TestingEmailSender emailSender = new TestingEmailSender();
SystemDiskSpaceChecker mockDiskSpaceChecker = Mockito.mock(SystemDiskSpaceChecker.class);
StageService stageService = mock(StageService.class);
ConfigDbStateRepository configDbStateRepository = mock(ConfigDbStateRepository.class);
goDiskSpaceMonitor = new GoDiskSpaceMonitor(goConfigService, systemEnvironment, serverHealthService, emailSender, mockDiskSpaceChecker, mock(ArtifactsService.class), stageService, configDbStateRepository);
goDiskSpaceMonitor.initialize();
worker = new MaterialUpdateListener(configTopic, materialDatabaseUpdater, logger, goDiskSpaceMonitor);
xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
configTestRepo = new ConfigTestRepo(hgRepo, xmlWriter);
this.material = (HgMaterial) materialConfigConverter.toMaterial(materialConfig);
pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
pipelineConfig.materialConfigs().clear();
pipelineConfig.materialConfigs().add(materialConfig);
PIPELINE_NAME = CaseInsensitiveString.str(pipelineConfig.name());
configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
pipelineConfig = goConfigService.pipelineConfigNamed(pipelineConfig.name());
pipelineScheduleQueue.clear();
//check test setup
Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs());
MaterialRevisions peggedRevisions = new MaterialRevisions();
firstRevisions = materialChecker.findLatestRevisions(peggedRevisions, materials);
assertThat(firstRevisions.isMissingModifications(), is(false));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class ConfigSaveDeadlockDetectionIntegrationTest method shouldNotDeadlockWhenAllPossibleWaysOfUpdatingTheConfigAreBeingUsedAtTheSameTime.
@Test
public void shouldNotDeadlockWhenAllPossibleWaysOfUpdatingTheConfigAreBeingUsedAtTheSameTime() throws Exception {
int EXISTING_ENV_COUNT = goConfigService.cruiseConfig().getEnvironments().size();
final ArrayList<Thread> group1 = new ArrayList<>();
final ArrayList<Thread> group2 = new ArrayList<>();
final ArrayList<Thread> group3 = new ArrayList<>();
final ArrayList<Thread> group4 = new ArrayList<>();
final ArrayList<Thread> group5 = new ArrayList<>();
int count = 100;
final int pipelineCreatedThroughApiCount = count;
final int pipelineCreatedThroughUICount = count;
final int configRepoAdditionThreadCount = count;
final int configRepoDeletionThreadCount = count;
final int fullConfigSaveThreadCount = count;
for (int i = 0; i < pipelineCreatedThroughUICount; i++) {
Thread thread = configSaveThread(i);
group1.add(thread);
}
for (int i = 0; i < pipelineCreatedThroughApiCount; i++) {
Thread thread = pipelineSaveThread(i);
group2.add(thread);
}
ConfigReposConfig configRepos = new ConfigReposConfig();
for (int i = 0; i < configRepoAdditionThreadCount; i++) {
ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(new GitMaterialConfig("url" + i), "plugin");
configRepos.add(configRepoConfig);
Thread thread = configRepoSaveThread(configRepoConfig, i);
group3.add(thread);
}
for (int i = 0; i < configRepoDeletionThreadCount; i++) {
ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(new GitMaterialConfig("to-be-deleted-url" + i), "plugin");
cachedGoPartials.addOrUpdate(configRepoConfig.getMaterialConfig().getFingerprint(), PartialConfigMother.withPipeline("to-be-deleted" + i, new RepoConfigOrigin(configRepoConfig, "plugin")));
configRepos.add(configRepoConfig);
Thread thread = configRepoDeleteThread(configRepoConfig, i);
group4.add(thread);
}
for (int i = 0; i < fullConfigSaveThreadCount; i++) {
Thread thread = fullConfigSaveThread(i);
group5.add(thread);
}
configHelper.setConfigRepos(configRepos);
for (int i = 0; i < count; i++) {
Thread timerThread = null;
try {
timerThread = createThread(new Runnable() {
@Override
public void run() {
try {
writeConfigToFile(new File(goConfigDao.fileLocation()));
} catch (Exception e) {
e.printStackTrace();
fail("Failed with error: " + e.getMessage());
}
cachedGoConfig.forceReload();
}
}, "timer-thread");
} catch (InterruptedException e) {
fail(e.getMessage());
}
try {
group1.get(i).start();
group2.get(i).start();
group3.get(i).start();
group4.get(i).start();
group5.get(i).start();
timerThread.start();
group1.get(i).join();
group2.get(i).join();
group3.get(i).join();
group4.get(i).join();
group5.get(i).join();
timerThread.join();
} catch (InterruptedException e) {
fail(e.getMessage());
}
}
assertThat(goConfigService.getAllPipelineConfigs().size(), is(pipelineCreatedThroughApiCount + pipelineCreatedThroughUICount + configRepoAdditionThreadCount));
assertThat(goConfigService.getConfigForEditing().getAllPipelineConfigs().size(), is(pipelineCreatedThroughApiCount + pipelineCreatedThroughUICount));
assertThat(goConfigService.getConfigForEditing().getEnvironments().size(), is(fullConfigSaveThreadCount + EXISTING_ENV_COUNT));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class PipelineConfigServiceTest method setUp.
@Before
public void setUp() throws Exception {
PipelineConfigs configs = createGroup("group", "pipeline", "in_env");
downstream(configs);
cruiseConfig = new BasicCruiseConfig(configs);
cruiseConfig.addEnvironment(environment("foo", "in_env"));
PipelineConfig remotePipeline = PipelineConfigMother.pipelineConfig("remote");
remotePipeline.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin"), "1234"));
cruiseConfig.addPipeline("group", remotePipeline);
goConfigService = mock(GoConfigService.class);
securityService = mock(SecurityService.class);
pluggableTaskService = mock(PluggableTaskService.class);
when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
pipelineConfigService = new PipelineConfigService(goConfigService, securityService, pluggableTaskService, null);
}
Aggregations