about summary refs log tree commit diff
path: root/nixos/tests/consul.nix
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2020-06-18 02:45:42 +0200
committerNiklas Hambüchen <mail@nh2.me>2020-06-18 02:49:27 +0200
commit811bcbe74a7838244f88462a21828d08bf7cc4b8 (patch)
treeb87a783bb4b3eb729f0efd099a765b8cec166501 /nixos/tests/consul.nix
parent701c0eb4897554a6d783869420195878132475e3 (diff)
consul.passthru.tests: Use correct server health test.
From: https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040
Diffstat (limited to 'nixos/tests/consul.nix')
-rw-r--r--nixos/tests/consul.nix17
1 files changed, 16 insertions, 1 deletions
diff --git a/nixos/tests/consul.nix b/nixos/tests/consul.nix
index a3fc9166695fb..c6f2ac8b2f6c3 100644
--- a/nixos/tests/consul.nix
+++ b/nixos/tests/consul.nix
@@ -109,8 +109,23 @@ in {
 
 
     def wait_for_healthy_servers():
+        # See https://github.com/hashicorp/consul/issues/8118#issuecomment-645330040
+        # for why the `Voter` column of `list-peers` has that info.
+        # TODO: The `grep true` relies on the fact that currently in
+        #       the output like
+        #           # consul operator raft list-peers
+        #           Node     ID   Address           State     Voter  RaftProtocol
+        #           server3  ...  192.168.1.3:8300  leader    true   3
+        #           server2  ...  192.168.1.2:8300  follower  true   3
+        #           server1  ...  192.168.1.1:8300  follower  false  3
+        #       `Voter`is the only boolean column.
+        #       Change this to the more reliable way to be defined by
+        #       https://github.com/hashicorp/consul/issues/8118
+        #       once that ticket is closed.
         for m in machines:
-            m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
+            m.wait_until_succeeds(
+                "[ $(consul operator raft list-peers | grep true | wc -l) == 3 ]"
+            )
 
 
     wait_for_healthy_servers()