Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cloudfoundry): Update ProcessStats model due to capi-1.84.0 changes (backport #6283) #6292

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}
Loading