From 8e9e77ee7dc0d612616ebe0f93d67be89b931131 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 22 Nov 2019 21:49:16 +0100 Subject: [PATCH 1/6] nixosTests.cockroachdb: add to all-tests.nix --- nixos/tests/all-tests.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 2bdced6a3cc1..6367f0b158e5 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -51,6 +51,7 @@ in cloud-init = handleTest ./cloud-init.nix {}; codimd = handleTest ./codimd.nix {}; consul = handleTest ./consul.nix {}; + cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {}; containers-bridge = handleTest ./containers-bridge.nix {}; containers-ephemeral = handleTest ./containers-ephemeral.nix {}; containers-extra_veth = handleTest ./containers-extra_veth.nix {}; From e7e05ad9575156e87468dafaf0964253cc628ea2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 22 Nov 2019 21:01:22 +0100 Subject: [PATCH 2/6] nixosTests.cockroachdb: port to python --- nixos/tests/cockroachdb.nix | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/nixos/tests/cockroachdb.nix b/nixos/tests/cockroachdb.nix index 496283fddc7b..33ff7c31b25f 100644 --- a/nixos/tests/cockroachdb.nix +++ b/nixos/tests/cockroachdb.nix @@ -95,7 +95,7 @@ let ''; }; -in import ./make-test.nix ({ pkgs, ...} : { +in import ./make-test-python.nix ({ pkgs, ...} : { name = "cockroachdb"; meta.maintainers = with pkgs.stdenv.lib.maintainers; [ thoughtpolice ]; @@ -110,17 +110,13 @@ in import ./make-test.nix ({ pkgs, ...} : { # there's otherwise no way to guarantee that node1 will start before the others try # to join it. testScript = '' - $node1->start; - $node1->waitForUnit("cockroachdb"); - - $node2->start; - $node2->waitForUnit("cockroachdb"); - - $node3->start; - $node3->waitForUnit("cockroachdb"); - - $node1->mustSucceed("cockroach sql --host=192.168.1.1 --insecure -e 'SHOW ALL CLUSTER SETTINGS' 2>&1"); - $node1->mustSucceed("cockroach workload init bank 'postgresql://root\@192.168.1.1:26257?sslmode=disable'"); - $node1->mustSucceed("cockroach workload run bank --duration=1m 'postgresql://root\@192.168.1.1:26257?sslmode=disable'"); + for node in node1, node2, node3: + node.start() + node.wait_for_unit("cockroachdb") + node1.succeed( + "cockroach sql --host=192.168.1.1 --insecure -e 'SHOW ALL CLUSTER SETTINGS' 2>&1", + "cockroach workload init bank 'postgresql://root@192.168.1.1:26257?sslmode=disable'", + "cockroach workload run bank --duration=1m 'postgresql://root@192.168.1.1:26257?sslmode=disable'", + ) ''; }) From 4009ef44e9a1b0dec6ab1df418ad1f54647e9b63 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 22 Nov 2019 22:28:17 +0100 Subject: [PATCH 3/6] cockroachdb: remove stray trailing whitespace --- nixos/modules/services/databases/cockroachdb.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/databases/cockroachdb.nix b/nixos/modules/services/databases/cockroachdb.nix index b6f94a4881a0..35fb46d69d8e 100644 --- a/nixos/modules/services/databases/cockroachdb.nix +++ b/nixos/modules/services/databases/cockroachdb.nix @@ -153,7 +153,7 @@ in defaultText = "pkgs.cockroachdb"; description = '' The CockroachDB derivation to use for running the service. - + This would primarily be useful to enable Enterprise Edition features in your own custom CockroachDB build (Nixpkgs CockroachDB binaries only contain open source features and open source code). From 98906dfdefe322cb573c7c54b4744ef781bdd2cd Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 22 Nov 2019 22:28:38 +0100 Subject: [PATCH 4/6] nixosTests.cockroachdb: bump memory cockroachdb complained about not enough memory available. --- nixos/tests/cockroachdb.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/tests/cockroachdb.nix b/nixos/tests/cockroachdb.nix index 33ff7c31b25f..a03a223d66a3 100644 --- a/nixos/tests/cockroachdb.nix +++ b/nixos/tests/cockroachdb.nix @@ -1,7 +1,7 @@ # This performs a full 'end-to-end' test of a multi-node CockroachDB cluster # using the built-in 'cockroach workload' command, to simulate a semi-realistic # test load. It generally takes anywhere from 3-5 minutes to run and 1-2GB of -# RAM (though each of 3 workers gets 1GB allocated) +# RAM (though each of 3 workers gets 2GB allocated) # # CockroachDB requires synchronized system clocks within a small error window # (~500ms by default) on each node in order to maintain a multi-node cluster. @@ -55,7 +55,7 @@ let { # Bank/TPC-C benchmarks take some memory to complete - virtualisation.memorySize = 1024; + virtualisation.memorySize = 2048; # Install the KVM PTP "Virtualized Clock" driver. This allows a /dev/ptp0 # device to appear as a reference clock, synchronized to the host clock. From f25a301a0a98a96b54b1a221c2dd410a3b32c4f1 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 23 Nov 2019 16:28:26 +0100 Subject: [PATCH 5/6] nixos/chrony: move to StateDirectory and tmpfiles.d --- nixos/modules/services/networking/ntp/chrony.nix | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/networking/ntp/chrony.nix b/nixos/modules/services/networking/ntp/chrony.nix index da9d960cc142..f1062edaa05b 100644 --- a/nixos/modules/services/networking/ntp/chrony.nix +++ b/nixos/modules/services/networking/ntp/chrony.nix @@ -92,6 +92,11 @@ in systemd.services.systemd-timedated.environment = { SYSTEMD_TIMEDATED_NTP_SERVICES = "chronyd.service"; }; + systemd.tmpfiles.rules = [ + "d ${stateDir} 0755 chrony chrony - -" + "f ${keyFile} 0640 chrony chrony -" + ]; + systemd.services.chronyd = { description = "chrony NTP daemon"; @@ -103,13 +108,6 @@ in path = [ pkgs.chrony ]; - preStart = '' - mkdir -m 0755 -p ${stateDir} - touch ${keyFile} - chmod 0640 ${keyFile} - chown chrony:chrony ${stateDir} ${keyFile} - ''; - unitConfig.ConditionCapability = "CAP_SYS_TIME"; serviceConfig = { Type = "simple"; @@ -118,7 +116,7 @@ in ProtectHome = "yes"; ProtectSystem = "full"; PrivateTmp = "yes"; - + StateDirectory = "chrony"; }; }; From fe6dd71f72ad53f8556498f6c1fb97f4004df6d5 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 23 Nov 2019 19:31:27 +0100 Subject: [PATCH 6/6] nixosTests.cockroachdb: set ConditionPathExists=/dev/ptp0 to chronyd --- nixos/tests/cockroachdb.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/tests/cockroachdb.nix b/nixos/tests/cockroachdb.nix index a03a223d66a3..d0cc5e19837c 100644 --- a/nixos/tests/cockroachdb.nix +++ b/nixos/tests/cockroachdb.nix @@ -88,6 +88,8 @@ let services.cockroachdb.listen.address = myAddr; services.cockroachdb.join = lib.mkIf (joinNode != null) joinNode; + systemd.services.chronyd.unitConfig.ConditionPathExists = "/dev/ptp0"; + # Hold startup until Chrony has performed its first measurement (which # will probably result in a full timeskip, thanks to makestep) systemd.services.cockroachdb.preStart = ''