diff --git a/tests-configuration-management/src/test/java/org/jboss/hal/testsuite/test/configuration/management/operations/ManagementOperationsTest.java b/tests-configuration-management/src/test/java/org/jboss/hal/testsuite/test/configuration/management/operations/ManagementOperationsTest.java index faf61ed9..783a9136 100644 --- a/tests-configuration-management/src/test/java/org/jboss/hal/testsuite/test/configuration/management/operations/ManagementOperationsTest.java +++ b/tests-configuration-management/src/test/java/org/jboss/hal/testsuite/test/configuration/management/operations/ManagementOperationsTest.java @@ -100,7 +100,7 @@ public void cancelNonProgressingOperation() throws Exception { page.navigate(); managementOps.waitForNonProgressingOperation(25); page.cancelNonProgressingOperation(); - assertTrue(managementOps.thereIsNoNonProgressingOperationATM()); + assertTrue(managementOps.areNonProgressiveOperationsCancelledATM()); deployFuture.join(); } diff --git a/tooling-management-operations/src/main/java/org/jboss/hal/testsuite/tooling/management/operations/ManagementOperations.java b/tooling-management-operations/src/main/java/org/jboss/hal/testsuite/tooling/management/operations/ManagementOperations.java index c19a9c3d..b25b8c5a 100644 --- a/tooling-management-operations/src/main/java/org/jboss/hal/testsuite/tooling/management/operations/ManagementOperations.java +++ b/tooling-management-operations/src/main/java/org/jboss/hal/testsuite/tooling/management/operations/ManagementOperations.java @@ -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; } @@ -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(); + } }