This is an automated email from the ASF dual-hosted git repository. joewitt pushed a commit to branch support/nifi-1.16 in repository https://gitbox.apache.org/repos/asf/nifi.git
commit d02d119bfad9637add588bc1739c8dd38fe3978f Author: exceptionfactory <[email protected]> AuthorDate: Mon Mar 14 10:08:49 2022 -0500 NIFI-9793 Added wait for Controller Service run status in tests - Added check for controller-level service run status in disableControllerLevelServices to avoid HTTP 409 Conflict response when attempting to delete services This closes #5863 Signed-off-by: Paul Grey <[email protected]> --- .../org/apache/nifi/tests/system/NiFiClientUtil.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java index ba8ec40a94..0dc64eac5f 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java @@ -708,6 +708,7 @@ public class NiFiClientUtil { runStatusEntity.setRevision(service.getRevision()); runStatusEntity.setState(ActivateControllerServicesEntity.STATE_DISABLED); nifiClient.getControllerServicesClient().activateControllerService(service.getId(), runStatusEntity); + waitForControllerServiceRunStatus(service.getId(), ActivateControllerServicesEntity.STATE_DISABLED); } } @@ -719,6 +720,25 @@ public class NiFiClientUtil { } } + public void waitForControllerServiceRunStatus(final String id, final String requestedRunStatus) throws NiFiClientException, IOException { + while (true) { + final ControllerServiceEntity serviceEntity = nifiClient.getControllerServicesClient().getControllerService(id); + final String runStatus = serviceEntity.getStatus().getRunStatus(); + if (requestedRunStatus.equals(runStatus)) { + logger.info("Controller Service [{}] run status [{}] found", id, runStatus); + break; + } + + logger.info("Controller Service [{}] run status [{}] not matched [{}]: sleeping before retrying", id, runStatus, requestedRunStatus); + + try { + Thread.sleep(500L); + } catch (final Exception e) { + Assert.fail(e.toString()); + } + } + } + public void waitForControllerSerivcesDisabled(final String groupId, final String... serviceIdsOfInterest) throws NiFiClientException, IOException { waitForControllerServiceState(groupId, "DISABLED", Arrays.asList(serviceIdsOfInterest)); }
