Skip to content

Commit

Permalink
NIFI-13802: Renamed system tests to ensure that they end in IT. Also …
Browse files Browse the repository at this point in the history
…a bit of cleanup in the system tests and ensure that the RestartWithDifferentPort test does not allow instance reuse, since it changes the nifi port, which can cause subsequent tests to fail if they use that same instance
  • Loading branch information
markap14 committed Sep 24, 2024
1 parent 69b9939 commit a525da3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -623,15 +623,17 @@ protected NodeEntity getNodeEntity(final int nodeIndex) throws NiFiClientExcepti
final ClusterEntity clusterEntity = getNifiClient().getControllerClient().getNodes();
final int expectedPort = getClientApiPort() + nodeIndex - 1;

final List<Integer> nodePorts = new ArrayList<>();
for (final NodeDTO nodeDto : clusterEntity.getCluster().getNodes()) {
nodePorts.add(nodeDto.getApiPort());
if (nodeDto.getApiPort() == expectedPort) {
final NodeEntity nodeEntity = new NodeEntity();
nodeEntity.setNode(nodeDto);
return nodeEntity;
}
}

throw new IllegalStateException("Could not find node with API Port of " + expectedPort);
throw new IllegalStateException("Could not find node with API Port of " + expectedPort + "; found nodes: " + nodePorts);
}

protected void waitForNodeState(final int nodeIndex, final NodeConnectionState... nodeStates) throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory;
import org.junit.jupiter.api.Test;

public class JoinClusterWithMissingConnectionNoData extends NiFiSystemIT {
public class JoinClusterWithMissingConnectionNoDataIT extends NiFiSystemIT {
@Override
public NiFiInstanceFactory getInstanceFactory() {
return new SpawnedClusterNiFiInstanceFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
import org.apache.nifi.web.api.entity.NodeEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class JoinClusterWithMissingConnectionWithData extends NiFiSystemIT {
public class JoinClusterWithMissingConnectionWithDataIT extends NiFiSystemIT {
private static final Logger logger = LoggerFactory.getLogger(JoinClusterWithMissingConnectionWithDataIT.class);

private static final String GENERATE_UUID = "6be9a7e7-016e-1000-0000-00004700499d";
private static final String CONNECTION_UUID = "6be9a991-016e-1000-ffff-fffffebf0217";

Expand Down Expand Up @@ -135,8 +139,8 @@ private boolean isDataQueued() {
final FlowDTO flowDto;
try {
flowDto = getNifiClient().getFlowClient().getProcessGroup("root").getProcessGroupFlow().getFlow();
} catch (Exception e) {
e.printStackTrace();
} catch (final Exception e) {
logger.error("Failed to retrieve flow", e);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class RestartWithDifferentPort extends NiFiSystemIT {
public class RestartWithDifferentPortIT extends NiFiSystemIT {
@Override
public NiFiInstanceFactory getInstanceFactory() {
return createTwoNodeInstanceFactory();
}

@Override
protected boolean isAllowFactoryReuse() {
// Do not allow reuse of the factory because we are changing the port that node 2 starts on, which can then cause
// subsequent tests to fail, if they are attempting to get node by port number.
return false;
}

@Test
public void testRestartWithDifferentPortKeepsNodeIdUnchanged() throws IOException, NiFiClientException {
// Get the set of Node UUID's
Expand Down

0 comments on commit a525da3

Please sign in to comment.