Search in sources :

Example 1 with ServerHealthStates

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

the class PipelineServiceTriangleDependencyTest method stubPipelineSaveForStatusListener.

private Pipeline stubPipelineSaveForStatusListener(StageStatusListener stageStatusListener, JobStatusListener jobStatusListener) {
    StageDao stageDao = mock(StageDao.class);
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
    JobInstanceService jobInstanceService = new JobInstanceService(mock(JobInstanceDao.class), mock(PropertiesService.class), mock(JobResultTopic.class), mock(JobStatusCache.class), actualTransactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, jobStatusListener);
    StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), mock(SecurityService.class), mock(PipelineDao.class), mock(ChangesetService.class), mock(GoConfigService.class), actualTransactionTemplate, transactionSynchronizationManager, goCache);
    Stage savedStage = StageMother.passedStageInstance("stage", "job", "pipeline-name");
    when(stageDao.save(any(Pipeline.class), any(Stage.class))).thenReturn(savedStage);
    stageService.addStageStatusListener(stageStatusListener);
    service = new PipelineService(pipelineDao, stageService, mock(PipelineLockService.class), pipelineTimeline, materialRepository, actualTransactionTemplate, systemEnvironment, null, materialConfigConverter);
    Pipeline pipeline = PipelineMother.pipeline("cruise", savedStage);
    when(pipelineDao.save(pipeline)).thenReturn(pipeline);
    when(pipelineTimeline.pipelineBefore(anyLong())).thenReturn(9L);
    when(pipelineTimeline.pipelineAfter(pipeline.getId())).thenReturn(-1L);
    when(materialRepository.findMaterialRevisionsForPipeline(9L)).thenReturn(MaterialRevisions.EMPTY);
    return pipeline;
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) JobResultTopic(com.thoughtworks.go.server.messaging.JobResultTopic) StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) JobInstanceDao(com.thoughtworks.go.server.dao.JobInstanceDao) Pipeline(com.thoughtworks.go.domain.Pipeline) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) JobStatusCache(com.thoughtworks.go.domain.activity.JobStatusCache) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) PipelineDao(com.thoughtworks.go.server.dao.PipelineDao) Stage(com.thoughtworks.go.domain.Stage)

Example 2 with ServerHealthStates

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

the class ScheduleServiceStageTriggerTest method jobInstanceService.

private JobInstanceService jobInstanceService(JobResultTopic jobResultTopic) {
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
    return new JobInstanceService(jobInstanceDao, propertiesService, jobResultTopic, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService);
}
Also used : ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates)

Example 3 with ServerHealthStates

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

the class ServerHealthInformationProvider method asJson.

@Override
public Map<String, Object> asJson() {
    LinkedHashMap<String, Object> json = new LinkedHashMap<>();
    ServerHealthStates allLogs = service.getAllLogs();
    json.put("Messages Count", allLogs.size());
    ArrayList<Map<String, String>> messages = new ArrayList<>();
    for (ServerHealthState log : allLogs) {
        messages.add(log.asJson());
    }
    json.put("Messages", messages);
    return json;
}
Also used : ArrayList(java.util.ArrayList) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with ServerHealthStates

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

the class PipelineServiceTest method stubPipelineSaveForStatusListener.

private Pipeline stubPipelineSaveForStatusListener(StageStatusListener stageStatusListener, JobStatusListener jobStatusListener) {
    StageDao stageDao = mock(StageDao.class);
    ServerHealthService serverHealthService = mock(ServerHealthService.class);
    when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
    JobInstanceService jobInstanceService = new JobInstanceService(mock(JobInstanceDao.class), mock(PropertiesService.class), mock(JobResultTopic.class), mock(JobStatusCache.class), actualTransactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, jobStatusListener);
    StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), mock(SecurityService.class), mock(PipelineDao.class), mock(ChangesetService.class), mock(GoConfigService.class), actualTransactionTemplate, transactionSynchronizationManager, goCache);
    Stage savedStage = StageMother.passedStageInstance("stage", "job", "pipeline-name");
    when(stageDao.save(any(Pipeline.class), any(Stage.class))).thenReturn(savedStage);
    stageService.addStageStatusListener(stageStatusListener);
    service = new PipelineService(pipelineDao, stageService, mock(PipelineLockService.class), pipelineTimeline, materialRepository, actualTransactionTemplate, systemEnvironment, null, materialConfigConverter);
    Pipeline pipeline = PipelineMother.pipeline("cruise", savedStage);
    when(pipelineDao.save(pipeline)).thenReturn(pipeline);
    when(pipelineTimeline.pipelineBefore(anyLong())).thenReturn(9L);
    when(pipelineTimeline.pipelineAfter(pipeline.getId())).thenReturn(-1L);
    when(materialRepository.findMaterialRevisionsForPipeline(9L)).thenReturn(MaterialRevisions.EMPTY);
    return pipeline;
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) JobResultTopic(com.thoughtworks.go.server.messaging.JobResultTopic) StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) JobInstanceDao(com.thoughtworks.go.server.dao.JobInstanceDao) Pipeline(com.thoughtworks.go.domain.Pipeline) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) JobStatusCache(com.thoughtworks.go.domain.activity.JobStatusCache) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) PipelineDao(com.thoughtworks.go.server.dao.PipelineDao) Stage(com.thoughtworks.go.domain.Stage)

Example 5 with ServerHealthStates

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

the class SCMMaterialSourceTest method shouldReloadSchedulableMaterialsOnConfigChange.

@Test
public void shouldReloadSchedulableMaterialsOnConfigChange() {
    Set<MaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config()));
    when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
    when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial)));
    Set<Material> materials = source.materialsForUpdate();
    assertThat(materials.size(), is(1));
    assertTrue(materials.contains(svnMaterial));
    schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config(), gitMaterial.config()));
    when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
    when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial, gitMaterial)));
    when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
    source.onConfigChange(mock(CruiseConfig.class));
    materials = source.materialsForUpdate();
    assertThat(materials.size(), is(2));
    assertTrue(materials.contains(svnMaterial));
    assertTrue(materials.contains(gitMaterial));
}
Also used : MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) Material(com.thoughtworks.go.domain.materials.Material) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ServerHealthStates (com.thoughtworks.go.serverhealth.ServerHealthStates)6 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)3 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)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 Material (com.thoughtworks.go.domain.materials.Material)2 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)2 JobInstanceDao (com.thoughtworks.go.server.dao.JobInstanceDao)2 PipelineDao (com.thoughtworks.go.server.dao.PipelineDao)2 StageDao (com.thoughtworks.go.server.dao.StageDao)2 JobResultTopic (com.thoughtworks.go.server.messaging.JobResultTopic)2 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ServerHealthState (com.thoughtworks.go.serverhealth.ServerHealthState)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1