Search in sources :

Example 6 with ServerHealthService

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

the class TimerSchedulerTest method shouldUpdateServerHealthStatusWhenPipelineCantBeAddedToTheQuartzScheduler.

@Test
public void shouldUpdateServerHealthStatusWhenPipelineCantBeAddedToTheQuartzScheduler() throws Exception {
    Scheduler scheduler = mock(Scheduler.class);
    when(scheduler.scheduleJob(any(JobDetail.class), any(Trigger.class))).thenThrow(new SchedulerException("scheduling failed!"));
    SchedulerFactory schedulerFactory = mock(SchedulerFactory.class);
    when(schedulerFactory.getScheduler()).thenReturn(scheduler);
    GoConfigService goConfigService = mock(GoConfigService.class);
    when(goConfigService.getAllPipelineConfigs()).thenReturn(asList(pipelineConfigWithTimer("uat", "* * * * * ?")));
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    TimerScheduler timerScheduler = new TimerScheduler(schedulerFactory, goConfigService, null, serverHealthService);
    timerScheduler.initialize();
    verify(serverHealthService).update(ServerHealthState.error("Could not register pipeline 'uat' with timer", "", HealthStateType.general(HealthStateScope.forPipeline("uat"))));
}
Also used : ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) Test(org.junit.Test)

Example 7 with ServerHealthService

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

the class TimerSchedulerTest method shouldUpdateServerHealthStatusWhenCronSpecCantBeParsed.

@Test
public void shouldUpdateServerHealthStatusWhenCronSpecCantBeParsed() throws Exception {
    when(schedulerFactory.getScheduler()).thenReturn(scheduler);
    GoConfigService goConfigService = mock(GoConfigService.class);
    when(goConfigService.getAllPipelineConfigs()).thenReturn(asList(pipelineConfigWithTimer("uat", "bad cron spec!!!")));
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    TimerScheduler timerScheduler = new TimerScheduler(schedulerFactory, goConfigService, null, serverHealthService);
    timerScheduler.initialize();
    verify(schedulerFactory).getScheduler();
    verify(scheduler).start();
    verify(serverHealthService).update(ServerHealthState.error("Bad timer specification for timer in Pipeline: uat", "Cannot schedule pipeline using the timer", HealthStateType.general(HealthStateScope.forPipeline("uat"))));
}
Also used : ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) Test(org.junit.Test)

Example 8 with ServerHealthService

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

the class JobRerunScheduleServiceTest method setup.

@Before
public void setup() {
    jobInstanceService = mock(JobInstanceService.class);
    goConfigService = mock(GoConfigService.class);
    environmentConfigService = mock(EnvironmentConfigService.class);
    serverHealthService = mock(ServerHealthService.class);
    final TestTransactionSynchronizationManager synchronizationManager = new TestTransactionSynchronizationManager();
    schedulingChecker = mock(SchedulingCheckerService.class);
    pipelineScheduleQueue = mock(PipelineScheduleQueue.class);
    pipelineService = mock(PipelineService.class);
    stageService = mock(StageService.class);
    securityService = mock(SecurityService.class);
    lockService = mock(PipelineLockService.class);
    txnTemplate = new TestTransactionTemplate(synchronizationManager);
    timeProvider = new TimeProvider();
    instanceFactory = mock(InstanceFactory.class);
    schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
    elasticProfileService = mock(ElasticProfileService.class);
    service = new ScheduleService(goConfigService, pipelineService, stageService, schedulingChecker, mock(PipelineScheduledTopic.class), mock(PipelineDao.class), mock(StageDao.class), mock(StageOrderService.class), securityService, pipelineScheduleQueue, jobInstanceService, mock(JobInstanceDao.class), mock(AgentAssignment.class), environmentConfigService, lockService, serverHealthService, txnTemplate, mock(AgentService.class), synchronizationManager, timeProvider, null, null, instanceFactory, schedulingPerformanceLogger, elasticProfileService);
}
Also used : TestTransactionTemplate(com.thoughtworks.go.server.transaction.TestTransactionTemplate) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) SchedulingPerformanceLogger(com.thoughtworks.go.server.perf.SchedulingPerformanceLogger) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) Before(org.junit.Before)

Example 9 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 10 with ServerHealthService

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

the class SCMMaterialSourceTest method setUp.

@Before
public void setUp() throws Exception {
    goConfigService = mock(GoConfigService.class);
    systemEnvironment = new SystemEnvironment();
    serverHealthService = mock(ServerHealthService.class);
    materialConfigConverter = mock(MaterialConfigConverter.class);
    materialUpdateService = mock(MaterialUpdateService.class);
    source = new SCMMaterialSource(goConfigService, systemEnvironment, materialConfigConverter, materialUpdateService);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Before(org.junit.Before)

Aggregations

ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)25 Before (org.junit.Before)12 Test (org.junit.Test)8 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 SchedulingPerformanceLogger (com.thoughtworks.go.server.perf.SchedulingPerformanceLogger)3 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)3 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)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 Stage (com.thoughtworks.go.domain.Stage)2 JobStatusCache (com.thoughtworks.go.domain.activity.JobStatusCache)2 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)2