Skip to content

Commit

Permalink
HAL-1920 part 2: Fixing ManagementOperationsTest.cancelNonProgressing…
Browse files Browse the repository at this point in the history
…Operation
  • Loading branch information
OndrejKotek committed Nov 8, 2023
1 parent f0d95fe commit d086cf0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
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();
}
}

0 comments on commit d086cf0

Please sign in to comment.