use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineOperationsControllerV1 method schedule.
public String schedule(Request req, Response res) throws IOException {
HttpOperationResult result = new HttpOperationResult();
String pipelineName = req.params("pipeline_name");
pipelineTriggerService.schedule(pipelineName, getScheduleOptions(req), currentUsername(), result);
return renderHTTPOperationResult(result, req, res);
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineOperationsControllerV1 method unlock.
public String unlock(Request req, Response res) throws IOException {
HttpOperationResult result = new HttpOperationResult();
String pipelineName = req.params("pipeline_name");
pipelineUnlockApiService.unlock(pipelineName, currentUsername(), result);
return renderHTTPOperationResult(result, req, res);
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineOperationsControllerV1 method getStatusInfo.
String getStatusInfo(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
HttpOperationResult result = new HttpOperationResult();
PipelineStatusModel pipelineStatus = pipelineHistoryService.getPipelineStatus(pipelineName, currentUsernameString(), result);
if (result.canContinue()) {
return writerForTopLevelObject(request, response, (outputWriter) -> PipelineStatusModelRepresenter.toJSON(outputWriter, pipelineStatus));
}
return renderHTTPOperationResult(result, request, response);
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class ArtifactsDiskCleanerTest method shouldTriggerCleanupWhenLimitReached.
@Test
@Timeout(20)
public void shouldTriggerCleanupWhenLimitReached() throws InterruptedException {
serverConfig.setPurgeLimits(20.0, 30.0);
final boolean[] artifactsDeletionTriggered = { false };
final Thread[] artifactDeleterThread = { null };
final Semaphore sem = new Semaphore(1);
sem.acquire();
artifactsDiskCleaner = new ArtifactsDiskCleaner(sysEnv, goConfigService, diskSpaceChecker, artifactService, stageService, configDbStateRepository) {
@Override
void deleteOldArtifacts() {
artifactDeleterThread[0] = Thread.currentThread();
artifactsDeletionTriggered[0] = true;
sem.release();
}
};
Thread cleaner = (Thread) ReflectionUtil.getField(artifactsDiskCleaner, "cleaner");
while (!cleaner.getState().equals(Thread.State.WAITING)) {
Thread.sleep(5);
}
artifactsDiskCleaner.createFailure(new HttpOperationResult(), 10, 100);
sem.acquire();
assertThat(artifactsDeletionTriggered[0], is(true));
assertThat(artifactDeleterThread[0], not(sameInstance(Thread.currentThread())));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class JobRerunScheduleServiceTest method shouldMarkResultIfScheduleFailsForUnexpectedReason.
@Test
void shouldMarkResultIfScheduleFailsForUnexpectedReason() {
PipelineConfig mingleConfig = PipelineConfigMother.createPipelineConfig("mingle", "build", "unit", "functional");
Pipeline pipeline = PipelineMother.passedPipelineInstance("mingle", "build", "unit");
Stage firstStage = pipeline.getFirstStage();
stub(mingleConfig, pipeline, firstStage);
// leads to null pointer exception
schedulingChecker = mock(SchedulingCheckerService.class);
doThrow(new NullPointerException("The whole world is a big null.")).when(schedulingChecker).canSchedule(any(OperationResult.class));
service = new ScheduleService(goConfigService, pipelineService, stageService, schedulingChecker, 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), null, null, null, null, null, schedulingPerformanceLogger, null, null);
HttpOperationResult result = new HttpOperationResult();
try (LogFixture logFixture = logFixtureFor(ScheduleService.class, Level.DEBUG)) {
Stage stage = service.rerunJobs(firstStage, a("unit"), result);
assertThat(logFixture.contains(Level.ERROR, "Job rerun request for job(s) [unit] could not be completed because of unexpected failure. Cause: The whole world is a big null.")).isTrue();
assertThat(stage).isNull();
assertThat(result.httpCode()).isEqualTo(500);
assertThat(result.message()).isEqualTo("Job rerun request for job(s) [unit] could not be completed because of unexpected failure. Cause: The whole world is a big null.");
}
}
Aggregations