nixos/tests/cassandra: Test jmxPort
The test sets it to a non-standard port so it won't work accidentally now and we'll be sure that our NixOS option works.
This commit is contained in:
parent
706518f761
commit
8fbf9559df
|
@ -8,11 +8,12 @@ let
|
||||||
jmxRoles = [{ username = "me"; password = "password"; }];
|
jmxRoles = [{ username = "me"; password = "password"; }];
|
||||||
jmxRolesFile = ./cassandra-jmx-roles;
|
jmxRolesFile = ./cassandra-jmx-roles;
|
||||||
jmxAuthArgs = "-u ${(builtins.elemAt jmxRoles 0).username} -pw ${(builtins.elemAt jmxRoles 0).password}";
|
jmxAuthArgs = "-u ${(builtins.elemAt jmxRoles 0).username} -pw ${(builtins.elemAt jmxRoles 0).password}";
|
||||||
|
jmxPort = 7200; # Non-standard port so it doesn't accidentally work
|
||||||
|
|
||||||
# Would usually be assigned to 512M
|
# Would usually be assigned to 512M
|
||||||
numMaxHeapSize = "400";
|
numMaxHeapSize = "400";
|
||||||
getHeapLimitCommand = ''
|
getHeapLimitCommand = ''
|
||||||
nodetool info | grep "^Heap Memory" | awk \'{print $NF}\'
|
nodetool info -p ${toString jmxPort} | grep "^Heap Memory" | awk \'{print $NF}\'
|
||||||
'';
|
'';
|
||||||
checkHeapLimitCommand = ''
|
checkHeapLimitCommand = ''
|
||||||
[ 1 -eq "$(echo "$(${getHeapLimitCommand}) < ${numMaxHeapSize}" | ${pkgs.bc}/bin/bc)" ]
|
[ 1 -eq "$(echo "$(${getHeapLimitCommand}) < ${numMaxHeapSize}" | ${pkgs.bc}/bin/bc)" ]
|
||||||
|
@ -27,19 +28,20 @@ let
|
||||||
package = testPackage;
|
package = testPackage;
|
||||||
maxHeapSize = "${numMaxHeapSize}M";
|
maxHeapSize = "${numMaxHeapSize}M";
|
||||||
heapNewSize = "100M";
|
heapNewSize = "100M";
|
||||||
|
inherit jmxPort;
|
||||||
};
|
};
|
||||||
nodeCfg = ipAddress: extra: {pkgs, config, ...}:
|
nodeCfg = ipAddress: extra: {pkgs, config, ...}: rec {
|
||||||
{ environment.systemPackages = [ testPackage ];
|
environment.systemPackages = [ testPackage ];
|
||||||
networking = {
|
networking = {
|
||||||
firewall.allowedTCPPorts = [ 7000 7199 9042 ];
|
firewall.allowedTCPPorts = [ 7000 9042 services.cassandra.jmxPort ];
|
||||||
useDHCP = false;
|
useDHCP = false;
|
||||||
interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
|
interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
|
||||||
{ address = ipAddress; prefixLength = 24; }
|
{ address = ipAddress; prefixLength = 24; }
|
||||||
];
|
];
|
||||||
};
|
|
||||||
services.cassandra = cassandraCfg ipAddress // extra;
|
|
||||||
virtualisation.memorySize = 1024;
|
|
||||||
};
|
};
|
||||||
|
services.cassandra = cassandraCfg ipAddress // extra;
|
||||||
|
virtualisation.memorySize = 1024;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = "cassandra-ci";
|
name = "cassandra-ci";
|
||||||
|
@ -50,7 +52,9 @@ in
|
||||||
cass2 = nodeCfg "192.168.1.3" { jvmOpts = [ "-Dcassandra.replace_address=cass1" ]; };
|
cass2 = nodeCfg "192.168.1.3" { jvmOpts = [ "-Dcassandra.replace_address=cass1" ]; };
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = let
|
||||||
|
jmxPortS = toString jmxPort;
|
||||||
|
in ''
|
||||||
# Check configuration
|
# Check configuration
|
||||||
subtest "Timers exist", sub {
|
subtest "Timers exist", sub {
|
||||||
$cass0->succeed("systemctl list-timers | grep cassandra-full-repair.timer");
|
$cass0->succeed("systemctl list-timers | grep cassandra-full-repair.timer");
|
||||||
|
@ -63,51 +67,51 @@ in
|
||||||
};
|
};
|
||||||
subtest "Nodetool is operational", sub {
|
subtest "Nodetool is operational", sub {
|
||||||
$cass0->waitForUnit("cassandra.service");
|
$cass0->waitForUnit("cassandra.service");
|
||||||
$cass0->waitUntilSucceeds("nc -z localhost 7199");
|
$cass0->waitUntilSucceeds("nc -z localhost ${jmxPortS}");
|
||||||
$cass0->succeed("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass0'");
|
$cass0->succeed("nodetool status -p ${jmxPortS} --resolve-ip | egrep '^UN[[:space:]]+cass0'");
|
||||||
};
|
};
|
||||||
subtest "Cluster name was set", sub {
|
subtest "Cluster name was set", sub {
|
||||||
$cass0->waitForUnit("cassandra.service");
|
$cass0->waitForUnit("cassandra.service");
|
||||||
$cass0->waitUntilSucceeds("nc -z localhost 7199");
|
$cass0->waitUntilSucceeds("nc -z localhost ${jmxPortS}");
|
||||||
$cass0->waitUntilSucceeds("nodetool describecluster | grep 'Name: ${clusterName}'");
|
$cass0->waitUntilSucceeds("nodetool describecluster -p ${jmxPortS} | grep 'Name: ${clusterName}'");
|
||||||
};
|
};
|
||||||
subtest "Heap limit set correctly", sub {
|
subtest "Heap limit set correctly", sub {
|
||||||
# Nodetool takes a while until it can display info
|
# Nodetool takes a while until it can display info
|
||||||
$cass0->waitUntilSucceeds('nodetool info');
|
$cass0->waitUntilSucceeds('nodetool info -p ${jmxPortS}');
|
||||||
$cass0->succeed('${checkHeapLimitCommand}');
|
$cass0->succeed('${checkHeapLimitCommand}');
|
||||||
};
|
};
|
||||||
|
|
||||||
# Check cluster interaction
|
# Check cluster interaction
|
||||||
subtest "Bring up cluster", sub {
|
subtest "Bring up cluster", sub {
|
||||||
$cass1->waitForUnit("cassandra.service");
|
$cass1->waitForUnit("cassandra.service");
|
||||||
$cass1->waitUntilSucceeds("nodetool ${jmxAuthArgs} status | egrep -c '^UN' | grep 2");
|
$cass1->waitUntilSucceeds("nodetool -p ${jmxPortS} ${jmxAuthArgs} status | egrep -c '^UN' | grep 2");
|
||||||
$cass0->succeed("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass1'");
|
$cass0->succeed("nodetool status -p ${jmxPortS} --resolve-ip | egrep '^UN[[:space:]]+cass1'");
|
||||||
};
|
};
|
||||||
'' + lib.optionalString testRemoteAuth ''
|
'' + lib.optionalString testRemoteAuth ''
|
||||||
subtest "Remote authenticated jmx", sub {
|
subtest "Remote authenticated jmx", sub {
|
||||||
# Doesn't work if not enabled
|
# Doesn't work if not enabled
|
||||||
$cass0->waitUntilSucceeds("nc -z localhost 7199");
|
$cass0->waitUntilSucceeds("nc -z localhost ${jmxPortS}");
|
||||||
$cass1->fail("nc -z 192.168.1.1 7199");
|
$cass1->fail("nc -z 192.168.1.1 ${toString jmxPort}");
|
||||||
$cass1->fail("nodetool -h 192.168.1.1 status");
|
$cass1->fail("nodetool -p ${jmxPortS} -h 192.168.1.1 status");
|
||||||
|
|
||||||
# Works if enabled
|
# Works if enabled
|
||||||
$cass1->waitUntilSucceeds("nc -z localhost 7199");
|
$cass1->waitUntilSucceeds("nc -z localhost ${toString jmxPort}");
|
||||||
$cass0->succeed("nodetool -h 192.168.1.2 ${jmxAuthArgs} status");
|
$cass0->succeed("nodetool -p ${jmxPortS} -h 192.168.1.2 ${jmxAuthArgs} status");
|
||||||
};
|
};
|
||||||
'' + ''
|
'' + ''
|
||||||
subtest "Break and fix node", sub {
|
subtest "Break and fix node", sub {
|
||||||
$cass1->block;
|
$cass1->block;
|
||||||
$cass0->waitUntilSucceeds("nodetool status --resolve-ip | egrep -c '^DN[[:space:]]+cass1'");
|
$cass0->waitUntilSucceeds("nodetool status -p ${jmxPortS} --resolve-ip | egrep -c '^DN[[:space:]]+cass1'");
|
||||||
$cass0->succeed("nodetool status | egrep -c '^UN' | grep 1");
|
$cass0->succeed("nodetool status -p ${jmxPortS} | egrep -c '^UN' | grep 1");
|
||||||
$cass1->unblock;
|
$cass1->unblock;
|
||||||
$cass1->waitUntilSucceeds("nodetool ${jmxAuthArgs} status | egrep -c '^UN' | grep 2");
|
$cass1->waitUntilSucceeds("nodetool -p ${jmxPortS} ${jmxAuthArgs} status | egrep -c '^UN' | grep 2");
|
||||||
$cass0->succeed("nodetool status | egrep -c '^UN' | grep 2");
|
$cass0->succeed("nodetool status -p ${jmxPortS} | egrep -c '^UN' | grep 2");
|
||||||
};
|
};
|
||||||
subtest "Replace crashed node", sub {
|
subtest "Replace crashed node", sub {
|
||||||
$cass1->crash;
|
$cass1->crash;
|
||||||
$cass2->waitForUnit("cassandra.service");
|
$cass2->waitForUnit("cassandra.service");
|
||||||
$cass0->waitUntilFails("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass1'");
|
$cass0->waitUntilFails("nodetool status -p ${jmxPortS} --resolve-ip | egrep '^UN[[:space:]]+cass1'");
|
||||||
$cass0->waitUntilSucceeds("nodetool status --resolve-ip | egrep '^UN[[:space:]]+cass2'");
|
$cass0->waitUntilSucceeds("nodetool status -p ${jmxPortS} --resolve-ip | egrep '^UN[[:space:]]+cass2'");
|
||||||
};
|
};
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue