ctdb-tests: Be more careful when building node addresses
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Sep 2018 05:24:43 +0000 (15:24 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 8 Oct 2018 00:46:23 +0000 (02:46 +0200)
The goal is to allow more local daemons by expanding the address range
rather than generating invalid addresses.

For IPv6, use all 4 trailing hex digits.

For IPv4, use the last 2 octets.  Although 127.0.0.0 is a /8 network,
avoid unexpected issues due to 0 and 255 in the last octet.  Use a
maximum of 100 addresses per "subnet" starting at .1.  Keep the first
group of addresses in 127.0.0.0/24 to continue to allow a reasonable
number of nodes to be tested with socket-wrapper.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/scripts/local_daemons.bash

index fa6e08029bb4fe42f7d908836f7cd30174f10e88..5b58dda05fc6300f726313f086d1b25021d4e748 100644 (file)
@@ -39,10 +39,10 @@ setup_nodes ()
 {
        local have_all_ips=true
        local i
-       for i in $(seq 1 $TEST_LOCAL_DAEMONS) ; do
+       for i in $(seq 0 $((TEST_LOCAL_DAEMONS - 1)) ) ; do
                if [ -n "$CTDB_USE_IPV6" ]; then
-                       local j=$(printf "%02x" $i)
-                       local node_ip="fd00::5357:5f${j}"
+                       local j=$(printf "%04x" $((0x5f00 + 1 + i)) )
+                       local node_ip="fd00::5357:${j}"
                        if have_ip "$node_ip" ; then
                                echo "$node_ip"
                        else
@@ -52,8 +52,9 @@ EOF
                                have_all_ips=false
                        fi
                else
-                       local j=$((i + 10))
-                       echo "127.0.0.${j}"
+                       local c=$(( i / 100 ))
+                       local d=$(( 1 + (i % 100) ))
+                       echo "127.0.${c}.${d}"
                fi
        done