Skip to content

Commit

Permalink
TSPS-325 Support for adding more CLI commands (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorgantaylor authored Nov 25, 2024
1 parent 30d8844 commit 5d78be2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
8 changes: 6 additions & 2 deletions common/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -731,16 +731,20 @@ components:

PipelineRun:
description: |
Object containing the job id, status, and user-provided description of a Pipeline Run.
Object containing the job id, status, user-provided description, time submitted, and (if run is complete) time completed of a Pipeline Run.
type: object
required: [ pipelineName, displayName, description ]
required: [ jobId, status, timeSubmitted ]
properties:
jobId:
$ref: '#/components/schemas/Id'
status:
$ref: "#/components/schemas/PipelineRunStatus"
description:
$ref: "#/components/schemas/PipelineRunDescription"
timeSubmitted:
$ref: "#/components/schemas/JobTimeSubmitted"
timeCompleted:
$ref: "#/components/schemas/JobTimeCompleted"

PipelineRunDescription:
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ public ResponseEntity<ApiGetPipelineRunsResponse> getAllPipelineRuns(
new ApiPipelineRun()
.jobId(pipelineRun.getJobId())
.status(pipelineRun.getStatus().name())
.description(pipelineRun.getDescription()))
.description(pipelineRun.getDescription())
.timeSubmitted(pipelineRun.getCreated().toString())
.timeCompleted(
pipelineRun.getStatus().isCompleted()
? pipelineRun.getUpdated().toString()
: null))
.toList();

ApiGetPipelineRunsResponse apiGetPipelineRunsResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public enum CommonPipelineRunStatusEnum {
public boolean isSuccess() {
return this == SUCCEEDED;
}

public boolean isCompleted() {
return this == SUCCEEDED || this == FAILED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,13 @@ void getAsyncResultEndpointHttp() {
void getAllPipelineRunsWithNoPageToken() throws Exception {
int limit = 5;
String pageToken = null;
PipelineRun pipelineRun = getPipelineRunPreparing();
PipelineRun pipelineRunPreparing = getPipelineRunPreparing();
PipelineRun pipelineRunSucceeded =
getPipelineRunWithStatus(CommonPipelineRunStatusEnum.SUCCEEDED);
PipelineRun pipelineRunFailed = getPipelineRunWithStatus(CommonPipelineRunStatusEnum.FAILED);
PageResponse<List<PipelineRun>> pageResponse =
new PageResponse<>(List.of(pipelineRun), null, null);
new PageResponse<>(
List.of(pipelineRunPreparing, pipelineRunSucceeded, pipelineRunFailed), null, null);

// the mocks
when(pipelineRunsServiceMock.findPipelineRunsPaginated(
Expand All @@ -605,13 +609,38 @@ void getAllPipelineRunsWithNoPageToken() throws Exception {
new ObjectMapper()
.readValue(result.getResponse().getContentAsString(), ApiGetPipelineRunsResponse.class);

// response should include one pipeline run
// response should include three pipeline runs
assertNull(response.getPageToken());
assertEquals(1, response.getResults().size());
ApiPipelineRun responsePipelineRun = response.getResults().get(0);
assertEquals(pipelineRun.getStatus().name(), responsePipelineRun.getStatus());
assertEquals(pipelineRun.getDescription(), responsePipelineRun.getDescription());
assertEquals(pipelineRun.getJobId(), responsePipelineRun.getJobId());
assertEquals(3, response.getResults().size());

// preparing run should not have a completed time
ApiPipelineRun responsePipelineRun1 = response.getResults().get(0);
assertEquals(pipelineRunPreparing.getStatus().name(), responsePipelineRun1.getStatus());
assertEquals(pipelineRunPreparing.getDescription(), responsePipelineRun1.getDescription());
assertEquals(pipelineRunPreparing.getJobId(), responsePipelineRun1.getJobId());
assertEquals(
pipelineRunPreparing.getCreated().toString(), responsePipelineRun1.getTimeSubmitted());
assertNull(responsePipelineRun1.getTimeCompleted());

// succeeded run should have a completed time
ApiPipelineRun responsePipelineRun2 = response.getResults().get(1);
assertEquals(pipelineRunSucceeded.getStatus().name(), responsePipelineRun2.getStatus());
assertEquals(pipelineRunSucceeded.getDescription(), responsePipelineRun2.getDescription());
assertEquals(pipelineRunSucceeded.getJobId(), responsePipelineRun2.getJobId());
assertEquals(
pipelineRunSucceeded.getCreated().toString(), responsePipelineRun2.getTimeSubmitted());
assertEquals(
pipelineRunSucceeded.getUpdated().toString(), responsePipelineRun2.getTimeCompleted());

// failed run should have a completed time
ApiPipelineRun responsePipelineRun3 = response.getResults().get(2);
assertEquals(pipelineRunFailed.getStatus().name(), responsePipelineRun3.getStatus());
assertEquals(pipelineRunFailed.getDescription(), responsePipelineRun3.getDescription());
assertEquals(pipelineRunFailed.getJobId(), responsePipelineRun3.getJobId());
assertEquals(
pipelineRunFailed.getCreated().toString(), responsePipelineRun3.getTimeSubmitted());
assertEquals(
pipelineRunFailed.getUpdated().toString(), responsePipelineRun3.getTimeCompleted());
}

@Test
Expand Down

0 comments on commit 5d78be2

Please sign in to comment.