From ac73a3806055a7b9df38abe7af24d46cf405af71 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 30 Nov 2024 21:20:03 +0100 Subject: [PATCH] cluster/services/patroni: adjust test for different numbers of replicas --- cluster/services/patroni/simulacrum/test.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cluster/services/patroni/simulacrum/test.nix b/cluster/services/patroni/simulacrum/test.nix index 3460ec1..4ae3d95 100644 --- a/cluster/services/patroni/simulacrum/test.nix +++ b/cluster/services/patroni/simulacrum/test.nix @@ -1,8 +1,9 @@ -{ cluster, ... }: +{ cluster, lib, ... }: let clusterName = "poseidon"; link = cluster.config.links.patroni-pg-access; + expectedReplicas = (lib.length cluster.config.services.patroni.nodes.worker) - 1; in { defaults = { depot, pkgs, ... }: { @@ -26,7 +27,7 @@ in def booted(nodes): return filter(lambda node: node.booted, nodes) - def wait_for_all_nodes_ready(expected_replicas=2): + def wait_for_all_nodes_ready(expected_replicas=${toString expectedReplicas}): booted_nodes = booted(nodes) for node in booted_nodes: node.wait_for_unit("patroni.service") @@ -71,7 +72,7 @@ in for node in nodes: node.crash() - wait_for_all_nodes_ready(1) + wait_for_all_nodes_ready(${toString (expectedReplicas - 1)}) # Execute some queries while a node is down. run_dummy_queries()