Search in sources :

Example 1 with GoDiskSpaceMonitor

use of com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor in project gocd by gocd.

the class BuildCauseProducerServiceConfigRepoIntegrationTest method setup.

@BeforeEach
public void setup(@TempDir Path tempDir) throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", tempDir);
    dbHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    materialConfig = hgRepo.materialConfig();
    ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(materialConfig, "gocd-xml", "gocd-id");
    config.getRules().add(new Allow("refer", "*", "*"));
    configHelper.addConfigRepo(config);
    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();
    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));
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) Allow(com.thoughtworks.go.config.rules.Allow) ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with GoDiskSpaceMonitor

use of com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor in project gocd by gocd.

the class BuildCauseProducerServiceConfigRepoIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", temporaryFolder);
    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));
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo) Before(org.junit.Before)

Example 3 with GoDiskSpaceMonitor

use of com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor in project gocd by gocd.

the class ConfigMaterialUpdaterIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    materialConfig = new HgMaterialConfig(hgRepo.projectRepositoryUrl(), null);
    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 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 = configTestRepo.getMaterial();
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo)

Example 4 with GoDiskSpaceMonitor

use of com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor in project gocd by gocd.

the class ConfigMaterialUpdateListenerIntegrationTest method setup.

@BeforeEach
public void setup(@TempDir Path tempDir) throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", tempDir);
    dbHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    materialConfig = hg(hgRepo.projectRepositoryUrl(), null);
    ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(materialConfig, "gocd-xml", "gocd-id");
    config.getRules().add(new Allow("refer", "*", "*"));
    configHelper.addConfigRepo(config);
    TestingEmailSender emailSender = new TestingEmailSender();
    SystemDiskSpaceChecker mockDiskSpaceChecker = Mockito.mock(SystemDiskSpaceChecker.class);
    StageService stageService = mock(StageService.class);
    ConfigDbStateRepository configDbStateRepository = mock(ConfigDbStateRepository.class);
    GoDiskSpaceMonitor goDiskSpaceMonitor = new GoDiskSpaceMonitor(goConfigService, systemEnvironment, serverHealthService, emailSender, mockDiskSpaceChecker, mock(ArtifactsService.class), stageService, configDbStateRepository);
    goDiskSpaceMonitor.initialize();
    xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
    configTestRepo = new ConfigTestRepo(hgRepo, xmlWriter);
    this.material = configTestRepo.getMaterial();
}
Also used : ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) Allow(com.thoughtworks.go.config.rules.Allow) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)4 ConfigTestRepo (com.thoughtworks.go.helper.ConfigTestRepo)4 HgTestRepo (com.thoughtworks.go.helper.HgTestRepo)4 GoDiskSpaceMonitor (com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor)4 MDUPerformanceLogger (com.thoughtworks.go.server.perf.MDUPerformanceLogger)3 Materials (com.thoughtworks.go.config.materials.Materials)2 Allow (com.thoughtworks.go.config.rules.Allow)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)1 Before (org.junit.Before)1