use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class GoConfigFileHelper method createTestingDao.
/**
* Creates config dao that has custom remote configuration parts provided by partialConfig argument
*/
public static GoConfigDao createTestingDao(GoPartialConfig partialConfig) {
SystemEnvironment systemEnvironment = new SystemEnvironment();
try {
ServerHealthService serverHealthService = new ServerHealthService();
ConfigRepository configRepository = new ConfigRepository(systemEnvironment);
configRepository.initialize();
FullConfigSaveNormalFlow normalFlow = new FullConfigSaveNormalFlow(new ConfigCache(), com.thoughtworks.go.util.ConfigElementImplementationRegistryMother.withNoPlugins(), systemEnvironment, new ServerVersion(), new TimeProvider(), configRepository, new CachedGoPartials(serverHealthService));
GoFileConfigDataSource dataSource = new GoFileConfigDataSource(new DoNotUpgrade(), configRepository, systemEnvironment, new TimeProvider(), new ConfigCache(), new ServerVersion(), com.thoughtworks.go.util.ConfigElementImplementationRegistryMother.withNoPlugins(), serverHealthService, new CachedGoPartials(serverHealthService), null, normalFlow);
dataSource.upgradeIfNecessary();
CachedGoPartials cachedGoPartials = new CachedGoPartials(serverHealthService);
CachedGoConfig cachedConfigService = new CachedGoConfig(serverHealthService, dataSource, cachedGoPartials, null, null);
cachedConfigService.loadConfigIfNull();
return new GoConfigDao(cachedConfigService);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class GoConfigMigrationIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
File file = temporaryFolder.newFolder();
configFile = new File(file, "cruise-config.xml");
new SystemEnvironment().setProperty(SystemEnvironment.CONFIG_FILE_PROPERTY, configFile.getAbsolutePath());
GoConfigFileHelper.clearConfigVersions();
configRepository = new ConfigRepository(systemEnvironment);
configRepository.initialize();
serverHealthService.removeAllLogs();
currentGoServerVersion = serverVersion.version();
loader = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins());
password = UUID.randomUUID().toString();
encryptedPassword = new GoCipher().encrypt(password);
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class BackupServiceIntegrationTest method shouldReturnIfBackupIsInProgress.
@Test
public void shouldReturnIfBackupIsInProgress() throws InterruptedException {
final Semaphore waitForBackupToBegin = new Semaphore(1);
final Semaphore waitForAssertion_whichHasToHappen_whileBackupIsRunning = new Semaphore(1);
Database databaseStrategyMock = mock(Database.class);
doAnswer((Answer<Object>) invocationOnMock -> {
waitForBackupToBegin.release();
waitForAssertion_whichHasToHappen_whileBackupIsRunning.acquire();
return null;
}).when(databaseStrategyMock).backup(any(File.class));
final BackupService backupService = new BackupService(artifactsDirHolder, goConfigService, new TimeProvider(), backupInfoRepository, systemEnvSpy, configRepository, databaseStrategyMock, null);
waitForBackupToBegin.acquire();
Thread thd = new Thread(() -> backupService.startBackup(admin));
thd.start();
waitForAssertion_whichHasToHappen_whileBackupIsRunning.acquire();
waitForBackupToBegin.acquire();
assertThat(backupService.isBackingUp(), is(true));
waitForAssertion_whichHasToHappen_whileBackupIsRunning.release();
thd.join();
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class ConfigGitRepoFilter method init.
@Override
public void init(FilterConfig config) throws ServletException {
ConfigRepository configRepository = ContextLoader.getCurrentWebApplicationContext().getBean(ConfigRepository.class);
FileResolver<HttpServletRequest> resolver = new FileResolver<>();
resolver.exportRepository("api/config-repository.git", configRepository.getGitRepo());
setRepositoryResolver(resolver);
setReceivePackFactory(null);
super.init(config);
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class GoConfigFileHelper method createTestingDao.
/**
* Creates config dao that accesses single file
*/
public static GoConfigDao createTestingDao() {
SystemEnvironment systemEnvironment = new SystemEnvironment();
try {
MaintenanceModeService maintenanceModeService = new MaintenanceModeService(new TimeProvider(), systemEnvironment);
ServerHealthService serverHealthService = new ServerHealthService();
ConfigRepository configRepository = new ConfigRepository(systemEnvironment);
configRepository.initialize();
ConfigCache configCache = new ConfigCache();
ConfigElementImplementationRegistry configElementImplementationRegistry = ConfigElementImplementationRegistryMother.withNoPlugins();
CachedGoPartials cachedGoPartials = new CachedGoPartials(serverHealthService);
FullConfigSaveNormalFlow normalFlow = new FullConfigSaveNormalFlow(configCache, configElementImplementationRegistry, systemEnvironment, new TimeProvider(), configRepository, cachedGoPartials);
GoFileConfigDataSource dataSource = new GoFileConfigDataSource(new DoNotUpgrade(), configRepository, systemEnvironment, new TimeProvider(), configCache, configElementImplementationRegistry, cachedGoPartials, null, normalFlow, mock(PartialConfigHelper.class));
GoConfigMigration goConfigMigration = new GoConfigMigration(new TimeProvider(), configElementImplementationRegistry);
GoConfigMigrator goConfigMigrator = new GoConfigMigrator(goConfigMigration, new SystemEnvironment(), configCache, configElementImplementationRegistry, normalFlow, configRepository, serverHealthService);
FileUtils.writeStringToFile(dataSource.fileLocation(), ConfigFileFixture.configWithSecurity(""), UTF_8);
goConfigMigrator.migrate();
CachedGoConfig cachedConfigService = new CachedGoConfig(serverHealthService, dataSource, cachedGoPartials, null, maintenanceModeService);
cachedConfigService.loadConfigIfNull();
return new GoConfigDao(cachedConfigService);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations