ctdb-tests: Get rid of ctdb func tests
authorAmitay Isaacs <amitay@gmail.com>
Wed, 27 Apr 2016 02:21:18 +0000 (12:21 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 10 May 2016 20:51:22 +0000 (22:51 +0200)
This tested parse_nodestring function from tools/ctdb.c.  However,
ctdb.c is soon going to be replaced with the code using new client API.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tests/src/ctdb_functest.c [deleted file]
ctdb/tests/tool/func.parse_nodestring.001.sh [deleted file]
ctdb/tests/tool/func.parse_nodestring.002.sh [deleted file]
ctdb/tests/tool/func.parse_nodestring.003.sh [deleted file]
ctdb/tests/tool/scripts/local.sh
ctdb/wscript

diff --git a/ctdb/tests/src/ctdb_functest.c b/ctdb/tests/src/ctdb_functest.c
deleted file mode 100644 (file)
index 9eaae55..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/* 
-   Tests for tools/ctdb.c and CTDB client stubs
-
-   Copyright (C) Martin Schwenke 2011
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-   
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-   
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#define CTDB_TEST_OVERRIDE_MAIN
-#include "ctdb_test.c"
-
-static void test_read_nodemap(void)
-{
-       struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context);
-
-       ctdb_test_stubs_read_nodemap(ctdb);
-       ctdb_test_stubs_print_nodemap(ctdb);
-
-       talloc_free(ctdb);
-}
-
-static void test_read_ifaces(void)
-{
-       struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context);
-
-       ctdb_test_stubs_read_ifaces(ctdb);
-       ctdb_test_stubs_print_ifaces(ctdb);
-
-       talloc_free(ctdb);
-}
-
-static void test_read_vnnmap(void)
-{
-       struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context);
-
-       ctdb_test_stubs_read_vnnmap(ctdb);
-       ctdb_test_stubs_print_vnnmap(ctdb);
-
-       talloc_free(ctdb);
-}
-
-static void test_fake_setup(void)
-{
-       bool first = true;
-       struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context);
-
-       ctdb_test_stubs_fake_setup(ctdb);
-
-       if (ctdb->nodes != NULL) {
-               if (!first) {
-                       printf("\n");
-               }
-               printf("NODEMAP\n");
-               ctdb_test_stubs_print_nodemap(ctdb);
-               first = false;
-       }
-
-       if (ctdb->ifaces != NULL) {
-               if (!first) {
-                       printf("\n");
-               }
-               printf("IFACES\n");
-               ctdb_test_stubs_print_ifaces(ctdb);
-               first = false;
-       }
-
-       if (ctdb->vnn_map != NULL) {
-               if (!first) {
-                       printf("\n");
-               }
-               printf("VNNMAP\n");
-               ctdb_test_stubs_print_vnnmap(ctdb);
-               first = false;
-       }
-
-       talloc_free(ctdb);
-}
-
-static const char * decode_pnn_mode(uint32_t pnn_mode)
-{
-       int i;
-       static const struct {
-               uint32_t mode;
-               const char *name;
-       } pnn_modes[] = {
-               { CTDB_CURRENT_NODE,        "CURRENT_NODE" },
-               { CTDB_BROADCAST_ALL,       "BROADCAST_ALL" },
-               { CTDB_BROADCAST_VNNMAP,    "BROADCAST_VNNMAP" },
-               { CTDB_BROADCAST_CONNECTED, "BROADCAST_CONNECTED" },
-               { CTDB_MULTICAST,           "MULTICAST" },
-       };
-
-       for (i = 0; i < ARRAY_SIZE(pnn_modes); i++) {
-               if (pnn_mode == pnn_modes[i].mode) {
-                       return pnn_modes[i].name;
-               }
-       }
-
-       return "PNN";
-}
-
-static void print_nodes(uint32_t *nodes, uint32_t pnn_mode)
-{
-       int i;
-
-       printf("NODES:");
-       for (i = 0; i < talloc_array_length(nodes); i++) {
-               printf(" %lu", (unsigned long) nodes[i]);
-       }
-       printf("\n");
-
-       printf("PNN MODE: %s (%lu)\n",
-              decode_pnn_mode(pnn_mode), (unsigned long) pnn_mode);
-}
-
-static void test_parse_nodestring(const char *nodestring_s,
-                                 const char *dd_ok_s)
-{
-       const char *nodestring;
-       bool dd_ok;
-       struct ctdb_context *ctdb;
-       uint32_t *nodes;
-       uint32_t pnn_mode;
-
-       nodestring = strcmp("", nodestring_s) == 0 ? NULL : nodestring_s;
-
-       if (strcasecmp(dd_ok_s, "yes") == 0 ||
-           strcmp(dd_ok_s, "true") == 0) {
-               dd_ok = true;
-       } else {
-               dd_ok = false;
-       }
-
-       ctdb  = talloc_zero(NULL, struct ctdb_context);
-
-       ctdb_test_stubs_read_nodemap(ctdb);
-
-       if (parse_nodestring(ctdb, NULL, nodestring, CTDB_CURRENT_NODE, dd_ok,
-                            &nodes, &pnn_mode)) {
-               print_nodes(nodes, pnn_mode);
-       }
-
-       talloc_free(ctdb);
-}
-
-static void usage(void)
-{
-       fprintf(stderr, "usage: ctdb_tool_functest <op>\n");
-       exit(1);
-}
-
-int main(int argc, const char *argv[])
-{
-       DEBUGLEVEL = DEBUG_DEBUG;
-       if (getenv("CTDB_TEST_LOGLEVEL")) {
-               DEBUGLEVEL = atoi(getenv("CTDB_TEST_LOGLEVEL"));
-       }
-
-       if (argc < 2) {
-               usage();
-       }
-
-       if (argc == 2 && strcmp(argv[1], "read_nodemap") == 0) {
-               test_read_nodemap();
-       } else if (argc == 2 && strcmp(argv[1], "read_ifaces") == 0) {
-               test_read_ifaces();
-       } else if (argc == 2 && strcmp(argv[1], "read_vnnmap") == 0) {
-               test_read_vnnmap();
-       } else if (argc == 2 && strcmp(argv[1], "fake_setup") == 0) {
-               test_fake_setup();
-       } else if (argc == 4 && strcmp(argv[1], "parse_nodestring") == 0) {
-               test_parse_nodestring(argv[2], argv[3]);
-       } else {
-               usage();
-       }
-
-       return 0;
-}
diff --git a/ctdb/tests/tool/func.parse_nodestring.001.sh b/ctdb/tests/tool/func.parse_nodestring.001.sh
deleted file mode 100755 (executable)
index d7caf89..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "all, dd_ok, 3 healthy"
-
-required_result <<EOF
-NODES: 0 1 2
-PNN MODE: BROADCAST_ALL (4026531842)
-EOF
-
-simple_test all true <<EOF
-0       192.168.20.41   0x0
-1       192.168.20.42   0x0
-2       192.168.20.43   0x0     CURRENT RECMASTER
-EOF
diff --git a/ctdb/tests/tool/func.parse_nodestring.002.sh b/ctdb/tests/tool/func.parse_nodestring.002.sh
deleted file mode 100755 (executable)
index c89e444..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "all, dd_ok, 2 ok/1 disconnected"
-
-required_result <<EOF
-NODES: 0 1 2
-PNN MODE: BROADCAST_ALL (4026531842)
-EOF
-
-simple_test all true <<EOF
-0       192.168.20.41   0x0
-1       192.168.20.42   0x1
-2       192.168.20.43   0x0     CURRENT RECMASTER
-EOF
diff --git a/ctdb/tests/tool/func.parse_nodestring.003.sh b/ctdb/tests/tool/func.parse_nodestring.003.sh
deleted file mode 100755 (executable)
index 1538e26..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "all, current disconnected"
-
-required_result 10 <<EOF
-${TEST_DATE_STAMP}Unable to get nodemap from local node
-EOF
-
-simple_test all true <<EOF
-0       192.168.20.41   0x0
-1       192.168.20.42   0x0
-2       192.168.20.43   0x1     CURRENT RECMASTER
-EOF
index 5db2a78fc9457b5bcb04ba88270e853a109a1993..c1d6ad134011f1589c3147cd615fd7694c5c5342 100644 (file)
@@ -17,12 +17,6 @@ define_test ()
     _f=$(basename "$0" ".sh")
 
     case "$_f" in
-       func.*)
-           _func="${_f#func.}"
-           _func="${_func%.*}" # Strip test number
-           export CTDB_TEST_PROG="ctdb_functest"
-           test_args="$_func"
-           ;;
        stubby.*)
            _cmd="${_f#stubby.}"
            _cmd="${_cmd%.*}" # Strip test number
index c51d963e7c672cf8a743a051df8e79482863710c..4df216cfd1c0a88dcc94fe49d5b4a8b2fbae3582 100755 (executable)
@@ -705,13 +705,6 @@ def build(bld):
                      includes='include',
                      install_path='${CTDB_TEST_LIBDIR}')
 
-    bld.SAMBA_BINARY('ctdb_functest',
-                     source='tests/src/ctdb_functest.c',
-                     deps='''replace tdb tevent talloc popt ctdb-system
-                             samba-util tdb-wrap ctdb-util''',
-                     includes='include',
-                     install_path='${CTDB_TEST_LIBDIR}')
-
     bld.SAMBA_BINARY('ctdb_stubtest',
                      source='tests/src/ctdb_test.c',
                      deps='''replace tdb tevent talloc popt ctdb-system