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 3cb5d07dbdd2..35ce2cffca7d 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 @@ -76,6 +76,7 @@ import org.apache.nifi.web.api.dto.status.ProcessGroupStatusSnapshotDTO; import org.apache.nifi.web.api.dto.status.ProcessorStatusSnapshotDTO; import org.apache.nifi.web.api.entity.ActivateControllerServicesEntity; +import org.apache.nifi.web.api.entity.AssetsEntity; import org.apache.nifi.web.api.entity.ConfigurationStepEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionStatusEntity; @@ -526,6 +527,27 @@ public void waitForConnectorState(final String connectorId, final ConnectorState } } + public void waitForAssetRemoved(final String connectorId, final String assetId) + throws NiFiClientException, IOException, InterruptedException { + int iteration = 0; + while (true) { + final AssetsEntity assetsEntity = getConnectorClient().getAssets(connectorId); + final boolean assetStillPresent = assetsEntity.getAssets() != null + && assetsEntity.getAssets().stream() + .filter(a -> a.getAsset() != null) + .anyMatch(a -> assetId.equals(a.getAsset().getId())); + if (!assetStillPresent) { + return; + } + + if (iteration++ % 30 == 0) { + logger.info("Asset with ID {} is still present for Connector {} but waiting for removal.", assetId, connectorId); + } + + Thread.sleep(100L); + } + } + public ConnectorEntity drainConnector(final String connectorId) throws NiFiClientException, IOException { final ConnectorEntity entity = getConnectorClient().getConnector(connectorId); entity.setDisconnectedNodeAcknowledged(true); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/connectors/ConnectorAssetsIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/connectors/ConnectorAssetsIT.java index 40a2bce775df..e02a3b3e5b0b 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/connectors/ConnectorAssetsIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/connectors/ConnectorAssetsIT.java @@ -188,15 +188,8 @@ public void testCreateConnectorAndUploadAsset() throws NiFiClientException, IOEx getClientUtil().waitForConnectorState(connectorId, ConnectorState.STOPPED); - // Verify that the Asset has been removed from the Connector's Assets list - final AssetsEntity assetsAfterRemoval = connectorClient.getAssets(connectorId); - assertNotNull(assetsAfterRemoval); - - final boolean assetStillPresent = assetsAfterRemoval.getAssets() != null && assetsAfterRemoval.getAssets().stream() - .filter(a -> a.getAsset() != null) - .anyMatch(a -> uploadedAssetId.equals(a.getAsset().getId())); - - assertFalse(assetStillPresent); + // Wait for the Asset to be removed from the Connector's Assets list + getClientUtil().waitForAssetRemoved(connectorId, uploadedAssetId); // Wait for Connector to stop before attempting to delete it. getClientUtil().waitForConnectorStopped(connectorAfterApply.getId());