Merge remote branch 'martins/master'
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 18 Apr 2012 03:48:43 +0000 (13:48 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 18 Apr 2012 03:48:43 +0000 (13:48 +1000)
(This used to be ctdb commit abe7ebe6c531f912efe4ebc1daade4d2af67574c)

ctdb/Makefile.in
ctdb/server/ctdb_recoverd.c
ctdb/server/ctdb_takeover.c
ctdb/tests/complex/01_ctdb_nfs_skip_share_check.sh
ctdb/tests/events.d/00.test
ctdb/tests/run_cluster_tests.sh [new file with mode: 0755]
ctdb/tests/scripts/ctdb_test_functions.bash
ctdb/tests/simple/11_ctdb_ip.sh
ctdb/tests/simple/14_ctdb_statistics.sh
ctdb/tests/simple/16_ctdb_config_add_ip.sh
ctdb/tests/tool/testcases/stubby.nodestatus.005.sh [new file with mode: 0755]

index 1794be504a1d736275bde75616676b5b42e22011..7b7f356331758555f6a99c6b82a962b6f09895c8 100755 (executable)
@@ -367,6 +367,9 @@ install_pmda:
 test: all
        tests/run_tests.sh
 
+test_cluster: all
+       tests/run_cluster_tests.sh
+
 valgrindtest: all
        VALGRIND="valgrind -q --trace-children=yes" tests/run_tests.sh
 
index 97e46704b1f1a54bcfa7df4c40927e25b722805d..c0792178685580a1635eeaf985cd4b472867be92 100644 (file)
@@ -2775,13 +2775,13 @@ static int verify_local_ip_allocation(struct ctdb_context *ctdb, struct ctdb_rec
                                                ctdb_addr_to_str(&ips->ips[j].addr)));
                                need_takeover_run = true;
                        } else if (ips->ips[j].pnn == pnn) {
-                               if (!ctdb_sys_have_ip(&ips->ips[j].addr)) {
+                               if (ctdb->do_checkpublicip && !ctdb_sys_have_ip(&ips->ips[j].addr)) {
                                        DEBUG(DEBUG_CRIT,("Public address '%s' is missing and we should serve this ip\n",
                                                ctdb_addr_to_str(&ips->ips[j].addr)));
                                        need_takeover_run = true;
                                }
                        } else {
-                               if (ctdb_sys_have_ip(&ips->ips[j].addr)) {
+                               if (ctdb->do_checkpublicip && ctdb_sys_have_ip(&ips->ips[j].addr)) {
                                        DEBUG(DEBUG_CRIT,("We are still serving a public address '%s' that we should not be serving.\n", 
                                                ctdb_addr_to_str(&ips->ips[j].addr)));
                                        need_takeover_run = true;
index 1037c2f6bb1842525d1d05cb148cd0581048f876..43201a3832506ca37817ddac0daf7f3137b9ad76 100644 (file)
@@ -350,6 +350,8 @@ static void ctdb_do_takeip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       if (ctdb->do_checkpublicip) {
+
        ret = ctdb_announce_vnn_iface(ctdb, state->vnn);
        if (ret != 0) {
                ctdb_request_control_reply(ctdb, state->c, NULL, -1, NULL);
@@ -357,6 +359,8 @@ static void ctdb_do_takeip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       }
+
        data.dptr  = (uint8_t *)ctdb_addr_to_str(&state->vnn->public_address);
        data.dsize = strlen((char *)data.dptr) + 1;
        DEBUG(DEBUG_INFO,(__location__ " sending TAKE_IP for '%s'\n", data.dptr));
@@ -383,7 +387,7 @@ static int32_t ctdb_do_takeip(struct ctdb_context *ctdb,
        ret = ctdb_vnn_assign_iface(ctdb, vnn);
        if (ret != 0) {
                DEBUG(DEBUG_ERR,("Takeover of IP %s/%u failed to "
-                                "assin a usable interface\n",
+                                "assign a usable interface\n",
                                 ctdb_addr_to_str(&vnn->public_address),
                                 vnn->public_netmask_bits));
                return -1;
@@ -460,6 +464,8 @@ static void ctdb_do_updateip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       if (ctdb->do_checkpublicip) {
+
        ret = ctdb_announce_vnn_iface(ctdb, state->vnn);
        if (ret != 0) {
                ctdb_request_control_reply(ctdb, state->c, NULL, -1, NULL);
@@ -467,6 +473,8 @@ static void ctdb_do_updateip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       }
+
        /* the control succeeded */
        ctdb_request_control_reply(ctdb, state->c, NULL, 0, NULL);
        talloc_free(state);
@@ -591,7 +599,9 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                return 0;
        }
 
-       have_ip = ctdb_sys_have_ip(&pip->addr);
+       if (ctdb->do_checkpublicip) {
+               have_ip = ctdb_sys_have_ip(&pip->addr);
+       }
        best_iface = ctdb_vnn_best_iface(ctdb, vnn);
        if (best_iface == NULL) {
                DEBUG(DEBUG_ERR,("takeoverip of IP %s/%u failed to find"
@@ -608,6 +618,7 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                have_ip = false;
        }
 
+
        if (vnn->iface == NULL && have_ip) {
                DEBUG(DEBUG_CRIT,(__location__ " takeoverip of IP %s is known to the kernel, "
                                  "but we have no interface assigned, has someone manually configured it? Ignore for now.\n",
@@ -798,19 +809,27 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
        talloc_free(vnn->takeover_ctx);
        vnn->takeover_ctx = NULL;
 
-       if (!ctdb_sys_have_ip(&pip->addr)) {
-               DEBUG(DEBUG_DEBUG,("Redundant release of IP %s/%u on interface %s (ip not held)\n", 
-                       ctdb_addr_to_str(&pip->addr),
-                       vnn->public_netmask_bits, 
-                       ctdb_vnn_iface_string(vnn)));
-               ctdb_vnn_unassign_iface(ctdb, vnn);
-               return 0;
-       }
+       if (ctdb->do_checkpublicip) {
 
-       if (vnn->iface == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " release_ip of IP %s is known to the kernel, "
-                                "but we have no interface assigned, has someone manually configured it? Ignore for now.\n",
-                                ctdb_addr_to_str(&vnn->public_address)));
+               if (!ctdb_sys_have_ip(&pip->addr)) {
+                       DEBUG(DEBUG_DEBUG,("Redundant release of IP %s/%u on interface %s (ip not held)\n",
+                               ctdb_addr_to_str(&pip->addr),
+                               vnn->public_netmask_bits,
+                               ctdb_vnn_iface_string(vnn)));
+                       ctdb_vnn_unassign_iface(ctdb, vnn);
+                       return 0;
+               }
+
+               if (vnn->iface == NULL) {
+                       DEBUG(DEBUG_ERR,(__location__ " release_ip of IP %s is known to the kernel, "
+                                        "but we have no interface assigned, has someone manually configured it? Ignore for now.\n",
+                                        ctdb_addr_to_str(&vnn->public_address)));
+                       return 0;
+               }
+
+       } else if (vnn->iface == NULL) {
+               DEBUG(DEBUG_ERR, ("No interface found for IP %s.\n",
+                                    ctdb_addr_to_str(&vnn->public_address)));
                return 0;
        }
 
@@ -1059,7 +1078,9 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist)
        }
 
 
-       ctdb_start_monitoring_interfaces(ctdb);
+       if (ctdb->do_checkpublicip) {
+               ctdb_start_monitoring_interfaces(ctdb);
+       }
 
        talloc_free(lines);
        return 0;
index 85bc64d6596bd662c91356ffee82d96dd2fbecc5..969b445191b0615e108b1abf186786dad89cb9ef 100755 (executable)
@@ -99,7 +99,7 @@ try_command_on_node -v $test_node "mkdir -p \"$rc_local_d\""
 
 f="$rc_local_d/fake-exportfs"
 echo "Installing \"$f\"..."
-try_command_on_node $test_node "echo \"function exportfs () { echo $foo_dir 127.0.0.1/32 ; }\" >\"$f\" ; chmod +x \"$f\""
+try_command_on_node $test_node "echo \"function exportfs () { echo \\\"$foo_dir 127.0.0.1/32(rw)\\\" ; }\" >\"$f\" ; chmod +x \"$f\""
 
 n="$rc_local_d/nfs-skip-share-check"
 n_contents='loadconfig() {
index 49b741b30ea1a92bf75bcdb1a3ca8da4fac149f2..51c0e112cadc59ab0422d957546cd4f16d9b1254 100755 (executable)
@@ -43,12 +43,13 @@ case $cmd in
        ip=$2
        maskbits=$3
 
-       [ `id -u` = 0 ] && {
+       [ -n "$CTDB_TEST_REAL_CLUSTER" ] && {
            /sbin/ip addr add $ip/$maskbits dev $iface || {
                echo "Failed to add $ip/$maskbits on dev $iface"
                exit 1
            }
        }
+       echo "ctdb takeip event for $1 $2 $3"
        exit 0;
        ;;
 
@@ -63,13 +64,13 @@ case $cmd in
        iface=$1
        ip=$2
        maskbits=$3
-       [ `id -u` = 0 ] && {
+       [ -n "$CTDB_TEST_REAL_CLUSTER" ] && {
            /sbin/ip addr del $ip/$maskbits dev $iface || {
                echo "Failed to del $ip on dev $iface"
                exit 1
            }
        }
-       echo "ctdb takeip event for $1 $2 $3"
+       echo "ctdb releaseip event for $1 $2 $3"
        exit 0
        ;;
 
diff --git a/ctdb/tests/run_cluster_tests.sh b/ctdb/tests/run_cluster_tests.sh
new file mode 100755 (executable)
index 0000000..6917fd9
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+CTDB_TEST_REAL_CLUSTER=1
+export CTDB_TEST_REAL_CLUSTER
+
+if [ -n "$*" ]; then
+    tests/scripts/run_tests -s $* || exit 1
+else
+    tests/scripts/run_tests -s tests/simple/*.sh tests/complex/*.sh || exit 1
+fi
+
+echo "All OK"
+exit 0
index e729486f55ea130586626be183aeda5363e5b878..70c5b5d10b623680f412b727e9585adbba52a715 100644 (file)
@@ -703,9 +703,9 @@ daemons_start_1 ()
        echo "Node $no_public_ips will have no public IPs."
     fi
 
-    local ctdb_options="--reclock=$var_dir/rec.lock --nlist $CTDB_NODES --nopublicipcheck --event-script-dir=$CTDB_DIR/tests/events.d --logfile=$var_dir/daemons.log -d 0 --dbdir=$var_dir/test.db --dbdir-persistent=$var_dir/test.db/persistent --dbdir-state=$var_dir/test.db/state"
+    local ctdb_options="--reclock=$var_dir/rec.lock --nlist $CTDB_NODES --nopublicipcheck --event-script-dir=$CTDB_DIR/tests/events.d --logfile=$var_dir/daemons.log -d 3 --dbdir=$var_dir/test.db --dbdir-persistent=$var_dir/test.db/persistent --dbdir-state=$var_dir/test.db/state"
 
-    if [ $(id -u) -eq 0 ]; then
+    if [ -z "$CTDB_TEST_REAL_CLUSTER" ]; then
         ctdb_options="$ctdb_options --public-interface=lo"
     fi
 
index e85884541a92905299781fd0d5e0cc3c7074858e..0d7dc5a342485aef2213389e0a87ebc0baaf7a95 100755 (executable)
@@ -41,15 +41,17 @@ machineout=$(echo "$out" | sed -r \
        -e 's@[[:alpha:]]+\[@@g' \
        -e 's@\]@@g')
 
-while read ip pnn ; do
-    try_command_on_node $pnn "ip addr show"
-    if [ "${out/inet ${ip}\/}" != "$out" ] ; then
-       echo "GOOD: node $pnn appears to have $ip assigned"
-    else
-       echo "BAD:  node $pnn does not appear to have $ip assigned"
-       testfailures=1
-    fi
-done <<<"$ips" # bashism to avoid problem setting variable in pipeline.
+if [ -n "$CTDB_TEST_REAL_CLUSTER" ]; then
+    while read ip pnn ; do
+        try_command_on_node $pnn "ip addr show"
+        if [ "${out/inet ${ip}\/}" != "$out" ] ; then
+            echo "GOOD: node $pnn appears to have $ip assigned"
+        else
+            echo "BAD:  node $pnn does not appear to have $ip assigned"
+            testfailures=1
+        fi
+    done <<<"$ips" # bashism to avoid problem setting variable in pipeline.
+fi
 
 [ "$testfailures" != 1 ] && echo "Looks good!"
 
index e9ecce5892101d8e3b1038d57993737f392adb74..76c520caf48e990fc2f5f5fb1c815d587e3c341f 100755 (executable)
@@ -33,7 +33,7 @@ set -e
 
 cluster_is_healthy
 
-pattern='^(CTDB version 1|Current time of statistics[[:space:]]*:.*|Statistics collected since[[:space:]]*:.*|Gathered statistics for [[:digit:]]+ nodes|[[:space:]]+[[:alpha:]_]+[[:space:]]+[[:digit:]]+|[[:space:]]+(node|client|timeouts)|[[:space:]]+([[:alpha:]_]+_latency|max_reclock_[[:alpha:]]+)[[:space:]]+[[:digit:]-]+\.[[:digit:]]+[[:space:]]sec|[[:space:]]*(reclock_ctdbd|reclock_recd|call_latency|lockwait_latency|childwrite_latency)[[:space:]]+MIN/AVG/MAX[[:space:]]+[-.[:digit:]]+/[-.[:digit:]]+/[-.[:digit:]]+ sec out of [[:digit:]]+)$'
+pattern='^(CTDB version 1|Current time of statistics[[:space:]]*:.*|Statistics collected since[[:space:]]*:.*|Gathered statistics for [[:digit:]]+ nodes|[[:space:]]+[[:alpha:]_]+[[:space:]]+[[:digit:]]+|[[:space:]]+(node|client|timeouts)|[[:space:]]+([[:alpha:]_]+_latency|max_reclock_[[:alpha:]]+)[[:space:]]+[[:digit:]-]+\.[[:digit:]]+[[:space:]]sec|[[:space:]]*(reclock_ctdbd|reclock_recd|call_latency|lockwait_latency|childwrite_latency)[[:space:]]+MIN/AVG/MAX[[:space:]]+[-.[:digit:]]+/[-.[:digit:]]+/[-.[:digit:]]+ sec out of [[:digit:]]+|[[:space:]]+hop_count_buckets:[[:space:][:digit:]]+)$'
 
 try_command_on_node -v 1 "$CTDB statistics"
 
index 3207661f16d82eeceb7ca04cb914377d3765703d..3c23ac1d9d17aa4df343cb53be75b6c471c7cf73 100755 (executable)
@@ -92,13 +92,13 @@ for i in $test_node_ips ; do
        # Get the interface details for $i, which our address is a
        # close relative of.  This should never fail but it can't hurt
        # to be careful...
-       for k in $all_test_node_ips ; do
-           if [ "$i" = "${k%/*}" ] ; then
-                       # Found one!
-               add_ip="${try}/${k#*/}"
+       try_command_on_node $test_node "ctdb ip -v -Y"
+       while IFS=":" read x ip pnn iface x ; do
+           if [ "$i" = "$ip" ]; then
+               add_ip="$try/32:$iface"
                break 3
            fi
-       done
+       done <<<"$out"
     done
 done
 
diff --git a/ctdb/tests/tool/testcases/stubby.nodestatus.005.sh b/ctdb/tests/tool/testcases/stubby.nodestatus.005.sh
new file mode 100755 (executable)
index 0000000..a18608d
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+. "${TESTS_SUBDIR}/common.sh"
+
+define_test "-n all all, 3 nodes, 1 disconnected"
+
+required_result 1 <<EOF
+Number of nodes:3
+pnn:0 192.168.20.41    OK (THIS NODE)
+pnn:1 192.168.20.42    DISCONNECTED|INACTIVE
+pnn:2 192.168.20.43    OK
+Number of nodes:3
+pnn:0 192.168.20.41    OK
+pnn:1 192.168.20.42    DISCONNECTED|INACTIVE
+pnn:2 192.168.20.43    OK (THIS NODE)
+EOF
+
+simple_test -n all all <<EOF
+NODEMAP
+0       192.168.20.41   0x0
+1       192.168.20.42   0x1
+2       192.168.20.43   0x0     CURRENT RECMASTER
+
+IFACES
+:Name:LinkStatus:References:
+:eth2:1:2:
+:eth1:1:4:
+
+VNNMAP
+654321
+0
+1
+2
+EOF