about summary refs log tree commit diff
path: root/nixos/tests/cassandra.nix
diff options
context:
space:
mode:
authorDaniel Schaefer <git@danielschaefer.me>2019-04-23 05:05:06 +0200
committerDaniel Schaefer <git@danielschaefer.me>2019-06-13 04:36:41 +0200
commit3162f45388638d04faac82a5d8c2dcf3076a84bc (patch)
treecd289b36848aae3a1245a6d195b06d20af96f11c /nixos/tests/cassandra.nix
parent2368345052adcf0076628ff7a732cc99c017a2c3 (diff)
nixos/cassandra: Test maxHeapSize
Diffstat (limited to 'nixos/tests/cassandra.nix')
-rw-r--r--nixos/tests/cassandra.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/nixos/tests/cassandra.nix b/nixos/tests/cassandra.nix
index eab757b80a549..a14cec5ab19af 100644
--- a/nixos/tests/cassandra.nix
+++ b/nixos/tests/cassandra.nix
@@ -4,6 +4,14 @@ let
   testPackage = pkgs.cassandra;
   clusterName = "NixOS Automated-Test Cluster";
 
+  numMaxHeapSize = "400";
+  getHeapLimitCommand = ''
+    nodetool info | grep "^Heap Memory" | awk \'{print $NF}\'
+  '';
+  checkHeapLimitCommand = ''
+    [ 1 -eq "$(echo "$(${getHeapLimitCommand}) < ${numMaxHeapSize}" | ${pkgs.bc}/bin/bc)" ]
+  '';
+
   cassandraCfg = ipAddress:
     { enable = true;
       inherit clusterName;
@@ -11,6 +19,8 @@ let
       rpcAddress = ipAddress;
       seedAddresses = [ "192.168.1.1" ];
       package = testPackage;
+      maxHeapSize = "${numMaxHeapSize}M";
+      heapNewSize = "100M";
     };
   nodeCfg = ipAddress: extra: {pkgs, config, ...}:
     { environment.systemPackages = [ testPackage ];
@@ -55,6 +65,11 @@ in
       $cass0->waitUntilSucceeds("nc -z localhost 7199");
       $cass0->waitUntilSucceeds("nodetool describecluster | grep 'Name: ${clusterName}'");
     };
+    subtest "Heap limit set correctly", sub {
+      # Nodetool takes a while until it can display info
+      $cass0->waitUntilSucceeds('nodetool info');
+      $cass0->succeed('${checkHeapLimitCommand}');
+    };
 
     # Check cluster interaction
     subtest "Bring up cluster", sub {