]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
redis: Fix node fail test to be more reliable
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 13 Apr 2023 07:43:41 +0000 (17:43 +1000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 13 Apr 2023 08:29:40 +0000 (18:29 +1000)
src/tests/modules/redis/cluster_node_fail.unlang

index 9a7867f8379c28cb82768745a571f7e2ba69c7f8..3775c324fa665369fc964bffd36fc805b77d0abc 100644 (file)
@@ -8,28 +8,34 @@ if (!("%(redis:SET b 'boom')" == 'OK')) {
        test_fail
 }
 
-#  Leave some time (100ms) for the synchronisation
-&Tmp-String-0 := `/bin/sleep 0.1`
+#  Leave some time (500ms) for the synchronisation
+%(delay:0.5)
 
 #  Note the current master
 &Tmp-String-1 := %(redis_node:b 0)
 
+#  Note the current replica
+&Tmp-String-2 := %(redis_node:b 1)
+
 #  Cause one of the redis cluster nodes to SEGV
 if ("%(redis:@%(redis_node:b 0) DEBUG SEGFAULT)" != '') {
        test_fail
 }
 
 #  Forcefully failover the slave for that node
-if (!("%(redis:@%(redis_node:b 1) CLUSTER FAILOVER TAKEOVER)" == 'OK')) {
+if (!("%(redis:@%{Tmp-String-2} CLUSTER FAILOVER TAKEOVER)" == 'OK')) {
        test_fail
 }
 
 #  Allow time for the takeover to propagate to other nodes
 foreach &control.Tmp-Integer-0 {
-       if (%(redis_node:b 0) != &Tmp-String-1) {
+       # Keep remapping the cluster
+       %(redis_remap:%{Tmp-String-2})
+
+       if (%(redis_node:b 0) == &Tmp-String-2) {
                break
        }
-       &Tmp-String-0 := `/bin/sleep 0.5`
+       %(delay:0.5)
 }
 
 if (!("%(redis:GET b)" == 'boom')) {
@@ -42,6 +48,7 @@ if ("%(redis:@%(redis_node:b) DEBUG SEGFAULT)" != '') {
 }
 
 # No alternatives...
+%(delay:0.5)
 if ("%(redis:GET b)" == 'boom') {
        test_fail
 }