The branch, master has been updated
       via  4df3dcd ctdb-tests: Add tests for client with multiple connections
       via  90f7e06 ctdb-tests: Add support for multiple ctdb connections in 
dummy_client
       via  6ed2ed7 ctdb-tests: Check all connections from a process in 
CHECK_PID_SRVID control
       via  e342f1f ctdb-daemon: Check all connections from a process in 
CHECK_PID_SRVID control
      from  3a360f5 selftest: Also run smbtorture smb2.compound with aio enabled

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4df3dcdda692ef65b7d95c4b5623905982b4bd2b
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Fri Sep 22 14:17:59 2017 +1000

    ctdb-tests: Add tests for client with multiple connections
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Volker Lendecke <v...@samba.org>
    
    Autobuild-User(master): Volker Lendecke <v...@samba.org>
    Autobuild-Date(master): Fri Sep 22 20:58:46 CEST 2017 on sn-devel-144

commit 90f7e06c2553a13779dd24739aeefea96f55ba3e
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Fri Sep 22 14:14:00 2017 +1000

    ctdb-tests: Add support for multiple ctdb connections in dummy_client
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Volker Lendecke <v...@samba.org>

commit 6ed2ed7e2dc55e2508f31f32e53db5dab1fce2a8
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Fri Sep 22 14:04:50 2017 +1000

    ctdb-tests: Check all connections from a process in CHECK_PID_SRVID control
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Volker Lendecke <v...@samba.org>

commit e342f1f078fa50904216e6e45fb9b6e40043eb98
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Fri Sep 22 13:52:09 2017 +1000

    ctdb-daemon: Check all connections from a process in CHECK_PID_SRVID control
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Volker Lendecke <v...@samba.org>

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

Summary of changes:
 ctdb/server/ctdb_daemon.c                          | 22 +++++-----
 ctdb/tests/simple/07_ctdb_process_exists.sh        |  2 +-
 ctdb/tests/src/dummy_client.c                      | 32 ++++++++++----
 ctdb/tests/src/fake_ctdbd.c                        | 49 +++++++++++++---------
 ...ss-exists.002.sh => ctdb.process-exists.003.sh} |  4 +-
 5 files changed, 70 insertions(+), 39 deletions(-)
 copy ctdb/tests/tool/{ctdb.process-exists.002.sh => 
ctdb.process-exists.003.sh} (77%)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 90e8b71..c72f41a 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1774,7 +1774,7 @@ int32_t ctdb_control_process_exists(struct ctdb_context 
*ctdb, pid_t pid)
 int32_t ctdb_control_check_pid_srvid(struct ctdb_context *ctdb,
                                     TDB_DATA indata)
 {
-        struct ctdb_client *client;
+       struct ctdb_client_pid_list *client_pid;
        pid_t pid;
        uint64_t srvid;
        int ret;
@@ -1782,17 +1782,19 @@ int32_t ctdb_control_check_pid_srvid(struct 
ctdb_context *ctdb,
        pid = *(pid_t *)indata.dptr;
        srvid = *(uint64_t *)(indata.dptr + sizeof(pid_t));
 
-       client = ctdb_find_client_by_pid(ctdb, pid);
-       if (client == NULL) {
-               return -1;
-       }
-
-       ret = srvid_exists(ctdb->srv, srvid, client);
-       if (ret != 0) {
-               return -1;
+       for (client_pid = ctdb->client_pids;
+            client_pid != NULL;
+            client_pid = client_pid->next) {
+               if (client_pid->pid == pid) {
+                       ret = srvid_exists(ctdb->srv, srvid,
+                                          client_pid->client);
+                       if (ret == 0) {
+                               return 0;
+                       }
+               }
        }
 
-       return 0;
+       return -1;
 }
 
 int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, 
TDB_DATA indata, TDB_DATA *outdata)
diff --git a/ctdb/tests/simple/07_ctdb_process_exists.sh 
b/ctdb/tests/simple/07_ctdb_process_exists.sh
index b3b8e51..8ccfc69 100755
--- a/ctdb/tests/simple/07_ctdb_process_exists.sh
+++ b/ctdb/tests/simple/07_ctdb_process_exists.sh
@@ -41,7 +41,7 @@ srvid=0xAE00000012345678
 # Execute a ctdb client on $test_node that will last for 60 seconds.
 # It should still be there when we check.
 try_command_on_node -v $test_node \
-       "$CTDB_TEST_WRAPPER exec dummy_client -S ${srvid} >/dev/null 2>&1 & 
echo \$!"
+       "$CTDB_TEST_WRAPPER exec dummy_client -n 10 -S ${srvid} >/dev/null 2>&1 
& echo \$!"
 client_pid="$out"
 
 cleanup ()
diff --git a/ctdb/tests/src/dummy_client.c b/ctdb/tests/src/dummy_client.c
index 6af41f3..6f30512 100644
--- a/ctdb/tests/src/dummy_client.c
+++ b/ctdb/tests/src/dummy_client.c
@@ -31,6 +31,7 @@
 static struct {
        const char *sockpath;
        const char *debuglevel;
+       int num_connections;
        int timelimit;
        const char *srvidstr;
 } options;
@@ -41,6 +42,8 @@ static struct poptOption cmdline_options[] = {
                "Unix domain socket path", "filename" },
        { "debug", 'd', POPT_ARG_STRING, &options.debuglevel, 0,
                "debug level", "ERR|WARNING|NOTICE|INFO|DEBUG" } ,
+       { "nconn", 'n', POPT_ARG_INT, &options.num_connections, 0,
+               "number of connections", "" },
        { "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0,
                "time limit", "seconds" },
        { "srvid", 'S', POPT_ARG_STRING, &options.srvidstr, 0,
@@ -59,16 +62,18 @@ int main(int argc, const char *argv[])
 {
        TALLOC_CTX *mem_ctx;
        struct tevent_context *ev;
-       struct ctdb_client_context *client;
+       struct ctdb_client_context **client;
+       struct ctdb_client_context *last_client;
        const char *ctdb_socket;
        poptContext pc;
-       int opt, ret;
+       int opt, ret, i;
        int log_level;
        bool status, done;
 
        /* Set default options */
        options.sockpath = CTDB_SOCKET;
        options.debuglevel = "ERR";
+       options.num_connections = 1;
        options.timelimit = 60;
        options.srvidstr = NULL;
 
@@ -112,19 +117,32 @@ int main(int argc, const char *argv[])
        setup_logging("dummy_client", DEBUG_STDERR);
        DEBUGLEVEL = log_level;
 
-       ret = ctdb_client_init(mem_ctx, ev, options.sockpath, &client);
-       if (ret != 0) {
-               D_ERR("Failed to initialize client, ret=%d\n", ret);
+       client = talloc_array(mem_ctx, struct ctdb_client_context *,
+                             options.num_connections);
+       if (client == NULL) {
+               fprintf(stderr, "Memory allocation error\n");
                exit(1);
        }
 
+       for (i=0; i<options.num_connections; i++) {
+               ret = ctdb_client_init(client, ev, options.sockpath,
+                                      &client[i]);
+               if (ret != 0) {
+                       D_ERR("Failed to initialize client %d, ret=%d\n",
+                             i, ret);
+                       exit(1);
+               }
+       }
+
+       last_client = client[options.num_connections-1];
+
        done = false;
        if (options.srvidstr != NULL) {
                uint64_t srvid;
 
                srvid = strtoull(options.srvidstr, NULL, 0);
 
-               ret = ctdb_client_set_message_handler(ev, client, srvid,
+               ret = ctdb_client_set_message_handler(ev, last_client, srvid,
                                                      dummy_handler, &done);
                if (ret != 0) {
                        D_ERR("Failed to register srvid, ret=%d\n", ret);
@@ -143,6 +161,6 @@ int main(int argc, const char *argv[])
                exit(1);
        }
 
-       talloc_free(client);
+       talloc_free(mem_ctx);
        exit(0);
 }
diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
index 8b3a0c4..98aacbe 100644
--- a/ctdb/tests/src/fake_ctdbd.c
+++ b/ctdb/tests/src/fake_ctdbd.c
@@ -2792,35 +2792,46 @@ static void control_check_pid_srvid(TALLOC_CTX *mem_ctx,
        struct client_state *state = tevent_req_data(
                req, struct client_state);
        struct ctdbd_context *ctdb = state->ctdb;
+       struct ctdb_client *client;
        struct client_state *cstate;
        struct ctdb_reply_control reply;
+       bool pid_found, srvid_found;
        int ret;
 
        reply.rdata.opcode = request->opcode;
 
-       cstate = client_find(ctdb, request->rdata.data.pid_srvid->pid);
-       if (cstate == NULL) {
-               reply.status = -1;
-               reply.errmsg = "No client for PID";
-       } else {
-               ret = srvid_exists(ctdb->srv,
-                                  request->rdata.data.pid_srvid->srvid,
-                                  cstate);
-               if (ret != 0) {
-                       reply.status = -1;
-                       reply.errmsg = "No client for PID and SRVID";
-               } else {
-                       ret = kill(cstate->pid, 0);
-                       if (ret != 0) {
-                               reply.status = ret;
-                               reply.errmsg = strerror(errno);
-                       } else {
-                               reply.status = 0;
-                               reply.errmsg = NULL;
+       pid_found = false;
+       srvid_found = false;
+
+       for (client=ctdb->client_list; client != NULL; client=client->next) {
+               if (client->pid == request->rdata.data.pid_srvid->pid) {
+                       pid_found = true;
+                       cstate = (struct client_state *)client->state;
+                       ret = srvid_exists(ctdb->srv,
+                                          request->rdata.data.pid_srvid->srvid,
+                                          cstate);
+                       if (ret == 0) {
+                               srvid_found = true;
+                               ret = kill(cstate->pid, 0);
+                               if (ret != 0) {
+                                       reply.status = ret;
+                                       reply.errmsg = strerror(errno);
+                               } else {
+                                       reply.status = 0;
+                                       reply.errmsg = NULL;
+                               }
                        }
                }
        }
 
+       if (! pid_found) {
+               reply.status = -1;
+               reply.errmsg = "No client for PID";
+       } else if (! srvid_found) {
+               reply.status = -1;
+               reply.errmsg = "No client for PID and SRVID";
+       }
+
        client_send_control(req, header, &reply);
 }
 
diff --git a/ctdb/tests/tool/ctdb.process-exists.002.sh 
b/ctdb/tests/tool/ctdb.process-exists.003.sh
similarity index 77%
copy from ctdb/tests/tool/ctdb.process-exists.002.sh
copy to ctdb/tests/tool/ctdb.process-exists.003.sh
index fe3dfd4..bb1ef9a 100755
--- a/ctdb/tests/tool/ctdb.process-exists.002.sh
+++ b/ctdb/tests/tool/ctdb.process-exists.003.sh
@@ -2,7 +2,7 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "ctdbd process on node 0"
+define_test "ctdbd process with multiple connections on node 0"
 
 setup_ctdbd <<EOF
 NODEMAP
@@ -13,7 +13,7 @@ EOF
 
 srvid="0xaebbccdd12345678"
 
-dummy_client -d INFO -s "$ctdbd_socket" -S "$srvid" &
+dummy_client -d INFO -s "$ctdbd_socket" -n 10 -S "$srvid" &
 pid=$!
 
 srvid2="0x1234567812345678"


-- 
Samba Shared Repository

Reply via email to