This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new a00cf8d7925 NIFI-15765 Improved reliability of NiFi System Integration 
Test teardown method  (#11073)
a00cf8d7925 is described below

commit a00cf8d7925af03768c85a68559ff4d9ff9ceb29
Author: Pierre Villard <[email protected]>
AuthorDate: Mon Mar 30 21:11:40 2026 +0200

    NIFI-15765 Improved reliability of NiFi System Integration Test teardown 
method  (#11073)
    
    Signed-off-by: David Handermann <[email protected]>
---
 .../org/apache/nifi/tests/system/NiFiSystemIT.java | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git 
a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java
 
b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java
index 3562174747b..dc576c275e7 100644
--- 
a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java
+++ 
b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java
@@ -156,17 +156,29 @@ public abstract class NiFiSystemIT implements 
NiFiInstanceProvider {
     public void teardown() throws Exception {
         logger.info("Beginning teardown");
 
+        setupClient();
+
         try {
             // In some cases a test can pass, but still leave a clustered 
instance with one
             // of the nodes in a bad state, if the instance then gets reused
             // it will cause later tests to fail, so it is better to destroy 
the environment
             // if the cluster is in a bad state at the end of a test
             final NiFiInstance nifiInstance = nifiRef.get();
-            if (nifiInstance != null && nifiInstance.isClustered() && 
(!isCoordinatorElected() || 
!allNodesConnected(nifiInstance.getNumberOfNodes()))) {
-                logger.info("Clustered environment is in a bad state, will 
completely tear down the environments and start with a clean environment for 
the next test.");
-                instanceCache.poison(nifiInstance);
-                cleanup();
-                return;
+            if (nifiInstance != null && nifiInstance.isClustered()) {
+                boolean clusterHealthy;
+                try {
+                    clusterHealthy = isCoordinatorElected() && 
allNodesConnected(nifiInstance.getNumberOfNodes());
+                } catch (final Exception e) {
+                    logger.warn("Failed to determine cluster health during 
teardown", e);
+                    clusterHealthy = false;
+                }
+
+                if (!clusterHealthy) {
+                    logger.info("Clustered environment is in a bad state, will 
completely tear down the environments and start with a clean environment for 
the next test.");
+                    instanceCache.poison(nifiInstance);
+                    cleanup();
+                    return;
+                }
             }
 
             Exception destroyFlowFailure = null;

Reply via email to