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 7, 2024
1 parent 0a41a50 commit e055692
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public static void setup() throws InterruptedException
.withLocalDatacenter("datacenter1")
.withAuthCredentials("cassandra", "cassandra");
mySession = builder.build();


}

@AfterClass
Expand All @@ -74,10 +72,12 @@ public static void tearDownCluster()
composeContainer.stop();
}

protected void decommissionNode ( String node) throws IOException, InterruptedException {
protected void decommissionNode ( String node) throws IOException, InterruptedException
{
String stdout = composeContainer.getContainerByServiceName(node).get()
.execInContainer("nodetool", "-u", "cassandra", "-pw", "cassandra", "decommission").getStdout();
}

protected void startContainer ( String node)
{
DockerClient dockerClient = DockerClientFactory.instance().client();
Expand All @@ -89,6 +89,7 @@ protected void startContainer ( String node)
startCmd3.exec();
}
}

protected void stopContainer ( String node)
{
DockerClient dockerClient = DockerClientFactory.instance().client();
Expand All @@ -98,8 +99,6 @@ protected void stopContainer ( String node)
{
stopCmd.exec();
}

}

}

Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public static void setup() throws InterruptedException {
Thread.sleep(50000);
}
@Test
public void testCassandraCluster() throws InterruptedException {

public void testAdditionalNodesAddedToCluster() throws InterruptedException
{
DefaultRepairConfigurationProvider listener = mock(DefaultRepairConfigurationProvider.class);
containerIP = composeContainer.getContainerByServiceName("cassandra-seed-dc1-rack1-node1").get()
.getContainerInfo()
Expand All @@ -64,6 +64,7 @@ public void testCassandraCluster() throws InterruptedException {
.withNodeStateListener(listener);
mySession = builder.build();

// scale up new nodes
composeContainer.withScaledService("cassandra-node-dc1-rack1-node2", 1 );
composeContainer.withScaledService("cassandra-node-dc2-rack1-node2", 1 );
composeContainer.withScaledService("cassandra-seed-dc2-rack1-node1", 1 );
Expand All @@ -73,9 +74,5 @@ public void testCassandraCluster() throws InterruptedException {

verify(listener, times(3)).onAdd(any());
verify(listener, times(0)).onRemove(any());




}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
import com.ericsson.bss.cassandra.ecchronos.core.impl.repair.DefaultRepairConfigurationProvider;
import com.github.dockerjava.api.DockerClient;
import org.junit.Test;
import org.testcontainers.DockerClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.InetSocketAddress;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

public class TestNodeRemoval extends AbstractCassandraCluster
{

private static final Logger LOG = LoggerFactory.getLogger(TestNodeRemoval.class);
@Test
public void testCassandraCluster() throws InterruptedException {

public void testNodeDecommissionedFromCluster() throws InterruptedException
{
DefaultRepairConfigurationProvider listener = mock(DefaultRepairConfigurationProvider.class);
containerIP = composeContainer.getContainerByServiceName("cassandra-seed-dc1-rack1-node1").get()
.getContainerInfo()
Expand All @@ -46,23 +45,16 @@ public void testCassandraCluster() throws InterruptedException {
.withNodeStateListener(listener);
mySession = builder.build();

try {
try
{
decommissionNode("cassandra-seed-dc1-rack1-node1");
} catch (IOException e) {
}
catch (IOException e) {
throw new RuntimeException(e);

}
LOG.info("Waiting for node to be decommissioned.");
Thread.sleep(50000);


verify(listener, times(1)).onRemove(any());

}
@Test
public void testNodetool() throws IOException, InterruptedException
{ String stdout = composeContainer.getContainerByServiceName("cassandra-seed-dc1-rack1-node1").get()
.execInContainer("nodetool", "-u", "cassandra", "-pw", "cassandra", "status").getStdout();
System.out.println(stdout);
assertTrue(stdout.contains("UN"));}

}

0 comments on commit e055692

Please sign in to comment.