Search in sources :

Example 46 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class DiskSpaceWarningCheckerTest method shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl.

@Test
public void shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl() throws URISyntaxException {
    String expectedHelpUrl = docsUrl("/installation/configuring_server_details.html");
    GoConfigService goConfigService = mockGoConfigServiceToHaveSiteUrl();
    SystemDiskSpaceChecker checker = mock(SystemDiskSpaceChecker.class);
    when(checker.getUsableSpace(any(File.class))).thenReturn(1000000L);
    ArtifactsDiskSpaceWarningChecker diskSpaceWarningChecker = new ArtifactsDiskSpaceWarningChecker(new SystemEnvironment(), null, goConfigService, checker, serverHealthService) {

        @Override
        protected String targetFolderCanonicalPath() {
            return ".";
        }
    };
    SendEmailMessage actual = diskSpaceWarningChecker.createEmail();
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    diskSpaceWarningChecker.check(result);
    assertThat(actual.getBody(), Matchers.containsString(expectedHelpUrl));
    assertThat(result.getServerHealthState().isSuccess(), is(true));
    assertThat(result.getServerHealthState().getMessage(), is("GoCD Server's artifact repository is running low on disk space"));
    assertThat(result.getServerHealthState().getType(), is(HealthStateType.artifactsDiskFull()));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) SendEmailMessage(com.thoughtworks.go.server.messaging.SendEmailMessage) Matchers.containsString(org.hamcrest.Matchers.containsString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 47 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class BuildCauseProducerServiceTest method manualTrigger_shouldUpdateJustPipelineConfigNotMaterialsWhenPipelineIsDefinedInConfigRepoAndMDUFlagIsTurnedOff.

@Test
public void manualTrigger_shouldUpdateJustPipelineConfigNotMaterialsWhenPipelineIsDefinedInConfigRepoAndMDUFlagIsTurnedOff() {
    HgMaterial material1 = new HgMaterial("url", null);
    HgMaterialConfig materialConfig1 = hg("url", null);
    HgMaterialConfig materialConfig2 = hg("url2", null);
    pipelineConfig.addMaterialConfig(materialConfig1);
    pipelineConfig.setOrigin(new RepoConfigOrigin(ConfigRepoConfig.createConfigRepoConfig(materialConfig2, "plug", "id"), "revision1"));
    when(materialConfigConverter.toMaterial(materialConfig2)).thenReturn(new MaterialConfigConverter().toMaterial(materialConfig2));
    ScheduleOptions scheduleOptions = new ScheduleOptions(new HashMap<>(), new HashMap<>(), new HashMap<>());
    scheduleOptions.shouldPerformMDUBeforeScheduling(false);
    buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), scheduleOptions, new ServerHealthStateOperationResult());
    verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
    MaterialUpdateStatusListener statusListener = extractMaterialListenerInstanceFromRegisterCall();
    statusListener.onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material1, 0));
    verify(mockMaterialUpdateStatusNotifier).registerListenerFor(eq(pipelineConfig), any(MaterialUpdateStatusListener.class));
    verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.jupiter.api.Test)

Example 48 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class CompositeCheckerTest method shouldReturnSuccessWhenAllTheCheckersReturnSuccess.

@Test
public void shouldReturnSuccessWhenAllTheCheckersReturnSuccess() {
    CompositeChecker checker = new CompositeChecker(successful(), successful());
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    checker.check(result);
    assertThat(result.getServerHealthState(), is(SUCCESS_SERVER_HEALTH_STATE));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.jupiter.api.Test)

Example 49 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class CompositeCheckerTest method shouldReturnTheFirstError.

@Test
public void shouldReturnTheFirstError() {
    CompositeChecker checker = new CompositeChecker(StubCheckerFactory.error(), StubCheckerFactory.anotherError());
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    checker.check(result);
    assertThat(result.getServerHealthState(), is(ERROR_SERVER_HEALTH_STATE));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.jupiter.api.Test)

Example 50 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class DiskSpaceWarningCheckerTest method shouldReturnSuccessWhenTheArtifactsFolderIsNotPresent.

@Test
public void shouldReturnSuccessWhenTheArtifactsFolderIsNotPresent() {
    final GoConfigService service = mock(GoConfigService.class);
    when(service.artifactsDir()).thenReturn(new File("/pavan"));
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    new ArtifactsDiskSpaceWarningChecker(new SystemEnvironment(), sender, service, new SystemDiskSpaceChecker(), serverHealthService).check(result);
    assertThat(result.getServerHealthState().isSuccess(), is(true));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)89 Test (org.junit.jupiter.api.Test)78 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)28 ScheduleOptions (com.thoughtworks.go.server.scheduling.ScheduleOptions)17 HashMap (java.util.HashMap)17 Pipeline (com.thoughtworks.go.domain.Pipeline)16 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)12 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)12 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)11 Modification (com.thoughtworks.go.domain.materials.Modification)10 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)8 Username (com.thoughtworks.go.server.domain.Username)8 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)6 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)6 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)6 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5 Materials (com.thoughtworks.go.config.materials.Materials)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)5