nixosTests.cassandra_4: handleTest -> runTest
This commit is contained in:
parent
2e4fac6dfd
commit
f4a714d8d5
@ -290,7 +290,10 @@ in
|
|||||||
calibre-server = import ./calibre-server.nix { inherit pkgs runTest; };
|
calibre-server = import ./calibre-server.nix { inherit pkgs runTest; };
|
||||||
canaille = runTest ./canaille.nix;
|
canaille = runTest ./canaille.nix;
|
||||||
castopod = runTest ./castopod.nix;
|
castopod = runTest ./castopod.nix;
|
||||||
cassandra_4 = handleTest ./cassandra.nix { testPackage = pkgs.cassandra_4; };
|
cassandra = runTest {
|
||||||
|
imports = [ ./cassandra.nix ];
|
||||||
|
_module.args.getPackage = pkgs: pkgs.cassandra;
|
||||||
|
};
|
||||||
centrifugo = runTest ./centrifugo.nix;
|
centrifugo = runTest ./centrifugo.nix;
|
||||||
ceph-multi-node = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./ceph-multi-node.nix { };
|
ceph-multi-node = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./ceph-multi-node.nix { };
|
||||||
ceph-single-node = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./ceph-single-node.nix { };
|
ceph-single-node = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./ceph-single-node.nix { };
|
||||||
|
|||||||
@ -1,162 +1,160 @@
|
|||||||
import ./make-test-python.nix (
|
{
|
||||||
{
|
pkgs,
|
||||||
pkgs,
|
lib,
|
||||||
lib,
|
getPackage ? pkgs: pkgs.cassandra_4,
|
||||||
testPackage ? pkgs.cassandra,
|
...
|
||||||
...
|
}:
|
||||||
}:
|
let
|
||||||
let
|
testPackage = getPackage pkgs;
|
||||||
clusterName = "NixOS Automated-Test Cluster";
|
clusterName = "NixOS Automated-Test Cluster";
|
||||||
|
testRemoteAuth = lib.versionAtLeast testPackage.version "3.11";
|
||||||
|
jmxRoles = [
|
||||||
|
{
|
||||||
|
username = "me";
|
||||||
|
password = "password";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
jmxRolesFile = ./cassandra-jmx-roles;
|
||||||
|
jmxAuthArgs = "-u ${(builtins.elemAt jmxRoles 0).username} -pw ${(builtins.elemAt jmxRoles 0).password}";
|
||||||
|
jmxPort = 7200; # Non-standard port so it doesn't accidentally work
|
||||||
|
jmxPortStr = toString jmxPort;
|
||||||
|
|
||||||
testRemoteAuth = lib.versionAtLeast testPackage.version "3.11";
|
# Would usually be assigned to 512M.
|
||||||
jmxRoles = [
|
# Set it to a different value, so that we can check whether our config
|
||||||
{
|
# actually changes it.
|
||||||
username = "me";
|
numMaxHeapSize = "400";
|
||||||
password = "password";
|
getHeapLimitCommand = ''
|
||||||
}
|
nodetool info -p ${jmxPortStr} | grep "^Heap Memory" | awk '{print $NF}'
|
||||||
];
|
'';
|
||||||
jmxRolesFile = ./cassandra-jmx-roles;
|
checkHeapLimitCommand = pkgs.writeShellScript "check-heap-limit.sh" ''
|
||||||
jmxAuthArgs = "-u ${(builtins.elemAt jmxRoles 0).username} -pw ${(builtins.elemAt jmxRoles 0).password}";
|
[ 1 -eq "$(echo "$(${getHeapLimitCommand}) < ${numMaxHeapSize}" | ${pkgs.bc}/bin/bc)" ]
|
||||||
jmxPort = 7200; # Non-standard port so it doesn't accidentally work
|
'';
|
||||||
jmxPortStr = toString jmxPort;
|
|
||||||
|
|
||||||
# Would usually be assigned to 512M.
|
cassandraCfg = pkgs: ipAddress: {
|
||||||
# Set it to a different value, so that we can check whether our config
|
enable = true;
|
||||||
# actually changes it.
|
inherit clusterName;
|
||||||
numMaxHeapSize = "400";
|
listenAddress = ipAddress;
|
||||||
getHeapLimitCommand = ''
|
rpcAddress = ipAddress;
|
||||||
nodetool info -p ${jmxPortStr} | grep "^Heap Memory" | awk '{print $NF}'
|
seedAddresses = [ "192.168.1.1" ];
|
||||||
'';
|
package = getPackage pkgs;
|
||||||
checkHeapLimitCommand = pkgs.writeShellScript "check-heap-limit.sh" ''
|
maxHeapSize = "${numMaxHeapSize}M";
|
||||||
[ 1 -eq "$(echo "$(${getHeapLimitCommand}) < ${numMaxHeapSize}" | ${pkgs.bc}/bin/bc)" ]
|
heapNewSize = "100M";
|
||||||
'';
|
inherit jmxPort;
|
||||||
|
};
|
||||||
cassandraCfg = ipAddress: {
|
nodeCfg =
|
||||||
enable = true;
|
ipAddress: extra:
|
||||||
inherit clusterName;
|
{ pkgs, config, ... }:
|
||||||
listenAddress = ipAddress;
|
rec {
|
||||||
rpcAddress = ipAddress;
|
environment.systemPackages = [ (getPackage pkgs) ];
|
||||||
seedAddresses = [ "192.168.1.1" ];
|
networking = {
|
||||||
package = testPackage;
|
firewall.allowedTCPPorts = [
|
||||||
maxHeapSize = "${numMaxHeapSize}M";
|
7000
|
||||||
heapNewSize = "100M";
|
9042
|
||||||
inherit jmxPort;
|
services.cassandra.jmxPort
|
||||||
};
|
];
|
||||||
nodeCfg =
|
useDHCP = false;
|
||||||
ipAddress: extra:
|
interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
|
||||||
{ pkgs, config, ... }:
|
{
|
||||||
rec {
|
address = ipAddress;
|
||||||
environment.systemPackages = [ testPackage ];
|
prefixLength = 24;
|
||||||
networking = {
|
}
|
||||||
firewall.allowedTCPPorts = [
|
];
|
||||||
7000
|
|
||||||
9042
|
|
||||||
services.cassandra.jmxPort
|
|
||||||
];
|
|
||||||
useDHCP = false;
|
|
||||||
interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
|
|
||||||
{
|
|
||||||
address = ipAddress;
|
|
||||||
prefixLength = 24;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
services.cassandra = cassandraCfg ipAddress // extra;
|
|
||||||
};
|
};
|
||||||
in
|
services.cassandra = cassandraCfg pkgs ipAddress // extra;
|
||||||
{
|
|
||||||
name = "cassandra-${testPackage.version}";
|
|
||||||
meta = {
|
|
||||||
maintainers = with lib.maintainers; [ johnazoidberg ];
|
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
name = "cassandra-${testPackage.version}";
|
||||||
|
meta = {
|
||||||
|
maintainers = with lib.maintainers; [ johnazoidberg ];
|
||||||
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
cass0 = nodeCfg "192.168.1.1" { };
|
cass0 = nodeCfg "192.168.1.1" { };
|
||||||
cass1 = nodeCfg "192.168.1.2" (
|
cass1 = nodeCfg "192.168.1.2" (
|
||||||
lib.optionalAttrs testRemoteAuth {
|
lib.optionalAttrs testRemoteAuth {
|
||||||
inherit jmxRoles;
|
inherit jmxRoles;
|
||||||
remoteJmx = true;
|
remoteJmx = true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cass2 = nodeCfg "192.168.1.3" { jvmOpts = [ "-Dcassandra.replace_address=cass1" ]; };
|
cass2 = nodeCfg "192.168.1.3" { jvmOpts = [ "-Dcassandra.replace_address=cass1" ]; };
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript =
|
||||||
''
|
''
|
||||||
# Check configuration
|
# Check configuration
|
||||||
with subtest("Timers exist"):
|
with subtest("Timers exist"):
|
||||||
cass0.succeed("systemctl list-timers | grep cassandra-full-repair.timer")
|
cass0.succeed("systemctl list-timers | grep cassandra-full-repair.timer")
|
||||||
cass0.succeed("systemctl list-timers | grep cassandra-incremental-repair.timer")
|
cass0.succeed("systemctl list-timers | grep cassandra-incremental-repair.timer")
|
||||||
|
|
||||||
with subtest("Can connect via cqlsh"):
|
with subtest("Can connect via cqlsh"):
|
||||||
cass0.wait_for_unit("cassandra.service")
|
cass0.wait_for_unit("cassandra.service")
|
||||||
cass0.wait_until_succeeds("nc -z cass0 9042")
|
cass0.wait_until_succeeds("nc -z cass0 9042")
|
||||||
cass0.succeed("echo 'show version;' | cqlsh cass0")
|
cass0.succeed("echo 'show version;' | cqlsh cass0")
|
||||||
|
|
||||||
with subtest("Nodetool is operational"):
|
with subtest("Nodetool is operational"):
|
||||||
cass0.wait_for_unit("cassandra.service")
|
cass0.wait_for_unit("cassandra.service")
|
||||||
cass0.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
cass0.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
||||||
cass0.succeed("nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass0'")
|
cass0.succeed("nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass0'")
|
||||||
|
|
||||||
with subtest("Cluster name was set"):
|
with subtest("Cluster name was set"):
|
||||||
cass0.wait_for_unit("cassandra.service")
|
cass0.wait_for_unit("cassandra.service")
|
||||||
cass0.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
cass0.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
||||||
cass0.wait_until_succeeds(
|
cass0.wait_until_succeeds(
|
||||||
"nodetool describecluster -p ${jmxPortStr} | grep 'Name: ${clusterName}'"
|
"nodetool describecluster -p ${jmxPortStr} | grep 'Name: ${clusterName}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
with subtest("Heap limit set correctly"):
|
with subtest("Heap limit set correctly"):
|
||||||
# Nodetool takes a while until it can display info
|
# Nodetool takes a while until it can display info
|
||||||
cass0.wait_until_succeeds("nodetool info -p ${jmxPortStr}")
|
cass0.wait_until_succeeds("nodetool info -p ${jmxPortStr}")
|
||||||
cass0.succeed("${checkHeapLimitCommand}")
|
cass0.succeed("${checkHeapLimitCommand}")
|
||||||
|
|
||||||
# Check cluster interaction
|
# Check cluster interaction
|
||||||
with subtest("Bring up cluster"):
|
with subtest("Bring up cluster"):
|
||||||
cass1.wait_for_unit("cassandra.service")
|
cass1.wait_for_unit("cassandra.service")
|
||||||
cass1.wait_until_succeeds(
|
cass1.wait_until_succeeds(
|
||||||
"nodetool -p ${jmxPortStr} ${jmxAuthArgs} status | egrep -c '^UN' | grep 2"
|
"nodetool -p ${jmxPortStr} ${jmxAuthArgs} status | egrep -c '^UN' | grep 2"
|
||||||
)
|
)
|
||||||
cass0.succeed("nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass1'")
|
cass0.succeed("nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass1'")
|
||||||
''
|
''
|
||||||
+ lib.optionalString testRemoteAuth ''
|
+ lib.optionalString testRemoteAuth ''
|
||||||
with subtest("Remote authenticated jmx"):
|
with subtest("Remote authenticated jmx"):
|
||||||
# Doesn't work if not enabled
|
# Doesn't work if not enabled
|
||||||
cass0.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
cass0.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
||||||
cass1.fail("nc -z 192.168.1.1 ${jmxPortStr}")
|
cass1.fail("nc -z 192.168.1.1 ${jmxPortStr}")
|
||||||
cass1.fail("nodetool -p ${jmxPortStr} -h 192.168.1.1 status")
|
cass1.fail("nodetool -p ${jmxPortStr} -h 192.168.1.1 status")
|
||||||
|
|
||||||
# Works if enabled
|
# Works if enabled
|
||||||
cass1.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
cass1.wait_until_succeeds("nc -z localhost ${jmxPortStr}")
|
||||||
cass0.succeed("nodetool -p ${jmxPortStr} -h 192.168.1.2 ${jmxAuthArgs} status")
|
cass0.succeed("nodetool -p ${jmxPortStr} -h 192.168.1.2 ${jmxAuthArgs} status")
|
||||||
''
|
''
|
||||||
+ ''
|
+ ''
|
||||||
with subtest("Break and fix node"):
|
with subtest("Break and fix node"):
|
||||||
cass1.block()
|
cass1.block()
|
||||||
cass0.wait_until_succeeds(
|
cass0.wait_until_succeeds(
|
||||||
"nodetool status -p ${jmxPortStr} --resolve-ip | egrep -c '^DN[[:space:]]+cass1'"
|
"nodetool status -p ${jmxPortStr} --resolve-ip | egrep -c '^DN[[:space:]]+cass1'"
|
||||||
)
|
)
|
||||||
cass0.succeed("nodetool status -p ${jmxPortStr} | egrep -c '^UN' | grep 1")
|
cass0.succeed("nodetool status -p ${jmxPortStr} | egrep -c '^UN' | grep 1")
|
||||||
cass1.unblock()
|
cass1.unblock()
|
||||||
cass1.wait_until_succeeds(
|
cass1.wait_until_succeeds(
|
||||||
"nodetool -p ${jmxPortStr} ${jmxAuthArgs} status | egrep -c '^UN' | grep 2"
|
"nodetool -p ${jmxPortStr} ${jmxAuthArgs} status | egrep -c '^UN' | grep 2"
|
||||||
)
|
)
|
||||||
cass0.succeed("nodetool status -p ${jmxPortStr} | egrep -c '^UN' | grep 2")
|
cass0.succeed("nodetool status -p ${jmxPortStr} | egrep -c '^UN' | grep 2")
|
||||||
|
|
||||||
with subtest("Replace crashed node"):
|
with subtest("Replace crashed node"):
|
||||||
cass1.block() # .crash() waits until it's fully shutdown
|
cass1.block() # .crash() waits until it's fully shutdown
|
||||||
cass2.start()
|
cass2.start()
|
||||||
cass0.wait_until_fails(
|
cass0.wait_until_fails(
|
||||||
"nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass1'"
|
"nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass1'"
|
||||||
)
|
)
|
||||||
|
|
||||||
cass2.wait_for_unit("cassandra.service")
|
cass2.wait_for_unit("cassandra.service")
|
||||||
cass0.wait_until_succeeds(
|
cass0.wait_until_succeeds(
|
||||||
"nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass2'"
|
"nodetool status -p ${jmxPortStr} --resolve-ip | egrep '^UN[[:space:]]+cass2'"
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit testPackage;
|
inherit testPackage;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user