diff options
author | Jaka Hudoklin <jakahudoklin@gmail.com> | 2014-11-23 12:16:50 +0100 |
---|---|---|
committer | Jaka Hudoklin <jakahudoklin@gmail.com> | 2014-11-23 12:16:50 +0100 |
commit | 4f592d4f29a06a553858bf50d64deda6752168e5 (patch) | |
tree | 11f75c51d050a38b8ab784d953c72079ae93546c | |
parent | d1493bc1eecf4b0240781ea13bda2a01838f4dfb (diff) | |
download | nixlib-4f592d4f29a06a553858bf50d64deda6752168e5.tar nixlib-4f592d4f29a06a553858bf50d64deda6752168e5.tar.gz nixlib-4f592d4f29a06a553858bf50d64deda6752168e5.tar.bz2 nixlib-4f592d4f29a06a553858bf50d64deda6752168e5.tar.lz nixlib-4f592d4f29a06a553858bf50d64deda6752168e5.tar.xz nixlib-4f592d4f29a06a553858bf50d64deda6752168e5.tar.zst nixlib-4f592d4f29a06a553858bf50d64deda6752168e5.zip |
nixos/etcd: fix postStart check and make tests deterministic
-rw-r--r-- | nixos/modules/services/misc/etcd.nix | 7 | ||||
-rw-r--r-- | nixos/tests/etcd.nix | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/nixos/modules/services/misc/etcd.nix b/nixos/modules/services/misc/etcd.nix index 550d351ccfbe..284361a04d9e 100644 --- a/nixos/modules/services/misc/etcd.nix +++ b/nixos/modules/services/misc/etcd.nix @@ -46,7 +46,7 @@ in { initialCluster = mkOption { description = "Etcd initial cluster configuration for bootstrapping."; - default = ["${cfg.name}=http://localhost:2380" "${cfg.name}=http://localhost:7001"]; + default = ["${cfg.name}=http://localhost:7001"]; type = types.listOf types.str; }; @@ -123,7 +123,10 @@ in { if [ "$(id -u)" = 0 ]; then chown etcd ${cfg.dataDir}; fi ''; postStart = '' - until ${pkgs.curl}/bin/curl -s -o /dev/null '${head cfg.listenClientUrls}/version'; do + until ${pkgs.etcdctl}/bin/etcdctl set /nixos/state 'up'; do + sleep 1; + done + until ${pkgs.etcdctl}/bin/etcdctl get /nixos/state | grep up; do sleep 1; done ''; diff --git a/nixos/tests/etcd.nix b/nixos/tests/etcd.nix index 6c6dd84f558d..ace5e05b170a 100644 --- a/nixos/tests/etcd.nix +++ b/nixos/tests/etcd.nix @@ -80,7 +80,7 @@ import ./make-test.nix { $simple->start(); $simple->waitForUnit("etcd.service"); $simple->succeed("etcdctl set /foo/bar 'Hello world'"); - $simple->succeed("etcdctl get /foo/bar | grep 'Hello world'"); + $simple->waitUntilSucceeds("etcdctl get /foo/bar | grep 'Hello world'"); }; subtest "multy node", sub { @@ -89,7 +89,7 @@ import ./make-test.nix { $node1->waitForUnit("etcd.service"); $node2->waitForUnit("etcd.service"); $node1->succeed("etcdctl set /foo/bar 'Hello world'"); - $node2->succeed("etcdctl get /foo/bar | grep 'Hello world'"); + $node2->waitUntilSucceeds("etcdctl get /foo/bar | grep 'Hello world'"); $node1->shutdown(); $node2->shutdown(); }; @@ -102,7 +102,7 @@ import ./make-test.nix { $discovery1->waitForUnit("etcd.service"); $discovery2->waitForUnit("etcd.service"); $discovery1->succeed("etcdctl set /foo/bar 'Hello world'"); - $discovery2->succeed("etcdctl get /foo/bar | grep 'Hello world'"); + $discovery2->waitUntilSucceeds("etcdctl get /foo/bar | grep 'Hello world'"); }; ''; } |