2016-07-22 19:29:35 +02:00
|
|
|
import ./make-test.nix ({ pkgs, ...}:
|
|
|
|
let
|
2017-11-07 14:11:56 +01:00
|
|
|
# Change this to test a different version of Cassandra:
|
|
|
|
testPackage = pkgs.cassandra;
|
2019-04-23 04:59:53 +02:00
|
|
|
|
|
|
|
cassandraCfg = ipAddress:
|
2017-11-07 14:11:56 +01:00
|
|
|
{ enable = true;
|
2019-04-23 04:59:53 +02:00
|
|
|
listenAddress = ipAddress;
|
|
|
|
rpcAddress = ipAddress;
|
2017-11-07 14:11:56 +01:00
|
|
|
extraConfig =
|
|
|
|
{ start_native_transport = true;
|
|
|
|
seed_provider =
|
|
|
|
[{ class_name = "org.apache.cassandra.locator.SimpleSeedProvider";
|
2019-04-09 04:02:49 +02:00
|
|
|
parameters = [ { seeds = "192.168.1.1"; } ];
|
2017-11-07 14:11:56 +01:00
|
|
|
}];
|
|
|
|
};
|
|
|
|
package = testPackage;
|
|
|
|
};
|
2019-04-23 04:59:53 +02:00
|
|
|
nodeCfg = ipAddress: extra: {pkgs, config, ...}:
|
2017-11-07 14:11:56 +01:00
|
|
|
{ environment.systemPackages = [ testPackage ];
|
|
|
|
networking.firewall.enable = false;
|
2019-04-23 04:59:53 +02:00
|
|
|
services.cassandra = cassandraCfg ipAddress // extra;
|
2016-07-22 19:29:35 +02:00
|
|
|
virtualisation.memorySize = 1024;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
name = "cassandra-ci";
|
|
|
|
|
|
|
|
nodes = {
|
2019-04-09 04:02:49 +02:00
|
|
|
cass0 = nodeCfg "192.168.1.1" {};
|
|
|
|
cass1 = nodeCfg "192.168.1.2" {};
|
|
|
|
cass2 = nodeCfg "192.168.1.3" { jvmOpts = [ "-Dcassandra.replace_address=cass1" ]; };
|
2016-07-22 19:29:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-04-23 04:59:53 +02:00
|
|
|
# Check configuration
|
|
|
|
subtest "Timers exist", sub {
|
2017-11-07 14:11:56 +01:00
|
|
|
$cass0->succeed("systemctl list-timers | grep cassandra-full-repair.timer");
|
|
|
|
$cass0->succeed("systemctl list-timers | grep cassandra-incremental-repair.timer");
|
|
|
|
};
|
2019-04-23 04:59:53 +02:00
|
|
|
subtest "Can connect via cqlsh", sub {
|
2016-07-22 19:29:35 +02:00
|
|
|
$cass0->waitForUnit("cassandra.service");
|
2017-11-07 14:11:56 +01:00
|
|
|
$cass0->waitUntilSucceeds("nc -z cass0 9042");
|
|
|
|
$cass0->succeed("echo 'show version;' | cqlsh cass0");
|
2016-07-22 19:29:35 +02:00
|
|
|
};
|
2019-04-23 04:59:53 +02:00
|
|
|
subtest "Nodetool is operational", sub {
|
2017-11-07 14:11:56 +01:00
|
|
|
$cass0->waitForUnit("cassandra.service");
|
|
|
|
$cass0->waitUntilSucceeds("nc -z localhost 7199");
|
|
|
|
$cass0->succeed("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass0'");
|
2016-07-22 19:29:35 +02:00
|
|
|
};
|
2019-04-23 04:59:53 +02:00
|
|
|
|
|
|
|
# Check cluster interaction
|
|
|
|
subtest "Bring up cluster", sub {
|
2016-07-22 19:29:35 +02:00
|
|
|
$cass1->waitForUnit("cassandra.service");
|
2017-11-07 14:11:56 +01:00
|
|
|
$cass1->waitUntilSucceeds("nodetool status | egrep -c '^UN' | grep 2");
|
|
|
|
$cass0->succeed("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass1'");
|
2016-07-22 19:29:35 +02:00
|
|
|
};
|
2019-04-23 04:59:53 +02:00
|
|
|
subtest "Break and fix node", sub {
|
2017-11-07 14:11:56 +01:00
|
|
|
$cass1->block;
|
|
|
|
$cass0->waitUntilSucceeds("nodetool status --resolve-ip | egrep -c '^DN[[:space:]]+cass1'");
|
|
|
|
$cass0->succeed("nodetool status | egrep -c '^UN' | grep 1");
|
|
|
|
$cass1->unblock;
|
|
|
|
$cass1->waitUntilSucceeds("nodetool status | egrep -c '^UN' | grep 2");
|
|
|
|
$cass0->succeed("nodetool status | egrep -c '^UN' | grep 2");
|
2016-07-22 19:29:35 +02:00
|
|
|
};
|
2019-04-23 04:59:53 +02:00
|
|
|
subtest "Replace crashed node", sub {
|
2016-07-22 19:29:35 +02:00
|
|
|
$cass1->crash;
|
|
|
|
$cass2->waitForUnit("cassandra.service");
|
2017-11-07 14:11:56 +01:00
|
|
|
$cass0->waitUntilFails("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass1'");
|
|
|
|
$cass0->waitUntilSucceeds("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass2'");
|
2016-07-22 19:29:35 +02:00
|
|
|
};
|
|
|
|
'';
|
|
|
|
})
|