Skip to content

Commit

Permalink
757 - Integration test for Hot Reload of nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Chandler committed Nov 19, 2024
1 parent b8c1d59 commit 51f0c98
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@
import com.github.dockerjava.api.command.StopContainerCmd;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.platform.commons.util.StringUtils;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.DockerComposeContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.node.BooleanNode;

import static org.junit.platform.commons.util.StringUtils.*;

public class AbstractCassandraCluster
{
Expand Down Expand Up @@ -83,6 +80,7 @@ protected void decommissionNode ( String node) throws IOException, InterruptedEx
composeContainer.getContainerByServiceName(node).get()
.execInContainer("nodetool", "-u", "cassandra", "-pw", "cassandra", "decommission").getStdout();
}

protected void startContainer ( String node)
{
DockerClient dockerClient = DockerClientFactory.instance().client();
Expand All @@ -105,12 +103,14 @@ protected void stopContainer ( String node)
stopCmd.exec();
}
}

protected static int getNodeCountViaNodetool( String node) throws IOException, InterruptedException
{
String stdout = composeContainer.getContainerByServiceName(node).get()
.execInContainer("nodetool", "-u", "cassandra", "-pw", "cassandra", "status").getStdout();
return stdout.split("UN",-1).length-1;
}

protected static boolean waitForNodesToBeUp( String node, int expectedNodes, long maxWaitTimeInMillis)
{
long startTime = System.currentTimeMillis();
Expand Down Expand Up @@ -139,6 +139,7 @@ protected static boolean waitForNodesToBeUp( String node, int expectedNodes, lon
LOG.info("Timed out waiting for the Cassandra cluster to finish starting up.");
return false;
}

protected void loadEcchronosKeyspace () throws InterruptedException
{
Path cqlfile = Paths.get("")
Expand All @@ -161,10 +162,6 @@ protected void loadEcchronosKeyspace () throws InterruptedException
{
System.err.println("Error reading the file: " + e.getMessage());
}


}


}

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public static void setup() throws InterruptedException

}
@Test
public void testAdditionalNodesAddedToCluster() throws InterruptedException, IOException {
public void testAdditionalNodesAddedToCluster() throws InterruptedException, IOException
{
DefaultRepairConfigurationProvider listener = mock(DefaultRepairConfigurationProvider.class);
containerIP = composeContainer.getContainerByServiceName("cassandra-seed-dc1-rack1-node1").get()
.getContainerInfo()
Expand All @@ -75,8 +76,7 @@ public void testAdditionalNodesAddedToCluster() throws InterruptedException, IOE
composeContainer.start();
LOG.info("Waiting for the new nodes to finish starting up.");
waitForNodesToBeUp("cassandra-seed-dc1-rack1-node1",4,50000);



assertEquals( 4, getNodeCountViaNodetool("cassandra-node-dc1-rack1-node2"));

verify(listener, times(3)).onAdd(any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
import java.io.IOException;
import java.net.InetSocketAddress;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.any;

public class ITNodeRemoval extends AbstractCassandraCluster
{
private static final Logger LOG = LoggerFactory.getLogger(ITNodeRemoval.class);

@Test
public void testNodeDecommissionedFromCluster() throws InterruptedException, IOException, ConfigurationException, EcChronosException
{
Expand All @@ -52,7 +56,8 @@ public void testNodeDecommissionedFromCluster() throws InterruptedException, IOE
{
decommissionNode("cassandra-seed-dc1-rack1-node1");
}
catch (IOException e) {
catch (IOException e)
{
throw new RuntimeException(e);
}
LOG.info("Waiting for node to be decommissioned.");
Expand Down

0 comments on commit 51f0c98

Please sign in to comment.