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 18, 2024
1 parent a1f9973 commit 07f0fb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
5 changes: 0 additions & 5 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@
<version>1.64</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>cassandra</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class AbstractCassandraCluster
private static final Logger LOG = LoggerFactory.getLogger(AbstractCassandraCluster.class);
protected static String containerIP;
protected static CqlSession mySession;
private static final long TENSECONDS = 10000;

@BeforeClass
public static void setup() throws InterruptedException
Expand Down Expand Up @@ -82,12 +83,6 @@ protected void decommissionNode ( String node) throws IOException, InterruptedEx
composeContainer.getContainerByServiceName(node).get()
.execInContainer("nodetool", "-u", "cassandra", "-pw", "cassandra", "decommission").getStdout();
}
protected void setupEcchronosKeyspace ( String node) throws IOException, InterruptedException
{
composeContainer.getContainerByServiceName(node).get()
.execInContainer("nodetool", "-u", "cassandra", "-pw", "cassandra", "decommission").getStdout();
}

protected void startContainer ( String node)
{
DockerClient dockerClient = DockerClientFactory.instance().client();
Expand Down Expand Up @@ -115,52 +110,55 @@ protected static int getNodeCountViaNodetool( String node) throws IOException, I
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();
LOG.info("Waiting 10sec");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
try
{
Thread.sleep(TENSECONDS);
} catch (InterruptedException e)
{
// ignore and retry
}
while ( startTime + maxWaitTimeInMillis > System.currentTimeMillis())
{
try
{
if (getNodeCountViaNodetool(node) == expectedNodes)
{
return true;
}
}
catch (IOException e)
{
// ignore and retry
}
catch (InterruptedException e)
catch (IOException | InterruptedException e)
{
// ignore and retry
}
}
LOG.info("Timed out waiting for the Cassandra cluster to finish starting up.");
return false;
}
protected void loadEcchronosKeyspace () throws InterruptedException {
protected void loadEcchronosKeyspace () throws InterruptedException
{
Path cqlfile = Paths.get("")
.toAbsolutePath()
.getParent()
.resolve("cassandra-test-image/src/main/docker/create_keyspaces.cql");

try (BufferedReader reader = new BufferedReader(new FileReader(cqlfile.toFile()))) {
try (BufferedReader reader = new BufferedReader(new FileReader(cqlfile.toFile())))
{
String line;
while ((line = reader.readLine()) != null) {
while ((line = reader.readLine()) != null)
{

System.out.println(line);
mySession.execute(line);
Thread.sleep(500);
}
} catch (IOException e) {
}
catch (IOException e)
{
System.err.println("Error reading the file: " + e.getMessage());
}

Expand Down

0 comments on commit 07f0fb2

Please sign in to comment.