Search in sources :

Example 16 with ServerHealthStateOperationResult

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

the class DiskSpaceFullCheckerTest method shouldReturnFalseIfTheArtifactFolderExceedSizeLimit.

@Test
public void shouldReturnFalseIfTheArtifactFolderExceedSizeLimit() {
    CruiseConfig cruiseConfig = simulateFullDisk();
    ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    fullChecker.check(result);
    assertThat(result.getServerHealthState().isSuccess(), is(false));
    assertThat(result.getServerHealthState().getMessage(), is("GoCD Server has run out of artifacts disk space. Scheduling has been stopped"));
    assertThat(result.getServerHealthState().getType(), is(HealthStateType.artifactsDiskFull()));
    verify(sender).sendEmail(any(SendEmailMessage.class));
}
Also used : SendEmailMessage(com.thoughtworks.go.server.messaging.SendEmailMessage) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.jupiter.api.Test)

Example 17 with ServerHealthStateOperationResult

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

the class CompositeCheckerTest method shouldReturnErrorWhenWarningIsFollowedByError.

@Test
public void shouldReturnErrorWhenWarningIsFollowedByError() {
    CompositeChecker checker = new CompositeChecker(StubCheckerFactory.warning(), StubCheckerFactory.error());
    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 18 with ServerHealthStateOperationResult

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

the class CompositeCheckerTest method shouldReturnWarningWhenOneCheckerIsWarning.

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

Example 19 with ServerHealthStateOperationResult

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

the class DiskSpaceWarningCheckerTest method shouldShowAbsolutePathOfArtifactDirInWarningMessage.

// #2866
@Test
public void shouldShowAbsolutePathOfArtifactDirInWarningMessage() throws IOException, URISyntaxException {
    goConfigService = mockGoConfigServiceToHaveSiteUrl();
    TestingEmailSender sender = new TestingEmailSender();
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    systemEnvironment.setProperty(SystemEnvironment.ARTIFACT_WARNING_SIZE_LIMIT, "1200009M");
    ArtifactsDiskSpaceWarningChecker checker = new ArtifactsDiskSpaceWarningChecker(systemEnvironment, sender, goConfigService, new SystemDiskSpaceChecker(), serverHealthService);
    checker.check(new ServerHealthStateOperationResult());
    assertThat(sender.getSentMessage(), containsString(new File(".").getCanonicalPath()));
}
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)

Example 20 with ServerHealthStateOperationResult

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

the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldSchedulePipelineWhenManuallyTriggered.

@Test
public void shouldSchedulePipelineWhenManuallyTriggered() throws Exception {
    configTestRepo.addCodeToRepositoryAndPush("a.java", "added code file", "some java code");
    materialUpdateService.updateMaterial(material);
    waitForMaterialNotInProgress();
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    Map<CaseInsensitiveString, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(5);
    assertThat(afterLoad.keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
    BuildCause cause = afterLoad.get(new CaseInsensitiveString(PIPELINE_NAME));
    assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
}
Also used : ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) HashMap(java.util.HashMap) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) 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