Skip to content

Commit

Permalink
fix(cloudfoundry): Update ProcessStats model due to capi-1.84.0 chang…
Browse files Browse the repository at this point in the history
…es (#6283) (#6293)

(cherry picked from commit 031bf1d)

Co-authored-by: Christos Arvanitis <[email protected]>
  • Loading branch information
mergify[bot] and christosarvanitis authored Oct 15, 2024
1 parent 59c86f4 commit c83c7c0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum State {
RUNNING,
CRASHED,
STARTING,
STOPPING,
DOWN
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static String describeProcessState(ProcessStats.State state) {
return "is still starting";
case CRASHED:
return "crashed";
case STOPPING:
return "is in graceful shutdown - stopping";
case RUNNING:
case DOWN:
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public Void operate(List priorOutputs) {
() -> client.getApplications().getAppState(description.getServerGroupId()),
inProgressState ->
inProgressState != ProcessStats.State.STARTING
&& inProgressState != ProcessStats.State.RUNNING,
&& inProgressState != ProcessStats.State.RUNNING
&& inProgressState != ProcessStats.State.STOPPING,
null,
getTask(),
description.getServerGroupName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,27 @@ void failedToStop() {
.isEqualTo(
"Cloud Foundry API returned with error(s): Failed to stop 'myapp' which instead is running");
}

@Test
void failedToStopStopping() {
OperationPoller poller = mock(OperationPoller.class);

//noinspection unchecked
when(poller.waitForOperation(any(Supplier.class), any(), any(), any(), any(), any()))
.thenReturn(ProcessStats.State.STOPPING);

StopCloudFoundryServerGroupAtomicOperation op =
new StopCloudFoundryServerGroupAtomicOperation(poller, desc);

Task task = runOperation(op);
List<Object> resultObjects = task.getResultObjects();
assertThat(resultObjects.size()).isEqualTo(1);
Object o = resultObjects.get(0);
assertThat(o).isInstanceOf(Map.class);
Object ex = ((Map) o).get("EXCEPTION");
assertThat(ex).isInstanceOf(CloudFoundryApiException.class);
assertThat(((CloudFoundryApiException) ex).getMessage())
.isEqualTo(
"Cloud Foundry API returned with error(s): Failed to stop 'myapp' which instead is in graceful shutdown - stopping");
}
}

0 comments on commit c83c7c0

Please sign in to comment.