[SCM] CTDB repository - branch master updated - ctdb-2.1-206-g75a620c

Amitay Isaacs amitay at samba.org
Fri May 24 07:42:32 MDT 2013


The branch, master has been updated
       via  75a620c516e384f042b5d675183b3a1b48fd6115 (commit)
       via  cfd1371d3a1f78a0ed86485d83bd4d311727c3d4 (commit)
       via  ef35c8889d90220929e48e66eb62da9ea2025ede (commit)
       via  954ae6f84cb06a8dcbc12456d4752280072be5bf (commit)
      from  32723c9efdad1c6ca4aa53f308ccd9bef1aadfff (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 75a620c516e384f042b5d675183b3a1b48fd6115
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Apr 5 20:47:47 2013 +1100

    tests/takeover: New test with 900 IPs

commit cfd1371d3a1f78a0ed86485d83bd4d311727c3d4
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Apr 5 20:45:08 2013 +1100

    tests/takeover: Takeover tests can use up to 1024 and checks limits
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit ef35c8889d90220929e48e66eb62da9ea2025ede
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 8 14:37:44 2013 +1000

    tests/takeover: LCP2 tests for weird, unbalanced corner-cases
    
    2 tests to show a bad result and a 3rd test for the fix.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 954ae6f84cb06a8dcbc12456d4752280072be5bf
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 8 14:37:08 2013 +1000

    tests/takeover: Allow takeover runs with differing IP allocations per node
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 tests/src/ctdb_takeover_tests.c |   71 ++-
 tests/takeover/lcp2.027.sh      |   45 +
 tests/takeover/lcp2.028.sh      |   45 +
 tests/takeover/lcp2.029.sh      |  111 +++
 tests/takeover/lcp2.030.sh      | 1813 +++++++++++++++++++++++++++++++++++++++
 tests/takeover/scripts/local.sh |    3 +-
 6 files changed, 2075 insertions(+), 13 deletions(-)
 create mode 100755 tests/takeover/lcp2.027.sh
 create mode 100755 tests/takeover/lcp2.028.sh
 create mode 100755 tests/takeover/lcp2.029.sh
 create mode 100755 tests/takeover/lcp2.030.sh


Changeset truncated at 500 lines:

diff --git a/tests/src/ctdb_takeover_tests.c b/tests/src/ctdb_takeover_tests.c
index 196f90d..1aa0620 100644
--- a/tests/src/ctdb_takeover_tests.c
+++ b/tests/src/ctdb_takeover_tests.c
@@ -21,7 +21,7 @@
 
 /* This is lazy... but it is test code! */
 #define CTDB_TEST_MAX_NODES 256
-#define CTDB_TEST_MAX_IPS 256
+#define CTDB_TEST_MAX_IPS 1024
 
 /* Format of each line is "IP pnn" - the separator has to be at least
  * 1 space (not a tab or whatever - a space!).
@@ -127,6 +127,11 @@ read_ctdb_public_ip_info(TALLOC_CTX *ctx,
 			*t = '\0';
 		}
 
+		/* Exit on an empty line */
+		if (line[0] == '\0') {
+			break;
+		}
+
 		/* Get the IP address */
 		tok = strtok(line, " \t");
 		if (tok == NULL) {
@@ -140,6 +145,10 @@ read_ctdb_public_ip_info(TALLOC_CTX *ctx,
 		}
 
 		numips++;
+		if (numips > CTDB_TEST_MAX_IPS) {
+			DEBUG(DEBUG_ERR, ("ERROR: Exceeding CTDB_TEST_MAX_IPS: %d\n", CTDB_TEST_MAX_IPS));
+			exit(1);
+		}
 
 		/* Get the PNN */
 		pnn = -1;
@@ -236,6 +245,10 @@ void ctdb_test_read_ctdb_public_ip_info(const char nodestates[])
 	tok = strtok(ns, ",");
 	while (tok != NULL) {
 		numnodes++;
+		if (numnodes > CTDB_TEST_MAX_NODES) {
+			DEBUG(DEBUG_ERR, ("ERROR: Exceeding CTDB_TEST_MAX_NODES: %d\n", CTDB_TEST_MAX_NODES));
+			exit(1);
+		}
 		tok = strtok(NULL, ",");
 	}
 	
@@ -377,10 +390,26 @@ static enum ctdb_runstate *get_runstate(TALLOC_CTX *tmp_ctx,
 	return runstate;
 }
 
+/* Fake up enough CTDB state to be able to run the IP allocation
+ * algorithm.  Usually this sets up some standard state, sets the node
+ * states from the command-line and reads the current IP layout from
+ * stdin.
+ *
+ * However, if read_ips_for_multiple_nodes is true then each node's
+ * idea of the IP layout is read separately from stdin.  In this mode
+ * is doesn't make much sense to use read_ctdb_public_ip_info's
+ * optional ALLOWED_PNN,... list in the input, since each node is
+ * being handled separately anyway.  IPs for each node are separated
+ * by a blank line.  This mode is for testing weird behaviours where
+ * the IP layouts differs across nodes and we want to improve
+ * create_merged_ip_list(), so should only be used in tests of
+ * ctdb_takeover_run_core().  Yes, it is a hack...  :-)
+ */
 void ctdb_test_init(const char nodestates[],
 		    struct ctdb_context **ctdb,
 		    struct ctdb_public_ip_list **all_ips,
-		    struct ctdb_ipflags **ipflags)
+		    struct ctdb_ipflags **ipflags,
+		    bool read_ips_for_multiple_nodes)
 {
 	struct ctdb_all_public_ips **avail;
 	int i, numnodes;
@@ -401,6 +430,10 @@ void ctdb_test_init(const char nodestates[],
 	while (tok != NULL) {
 		nodeflags[numnodes] = (uint32_t) strtol(tok, NULL, 0);
 		numnodes++;
+		if (numnodes > CTDB_TEST_MAX_NODES) {
+			DEBUG(DEBUG_ERR, ("ERROR: Exceeding CTDB_TEST_MAX_NODES: %d\n", CTDB_TEST_MAX_NODES));
+			exit(1);
+		}
 		tok = strtok(NULL, ",");
 	}
 	
@@ -438,7 +471,9 @@ void ctdb_test_init(const char nodestates[],
 	nodemap =  talloc_array(*ctdb, struct ctdb_node_map, numnodes);
 	nodemap->num = numnodes;
 
-	read_ctdb_public_ip_info(*ctdb, numnodes, all_ips, &avail);
+	if (!read_ips_for_multiple_nodes) {
+		read_ctdb_public_ip_info(*ctdb, numnodes, all_ips, &avail);
+	}
 
 	(*ctdb)->nodes = talloc_array(*ctdb, struct ctdb_node *, numnodes); // FIXME: bogus size, overkill
 
@@ -447,6 +482,11 @@ void ctdb_test_init(const char nodestates[],
 		nodemap->nodes[i].flags = nodeflags[i];
 		/* nodemap->nodes[i].sockaddr is uninitialised */
 
+		if (read_ips_for_multiple_nodes) {
+			read_ctdb_public_ip_info(*ctdb, numnodes,
+						 all_ips, &avail);
+		}
+
 		(*ctdb)->nodes[i] = talloc(*ctdb, struct ctdb_node);
 		(*ctdb)->nodes[i]->pnn = i;
 		(*ctdb)->nodes[i]->flags = nodeflags[i];
@@ -470,7 +510,7 @@ void ctdb_test_lcp2_allocate_unassigned(const char nodestates[])
 	uint32_t *lcp2_imbalances;
 	bool *newly_healthy;
 
-	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags);
+	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags, false);
 
 	lcp2_init(ctdb, ipflags, all_ips, &lcp2_imbalances, &newly_healthy);
 
@@ -492,7 +532,7 @@ void ctdb_test_lcp2_failback(const char nodestates[])
 	uint32_t *lcp2_imbalances;
 	bool *newly_healthy;
 
-	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags);
+	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags, false);
 
 	lcp2_init(ctdb, ipflags, all_ips, &lcp2_imbalances, &newly_healthy);
 
@@ -514,7 +554,7 @@ void ctdb_test_lcp2_failback_loop(const char nodestates[])
 	uint32_t *lcp2_imbalances;
 	bool *newly_healthy;
 
-	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags);
+	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags, false);
 
 	lcp2_init(ctdb, ipflags, all_ips, &lcp2_imbalances, &newly_healthy);
 
@@ -526,14 +566,18 @@ void ctdb_test_lcp2_failback_loop(const char nodestates[])
 	talloc_free(ctdb);
 }
 
-/* IP layout is read from stdin. */
-void ctdb_test_ctdb_takeover_run_core(const char nodestates[])
+/* IP layout is read from stdin.  See comment for ctdb_test_init() for
+ * explanation of read_ips_for_multiple_nodes.
+ */
+void ctdb_test_ctdb_takeover_run_core(const char nodestates[],
+				      bool read_ips_for_multiple_nodes)
 {
 	struct ctdb_context *ctdb;
 	struct ctdb_public_ip_list *all_ips;
 	struct ctdb_ipflags *ipflags;
 
-	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags);
+	ctdb_test_init(nodestates, &ctdb, &all_ips, &ipflags,
+		       read_ips_for_multiple_nodes);
 
 	ctdb_takeover_run_core(ctdb, ipflags, &all_ips);
 
@@ -575,8 +619,13 @@ int main(int argc, const char *argv[])
 		ctdb_test_lcp2_failback(argv[2]);
 	} else if (argc == 3 && strcmp(argv[1], "lcp2_failback_loop") == 0) {
 		ctdb_test_lcp2_failback_loop(argv[2]);
-	} else if (argc == 3 && strcmp(argv[1], "ctdb_takeover_run_core") == 0) {
-		ctdb_test_ctdb_takeover_run_core(argv[2]);
+	} else if (argc == 3 &&
+		   strcmp(argv[1], "ctdb_takeover_run_core") == 0) {
+		ctdb_test_ctdb_takeover_run_core(argv[2], false);
+	} else if (argc == 4 &&
+		   strcmp(argv[1], "ctdb_takeover_run_core") == 0 &&
+		   strcmp(argv[3], "multi") == 0) {
+		ctdb_test_ctdb_takeover_run_core(argv[2], true);
 	} else {
 		usage();
 	}
diff --git a/tests/takeover/lcp2.027.sh b/tests/takeover/lcp2.027.sh
new file mode 100755
index 0000000..20e0f28
--- /dev/null
+++ b/tests/takeover/lcp2.027.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "4 nodes, all IPs assigned, 3->4 unhealthy"
+
+export CTDB_TEST_LOGLEVEL=0
+
+required_result <<EOF
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 3
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 0
+130.216.30.172 3
+130.216.30.171 1
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 0
+10.19.99.250 3
+EOF
+
+simple_test 0,0,2,0 <<EOF
+130.216.30.170 3
+130.216.30.171 2
+130.216.30.172 3
+130.216.30.173 2
+130.216.30.174 1
+130.216.30.175 0
+130.216.30.176 1
+130.216.30.177 0
+130.216.30.178 3
+130.216.30.179 2
+130.216.30.180 1
+130.216.30.181 0
+10.19.99.250 3
+10.19.99.251 2
+10.19.99.252 1
+10.19.99.253 0
+EOF
diff --git a/tests/takeover/lcp2.028.sh b/tests/takeover/lcp2.028.sh
new file mode 100755
index 0000000..60d22d9
--- /dev/null
+++ b/tests/takeover/lcp2.028.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "4 nodes, all healthy/assigned, stays unbalanced"
+
+export CTDB_TEST_LOGLEVEL=3
+
+required_result <<EOF
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 2
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 0
+130.216.30.172 3
+130.216.30.171 1
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 0
+10.19.99.250 3
+EOF
+
+simple_test 0,0,0,0 <<EOF
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 2
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 0
+130.216.30.172 3
+130.216.30.171 1
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 0
+10.19.99.250 3
+EOF
diff --git a/tests/takeover/lcp2.029.sh b/tests/takeover/lcp2.029.sh
new file mode 100755
index 0000000..d3c817f
--- /dev/null
+++ b/tests/takeover/lcp2.029.sh
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "4 nodes, some IPs unassigned on target nodes"
+
+export CTDB_TEST_LOGLEVEL=3
+
+required_result <<EOF
+DATE TIME [PID]:  10.19.99.251 -> 2 [+9216]
+DATE TIME [PID]:  130.216.30.173 -> 2 [+24345]
+DATE TIME [PID]:  130.216.30.171 -> 2 [+39970]
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 2
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 2
+130.216.30.172 3
+130.216.30.171 2
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 2
+10.19.99.250 3
+EOF
+
+# In this example were 4 releases from node 2 in a previous iteration
+#
+#   Release of IP 130.216.30.179/27 on interface ethX1  node:3
+#   Release of IP 130.216.30.173/27 on interface ethX1  node:0
+#   Release of IP 130.216.30.171/27 on interface ethX1  node:1
+#   Release of IP 10.19.99.251/22 on interface ethX2  node:0
+#
+# However, one release failed so no takeovers were done.  This means
+# that the target node for each IP still thinks that the IPs are held
+# by node 2.  The release of 130.216.30.179 was so late that node 2
+# still thought that it held that address.
+
+simple_test 0,0,0,0 multi <<EOF
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 3
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 2
+130.216.30.172 3
+130.216.30.171 1
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 2
+10.19.99.250 3
+
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 3
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 0
+130.216.30.172 3
+130.216.30.171 2
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 0
+10.19.99.250 3
+
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 2
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 0
+130.216.30.172 3
+130.216.30.171 1
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 0
+10.19.99.250 3
+
+130.216.30.181 0
+130.216.30.180 1
+130.216.30.179 2
+130.216.30.178 3
+130.216.30.177 0
+130.216.30.176 1
+130.216.30.175 0
+130.216.30.174 1
+130.216.30.173 0
+130.216.30.172 3
+130.216.30.171 1
+130.216.30.170 3
+10.19.99.253 0
+10.19.99.252 1
+10.19.99.251 0
+10.19.99.250 3
+EOF
diff --git a/tests/takeover/lcp2.030.sh b/tests/takeover/lcp2.030.sh
new file mode 100755
index 0000000..739757b
--- /dev/null
+++ b/tests/takeover/lcp2.030.sh
@@ -0,0 +1,1813 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "900 IPs, 5 nodes, 0 -> 5 healthy"
+
+export CTDB_TEST_LOGLEVEL=0
+
+required_result <<EOF
+192.168.10.90 0
+192.168.10.89 1
+192.168.10.88 2
+192.168.10.87 3
+192.168.10.86 4
+192.168.10.85 0
+192.168.10.84 1
+192.168.10.83 2
+192.168.10.82 3
+192.168.10.81 4
+192.168.10.80 0
+192.168.10.79 0
+192.168.10.78 1
+192.168.10.77 2
+192.168.10.76 3
+192.168.10.75 4
+192.168.10.74 1
+192.168.10.73 2
+192.168.10.72 3
+192.168.10.71 3
+192.168.10.70 4
+192.168.10.69 0
+192.168.10.68 1
+192.168.10.67 2
+192.168.10.66 4
+192.168.10.65 0
+192.168.10.64 1
+192.168.10.63 0
+192.168.10.62 1
+192.168.10.61 2
+192.168.10.60 3
+192.168.10.59 4
+192.168.10.58 2
+192.168.10.57 3
+192.168.10.56 0
+192.168.10.55 0
+192.168.10.54 1
+192.168.10.53 2
+192.168.10.52 3
+192.168.10.51 4
+192.168.10.50 1
+192.168.10.49 4
+192.168.10.48 2
+192.168.10.47 0
+192.168.10.46 1
+192.168.10.45 2
+192.168.10.44 3
+192.168.10.43 4
+192.168.10.42 2
+192.168.10.41 3
+192.168.10.40 1
+192.168.10.39 3
+192.168.10.38 4
+192.168.10.37 0
+192.168.10.36 1
+192.168.10.35 2
+192.168.10.34 4
+192.168.10.33 0
+192.168.10.32 3
+192.168.10.31 0
+192.168.10.30 1
+192.168.10.29 2
+192.168.10.28 3
+192.168.10.27 4
+192.168.10.26 3
+192.168.10.25 2
+192.168.10.24 0
+192.168.10.23 3
+192.168.10.22 4
+192.168.10.21 0
+192.168.10.20 1
+192.168.10.19 2
+192.168.10.18 4
+192.168.10.17 1
+192.168.10.16 4
+192.168.10.15 0
+192.168.10.14 1
+192.168.10.13 2
+192.168.10.12 3
+192.168.10.11 4
+192.168.10.10 2
+192.168.10.9 3
+192.168.10.8 4
+192.168.10.7 0
+192.168.10.6 1
+192.168.10.5 2
+192.168.10.4 3
+192.168.10.3 4
+192.168.10.2 0
+192.168.10.1 1
+192.168.9.90 0
+192.168.9.89 1


-- 
CTDB repository


More information about the samba-cvs mailing list