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

HAL-1920 part 2: Fixing ManagementOperationsTest.cancelNonProgressingOperation #193

Merged
merged 1 commit into from
Nov 9, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void cancelNonProgressingOperation() throws Exception {
page.navigate();
managementOps.waitForNonProgressingOperation(25);
page.cancelNonProgressingOperation();
assertTrue(managementOps.thereIsNoNonProgressingOperationATM());
assertTrue(managementOps.areNonProgressiveOperationsCancelledATM());

deployFuture.join();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ public long waitForNonProgressingOperation(int timeoutInSeconds) throws IOExcept
return Long.parseLong(nonProgressingOperationResult.stringValue());
}

public boolean thereIsNoNonProgressingOperationATM() throws InterruptedException, IOException {
public boolean areNonProgressiveOperationsCancelledATM() throws InterruptedException, IOException {
int timeoutInMilis = 220; // just to be sure all actions are propagated
long startTime = System.currentTimeMillis();
ModelNodeResult nonProgressingOperationResult = findNonProgressingOperation();
while (nonProgressingOperationResult.hasDefinedValue()) {
while (!areNonProgressiveOperationsCancelled()) {
if (System.currentTimeMillis() - startTime > timeoutInMilis) {
return false;
}
TimeUnit.MILLISECONDS.sleep(50);
nonProgressingOperationResult = findNonProgressingOperation();
}
return true;
}
Expand All @@ -75,4 +73,20 @@ private ModelNodeResult findNonProgressingOperation() throws IOException {
result.assertSuccess();
return result;
}

private boolean areNonProgressiveOperationsCancelled() throws IOException {
ModelNodeResult nonProgressingOperationResult = findNonProgressingOperation();
// just one operation is expected, improve this if needed
String operationId = nonProgressingOperationResult.get(RESULT).asStringOrNull();
if (operationId != null) {
return isActiveOperationCancelled(operationId);
}
return true;
}

private boolean isActiveOperationCancelled(String operationId) throws IOException {
ModelNodeResult result = ops.readAttribute(MANAGEMENT_OPERATIONS_ADDRESS.and(ACTIVE_OPERATION, operationId), CANCELLED);
result.assertSuccess();
return result.asBoolean();
}
}