Search in sources :

Example 11 with ServerHealthService

use of com.thoughtworks.go.serverhealth.ServerHealthService in project gocd by gocd.

the class PipelineSchedulerTest method setUp.

@Before
public void setUp() {
    queue = mock(ScheduleCheckQueue.class);
    configService = mock(GoConfigService.class);
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    SchedulingCheckerService schedulingCheckerService = mock(SchedulingCheckerService.class);
    buildCauseProducerService = mock(BuildCauseProducerService.class);
    topic = mock(ScheduleCheckCompletedTopic.class);
    schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
    scheduler = new PipelineScheduler(configService, serverHealthService, schedulingCheckerService, buildCauseProducerService, queue, topic, schedulingPerformanceLogger);
}
Also used : ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) SchedulingPerformanceLogger(com.thoughtworks.go.server.perf.SchedulingPerformanceLogger) Before(org.junit.Before)

Example 12 with ServerHealthService

use of com.thoughtworks.go.serverhealth.ServerHealthService 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 {
        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 ServerVersion(), new TimeProvider(), configRepository, cachedGoPartials);
        GoFileConfigDataSource dataSource = new GoFileConfigDataSource(new DoNotUpgrade(), configRepository, systemEnvironment, new TimeProvider(), configCache, new ServerVersion(), configElementImplementationRegistry, serverHealthService, cachedGoPartials, null, normalFlow);
        dataSource.upgradeIfNecessary();
        CachedGoConfig cachedConfigService = new CachedGoConfig(serverHealthService, dataSource, cachedGoPartials, null, null);
        cachedConfigService.loadConfigIfNull();
        return new GoConfigDao(cachedConfigService);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) IOException(java.io.IOException) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService)

Example 13 with ServerHealthService

use of com.thoughtworks.go.serverhealth.ServerHealthService 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);
    }
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) IOException(java.io.IOException) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService)

Example 14 with ServerHealthService

use of com.thoughtworks.go.serverhealth.ServerHealthService in project gocd by gocd.

the class GoPartialConfigTest method setUp.

@Before
public void setUp() {
    serverHealthService = mock(ServerHealthService.class);
    configPluginService = mock(GoConfigPluginService.class);
    plugin = mock(PartialConfigProvider.class);
    when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(plugin);
    cruiseConfig = new BasicCruiseConfig();
    configRepoConfig = new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
    cachedGoConfig = mock(CachedGoConfig.class);
    when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
    configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
    repoConfigDataSource = new GoRepoConfigDataSource(configWatchList, configPluginService, serverHealthService);
    cachedGoPartials = new CachedGoPartials(serverHealthService);
    goConfigService = mock(GoConfigService.class);
    serverHealthService = mock(ServerHealthService.class);
    partialConfig = new GoPartialConfig(repoConfigDataSource, configWatchList, goConfigService, cachedGoPartials, serverHealthService);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) Before(org.junit.Before)

Example 15 with ServerHealthService

use of com.thoughtworks.go.serverhealth.ServerHealthService in project gocd by gocd.

the class InvalidConfigMessageRemoverTest method shouldRemoveServerHealthServiceMessageAboutStartedWithInvalidConfigurationOnPipelineConfigSave.

@Test
public void shouldRemoveServerHealthServiceMessageAboutStartedWithInvalidConfigurationOnPipelineConfigSave() {
    GoConfigService goConfigService = mock(GoConfigService.class);
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    ArgumentCaptor<ConfigChangedListener> configChangedListenerArgumentCaptor = ArgumentCaptor.forClass(ConfigChangedListener.class);
    doNothing().when(goConfigService).register(configChangedListenerArgumentCaptor.capture());
    InvalidConfigMessageRemover invalidConfigMessageRemover = new InvalidConfigMessageRemover(goConfigService, serverHealthService);
    invalidConfigMessageRemover.initialize();
    invalidConfigMessageRemover.onConfigChange(null);
    List<ConfigChangedListener> listeners = configChangedListenerArgumentCaptor.getAllValues();
    assertThat(listeners.get(1) instanceof EntityConfigChangedListener, is(true));
    EntityConfigChangedListener listener = (EntityConfigChangedListener) listeners.get(1);
    assertThat(listener.shouldCareAbout(mock(PipelineConfig.class)), is(true));
    invalidConfigMessageRemover.pipelineConfigChangedListener().onEntityConfigChange(mock(PipelineConfig.class));
    ArgumentCaptor<HealthStateScope> captor = ArgumentCaptor.forClass(HealthStateScope.class);
    verify(serverHealthService).removeByScope(captor.capture());
    assertThat(captor.getValue().compareTo(HealthStateScope.forInvalidConfig()), is(0));
}
Also used : HealthStateScope(com.thoughtworks.go.serverhealth.HealthStateScope) EntityConfigChangedListener(com.thoughtworks.go.listener.EntityConfigChangedListener) ConfigChangedListener(com.thoughtworks.go.listener.ConfigChangedListener) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) EntityConfigChangedListener(com.thoughtworks.go.listener.EntityConfigChangedListener) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Test(org.junit.Test)

Aggregations

ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)26 Before (org.junit.Before)13 Test (org.junit.Test)7 SchedulingPerformanceLogger (com.thoughtworks.go.server.perf.SchedulingPerformanceLogger)4 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)4 ConfigRepository (com.thoughtworks.go.service.ConfigRepository)4 IOException (java.io.IOException)4 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)3 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)3 TestTransactionTemplate (com.thoughtworks.go.server.transaction.TestTransactionTemplate)3 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 TimeProvider (com.thoughtworks.go.util.TimeProvider)3 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)2 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)2 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)2 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 Pipeline (com.thoughtworks.go.domain.Pipeline)2