Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading