Search in sources :

Example 11 with HealthStateType

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

the class ManualPipelineChecker method check.

@Override
public void check(OperationResult result) {
    HealthStateType type = HealthStateType.general(HealthStateScope.forPipeline(CaseInsensitiveString.str(pipelineConfig.name())));
    if (pipelineConfig.isFirstStageManualApproval()) {
        String message = String.format("Failed to trigger pipeline [%s]", pipelineConfig.name());
        result.error(message, String.format("The first stage of pipeline \"%s\" has manual approval", pipelineConfig.name()), type);
    } else {
        result.success(type);
    }
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) HealthStateType(com.thoughtworks.go.serverhealth.HealthStateType)

Example 12 with HealthStateType

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

the class PipelineLockChecker method check.

@Override
public void check(OperationResult result) {
    HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forPipeline(pipelineName));
    if (pipelineLockService.isLocked(pipelineName)) {
        String message = format("Pipeline %s cannot be scheduled", pipelineName);
        String description = format("Pipeline %s is locked as another instance of this pipeline is running.", pipelineName);
        result.conflict(message, description, healthStateType);
    } else {
        result.success(healthStateType);
    }
}
Also used : HealthStateType(com.thoughtworks.go.serverhealth.HealthStateType)

Example 13 with HealthStateType

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

the class StageAuthorizationChecker method check.

@Override
public void check(OperationResult result) {
    HealthStateType id = HealthStateType.general(HealthStateScope.forPipeline(pipelineName));
    if (!securityService.hasOperatePermissionForStage(pipelineName, stageName, username)) {
        String message = String.format("Failed to trigger pipeline [%s]", pipelineName);
        result.forbidden(message, "User " + username + " does not have permission to schedule " + pipelineName + "/" + stageName, id);
    } else {
        result.success(id);
    }
}
Also used : HealthStateType(com.thoughtworks.go.serverhealth.HealthStateType)

Example 14 with HealthStateType

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

the class PipelineLockCheckerTest method shouldUpdateOperationResultAfterUnlockSoThatTheErrorMessageOnUIGoesAway.

@Test
public void shouldUpdateOperationResultAfterUnlockSoThatTheErrorMessageOnUIGoesAway() {
    PipelineLockChecker pipelineLockChecker = new PipelineLockChecker("blahPipeline", pipelineLockService);
    HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forPipeline("blahPipeline"));
    when(pipelineLockService.isLocked("blahPipeline")).thenReturn(true);
    pipelineLockChecker.check(operationResult);
    Mockito.verify(operationResult).conflict("Pipeline blahPipeline cannot be scheduled", "Pipeline blahPipeline is locked as another instance of this pipeline is running.", healthStateType);
    when(pipelineLockService.isLocked("blahPipeline")).thenReturn(false);
    pipelineLockChecker.check(operationResult);
    Mockito.verify(operationResult).success(healthStateType);
}
Also used : HealthStateType(com.thoughtworks.go.serverhealth.HealthStateType) Test(org.junit.jupiter.api.Test)

Example 15 with HealthStateType

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

the class AutoSchedulerIntegrationTest method shouldLogErrorIntoServerHealthServiceWhenArtifactsDiskSpaceIsFull.

@Test
public void shouldLogErrorIntoServerHealthServiceWhenArtifactsDiskSpaceIsFull() throws Exception {
    serverHealthService.removeAllLogs();
    ArtifactsDiskIsFull full = new ArtifactsDiskIsFull();
    full.onSetUp();
    if (!configService.artifactsDir().exists()) {
        configService.artifactsDir().createNewFile();
    }
    try {
        pipelineScheduler.onTimer();
        HealthStateType healthStateType = HealthStateType.artifactsDiskFull();
        assertThat(serverHealthService, containsState(healthStateType, HealthStateLevel.ERROR, "GoCD Server has run out of artifacts disk space. Scheduling has been stopped"));
    } finally {
        full.onTearDown();
        configService.artifactsDir().delete();
    }
}
Also used : ArtifactsDiskIsFull(com.thoughtworks.go.fixture.ArtifactsDiskIsFull) HealthStateType(com.thoughtworks.go.serverhealth.HealthStateType) Test(org.junit.jupiter.api.Test)

Aggregations

HealthStateType (com.thoughtworks.go.serverhealth.HealthStateType)15 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)6 Test (org.junit.jupiter.api.Test)3 ApiController (com.thoughtworks.go.api.ApiController)1 ApiVersion (com.thoughtworks.go.api.ApiVersion)1 JsonReader (com.thoughtworks.go.api.representers.JsonReader)1 ApiAuthenticationHelper (com.thoughtworks.go.api.spring.ApiAuthenticationHelper)1 GsonTransformer (com.thoughtworks.go.api.util.GsonTransformer)1 HaltApiResponses (com.thoughtworks.go.api.util.HaltApiResponses)1 StageInstancesRepresenter (com.thoughtworks.go.apiv3.stageinstance.representers.StageInstancesRepresenter)1 StageRepresenter (com.thoughtworks.go.apiv3.stageinstance.representers.StageRepresenter)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 JobInstance (com.thoughtworks.go.domain.JobInstance)1 NullStage (com.thoughtworks.go.domain.NullStage)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 PipelineRunIdInfo (com.thoughtworks.go.domain.PipelineRunIdInfo)1 Stage (com.thoughtworks.go.domain.Stage)1 ArtifactsDiskIsFull (com.thoughtworks.go.fixture.ArtifactsDiskIsFull)1 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)1