]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use the same reset script for ippool and normal redis tests
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 12 Mar 2019 04:41:03 +0000 (12:41 +0800)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 12 Mar 2019 04:41:03 +0000 (12:41 +0800)
src/tests/modules/redis/cluster_reset.inc
src/tests/modules/redis_ippool/cluster_reset.inc [changed from file to symlink]

index a1976df58970ed73ad2c2cfd35f038aaa7dabe96..e0380b1e5986b825f4841510d8004309a870a285 100644 (file)
@@ -43,6 +43,14 @@ update control {
 #
 #  Determine when initial synchronisation has been completed
 #
+update request {
+       &Tmp-String-0 := $ENV{REDIS_TEST_SERVER}
+}
+if (!&Tmp-String-0 || (&Tmp-String-0 == '')) {
+       update request {
+               &Tmp-String-0 = $ENV{REDIS_IPPOOL_TEST_SERVER}
+       }
+}
 
 #  Test nodes should be running on
 #  - 127.0.0.1:30001 - master [0-5460]
@@ -52,9 +60,7 @@ update control {
 #  - 127.0.0.1:30003 - master [10923-16383]
 #  - 127.0.0.1:30006 - slave
 foreach &control:Tmp-Integer-0 {
-       update request {
-               &Tmp-String-0 := $ENV{REDIS_IPPOOL_TEST_SERVER}
-       }
+
        #
        #  Force a remap as the slaves don't show up in the cluster immediately
        #
deleted file mode 100644 (file)
index 1da8c143300e8fdd2995fad8fa4245224404505d..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-#  Include from Redis cluster tests to get clusters back into a known state
-#
-
-# Some values we need for startup
-update control {
-       &Tmp-Integer-0 := 0
-       &Tmp-Integer-0 += 1
-       &Tmp-Integer-0 += 2
-       &Tmp-Integer-0 += 3
-       &Tmp-Integer-0 += 4
-       &Tmp-Integer-0 += 5
-       &Tmp-Integer-0 += 6
-       &Tmp-Integer-0 += 7
-       &Tmp-Integer-0 += 8
-       &Tmp-Integer-0 += 9
-       &Tmp-Integer-0 += 10
-       &Tmp-String-0 := "1-%{randstr:aaaaaaaa}"
-       &Tmp-String-1 := "2-%{randstr:aaaaaaaa}"
-       &Tmp-String-2 := "3-%{randstr:aaaaaaaa}"
-}
-
-if ("$ENV{REDIS_CLUSTER_CONTROL}" == '') {
-       update control {
-               &Tmp-String-8 := '/tmp/redis/create-cluster'
-       }
-} else {
-       update control {
-               &Tmp-String-8 := "$ENV{REDIS_CLUSTER_CONTROL}"
-       }
-}
-
-#
-#  Reset the cluster
-#
-update control {
-       &Tmp-String-0 = `%{control:Tmp-String-8} stop`
-       &Tmp-String-0 = `%{control:Tmp-String-8} clean`
-       &Tmp-String-0 = `%{control:Tmp-String-8} start`
-       &Tmp-String-0 = `%{control:Tmp-String-8} create`
-}
-
-#
-#  Determine when initial synchronisation has been completed
-#
-
-#  Hashes to Redis cluster node master 0 (1)
-if (("%{redis:SET b '%{control:Tmp-String-0}'}" != 'OK') || \
-    ("%{redis:SET c '%{control:Tmp-String-1}'}" != 'OK') || \
-    ("%{redis:SET d '%{control:Tmp-String-2}'}" != 'OK')) {
-       test_fail
-} else {
-       test_pass
-}
-
-#  Test nodes should be running on
-#  - 127.0.0.1:30001 - master [0-5460]
-#  - 127.0.0.1:30004 - slave
-#  - 127.0.0.1:30002 - master [5461-10922]
-#  - 127.0.0.1:30005 - slave
-#  - 127.0.0.1:30003 - master [10923-16383]
-#  - 127.0.0.1:30006 - slave
-foreach &control:Tmp-Integer-0 {
-       update request {
-               &Tmp-String-0 := $ENV{REDIS_IPPOOL_TEST_SERVER}
-       }
-       #
-       #  Force a remap as the slaves don't show up in the cluster immediately
-       #
-       if ("%{redis_remap:%{Tmp-String-0}:30001}" == 'success') {
-               #  The actual node to keyslot mapping seems to be somewhat random
-               #  so we now need to figure out which slave each of those keys
-               #  ended up on.
-               if (("%{redis:-@%{redis_node:b 1} GET b}" == "%{control:Tmp-String-0}") && \
-                   ("%{redis:-@%{redis_node:c 1} GET c}" == "%{control:Tmp-String-1}") && \
-                   ("%{redis:-@%{redis_node:d 1} GET d}" == "%{control:Tmp-String-2}")) {
-                       break
-               }
-
-               update request {
-                       &Module-Failure-Message !* ANY
-               }
-       }
-
-       # Perform checks every 0.5 seconds
-       update {
-               &Tmp-Integer-0 := `/bin/sleep 0.5`
-       }
-
-       if ("%{Foreach-Variable-0}" == 10) {
-               test_fail
-       }
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..98029134edc1f269b3e23f556b734976a7a2049c
--- /dev/null
@@ -0,0 +1 @@
+../redis/cluster_reset.inc
\ No newline at end of file