The branch, master has been updated via 503bc39 ctdb-tests: Add tests for PID with srvid via 7d034fe ctdb-tests: Implement control CHECK_PID_SRVID in fake daemon via c480cc0 ctdb-tests: Reimplement message handlers using srvid abstraction via 1c472df ctdb-tool: Update process-exists command to pass optional srvid via c6a3520 ctdb-client: Add client code for control CHECK_PID_SRVID via 02ae3d9 ctdb-daemon: Add implementation of control CHECK_PID_SRVID via 7115378 ctdb-protocol: Add marshalling for control CHECK_PID_SRVID via 5d12006 ctdb-protocol: Add marshalling for struct ctdb_pid_srvid via e5b133a ctdb-protocol: Add new control CTDB_CONTROL_CHECK_PID_SRVID via e675f34 ctdb-common: Extend srvid_exists() check to support optional private_data from 30ffc12 testsuite: Fix the 32-bit test build
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 503bc3997800cfb2fd9f7f092ef896c355b844cd Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 16:35:49 2017 +1000 ctdb-tests: Add tests for PID with srvid BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> Autobuild-User(master): Martin Schwenke <mart...@samba.org> Autobuild-Date(master): Thu Sep 21 12:56:30 CEST 2017 on sn-devel-144 commit 7d034fe1399ecb7305c91e16e114a63c67f5a983 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 17:04:44 2017 +1000 ctdb-tests: Implement control CHECK_PID_SRVID in fake daemon BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit c480cc0152f3afc8ea81e2bc72c31deed1e0ca71 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 16:59:16 2017 +1000 ctdb-tests: Reimplement message handlers using srvid abstraction BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 This is required for CHECK_PID_SRVID control implementation. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 1c472dffd4d412806c2cb7202a8a5f37aac53b0f Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 16:29:01 2017 +1000 ctdb-tool: Update process-exists command to pass optional srvid BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit c6a35200f45b04e2e6f867743213f2d95eabef4f Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Sep 21 15:52:14 2017 +1000 ctdb-client: Add client code for control CHECK_PID_SRVID BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 02ae3d9fab6cdaaa1a2999a57a37ecc281f7f608 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 16:18:02 2017 +1000 ctdb-daemon: Add implementation of control CHECK_PID_SRVID BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 7115378f7534f79043ab1b5d2b8fb265145537aa Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 15:13:53 2017 +1000 ctdb-protocol: Add marshalling for control CHECK_PID_SRVID BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 5d12006e29a898c503a885115069fe26f2e084bc Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 15:13:12 2017 +1000 ctdb-protocol: Add marshalling for struct ctdb_pid_srvid BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit e5b133a127ff2a34689e679397bdd211fa2aada6 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 15:10:56 2017 +1000 ctdb-protocol: Add new control CTDB_CONTROL_CHECK_PID_SRVID BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit e675f346805de1754a6b18cf0dfbc71df9c7a05d Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Aug 30 13:27:12 2017 +1000 ctdb-common: Extend srvid_exists() check to support optional private_data BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> ----------------------------------------------------------------------- Summary of changes: ctdb/client/client_control_sync.c | 29 +++++++++ ctdb/client/client_sync.h | 5 ++ ctdb/common/srvid.c | 13 +++- ctdb/common/srvid.h | 8 ++- ctdb/doc/ctdb.1.xml | 8 ++- ctdb/include/ctdb_private.h | 2 + ctdb/protocol/protocol.h | 7 +++ ctdb/protocol/protocol_api.h | 5 ++ ctdb/protocol/protocol_client.c | 28 +++++++++ ctdb/protocol/protocol_control.c | 22 +++++++ ctdb/protocol/protocol_debug.c | 1 + ctdb/protocol/protocol_private.h | 6 ++ ctdb/protocol/protocol_types.c | 53 ++++++++++++++++ ctdb/server/ctdb_control.c | 4 ++ ctdb/server/ctdb_daemon.c | 24 +++++++ ctdb/tests/cunit/protocol_test_101.sh | 2 +- ctdb/tests/simple/07_ctdb_process_exists.sh | 20 +++++- ctdb/tests/src/fake_ctdbd.c | 97 +++++++++++++++++++---------- ctdb/tests/src/protocol_common.c | 13 ++++ ctdb/tests/src/protocol_common.h | 4 ++ ctdb/tests/src/protocol_common_ctdb.c | 13 ++++ ctdb/tests/src/protocol_ctdb_test.c | 2 +- ctdb/tests/src/protocol_types_test.c | 2 + ctdb/tests/src/srvid_test.c | 12 +++- ctdb/tests/tool/ctdb.process-exists.002.sh | 26 ++++++++ ctdb/tools/ctdb.c | 32 ++++++++-- 26 files changed, 389 insertions(+), 49 deletions(-) create mode 100755 ctdb/tests/tool/ctdb.process-exists.002.sh Changeset truncated at 500 lines: diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c index 343d15d..7ee9f1d 100644 --- a/ctdb/client/client_control_sync.c +++ b/ctdb/client/client_control_sync.c @@ -2631,3 +2631,32 @@ int ctdb_ctrl_db_attach_replicated(TALLOC_CTX *mem_ctx, return 0; } + +int ctdb_ctrl_check_pid_srvid(TALLOC_CTX *mem_ctx, struct tevent_context *ev, + struct ctdb_client_context *client, + int destnode, struct timeval timeout, + struct ctdb_pid_srvid *pid_srvid, int *status) +{ + struct ctdb_req_control request; + struct ctdb_reply_control *reply; + int ret; + + ctdb_req_control_check_pid_srvid(&request, pid_srvid); + ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout, + &request, &reply); + if (ret != 0) { + DEBUG(DEBUG_ERR, + ("Control CHECK_PID_SRVID failed to node %u, ret=%d\n", + destnode, ret)); + return ret; + } + + ret = ctdb_reply_control_check_pid_srvid(reply, status); + if (ret != 0) { + DEBUG(DEBUG_ERR, + ("Control CHECK_PID_SRVID failed, ret=%d\n", ret)); + return ret; + } + + return 0; +} diff --git a/ctdb/client/client_sync.h b/ctdb/client/client_sync.h index 99a886a..c07edf6 100644 --- a/ctdb/client/client_sync.h +++ b/ctdb/client/client_sync.h @@ -476,6 +476,11 @@ int ctdb_ctrl_db_attach_replicated(TALLOC_CTX *mem_ctx, int destnode, struct timeval timeout, const char *db_name, uint32_t *db_id); +int ctdb_ctrl_check_pid_srvid(TALLOC_CTX *mem_ctx, struct tevent_context *ev, + struct ctdb_client_context *client, + int destnode, struct timeval timeout, + struct ctdb_pid_srvid *pid_srvid, int *status); + /* from client/client_message_sync.c */ int ctdb_message_recd_update_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/ctdb/common/srvid.c b/ctdb/common/srvid.c index f9cd49b..3304994 100644 --- a/ctdb/common/srvid.c +++ b/ctdb/common/srvid.c @@ -221,9 +221,10 @@ int srvid_deregister(struct srvid_context *srv, uint64_t srvid, /* * Check if a message handler exists */ -int srvid_exists(struct srvid_context *srv, uint64_t srvid) +int srvid_exists(struct srvid_context *srv, uint64_t srvid, void *private_data) { struct srvid_handler_list *list; + struct srvid_handler *h; int ret; ret = srvid_fetch(srv, srvid, &list); @@ -234,6 +235,16 @@ int srvid_exists(struct srvid_context *srv, uint64_t srvid) return ENOENT; } + if (private_data != NULL) { + for (h = list->h; h != NULL; h = h->next) { + if (h->private_data == private_data) { + return 0; + } + } + + return ENOENT; + } + return 0; } diff --git a/ctdb/common/srvid.h b/ctdb/common/srvid.h index f048b5c..702724f 100644 --- a/ctdb/common/srvid.h +++ b/ctdb/common/srvid.h @@ -91,11 +91,17 @@ int srvid_deregister(struct srvid_context *srv, uint64_t srvid, /** * @brief Check if any message handler is registered for srvid * + * If private_data is NULL, then check if there is any registration + * for * specified srvid. If private_data is not NULL, then check for + * registration that matches the specified private data. + * * @param[in] srv The srvid message handler database context * @param[in] srvid The srvid + * @param[in] private_data Private data * @return 0 on success, errno on failure */ -int srvid_exists(struct srvid_context *srv, uint64_t srvid); +int srvid_exists(struct srvid_context *srv, uint64_t srvid, + void *private_data); /** * @brief Call message handlers for given srvid diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml index c1d8107..8dfca3b 100644 --- a/ctdb/doc/ctdb.1.xml +++ b/ctdb/doc/ctdb.1.xml @@ -1681,9 +1681,13 @@ RUNNING </refsect2> <refsect2> - <title>process-exists <parameter>PID</parameter></title> + <title>process-exists <parameter>PID</parameter> <parameter>[SRVID]</parameter></title> <para> - This command checks if a specific process exists on the CTDB host. This is mainly used by Samba to check if remote instances of samba are still running or not. + This command checks if a specific process exists on the CTDB + host. This is mainly used by Samba to check if remote instances + of samba are still running or not. When the optional SRVID + argument is specified, the command check if a specific process + exists on the CTDB host and has registered for specified SRVID. </para> </refsect2> diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 9be81ff..227d518 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -582,6 +582,8 @@ struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb, pid_t pid); 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); int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata); diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h index 3c57e20..ed5deb8 100644 --- a/ctdb/protocol/protocol.h +++ b/ctdb/protocol/protocol.h @@ -369,6 +369,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, CTDB_CONTROL_DB_PUSH_CONFIRM = 148, CTDB_CONTROL_DB_OPEN_FLAGS = 149, CTDB_CONTROL_DB_ATTACH_REPLICATED = 150, + CTDB_CONTROL_CHECK_PID_SRVID = 151, }; #define MAX_COUNT_BUCKETS 16 @@ -840,6 +841,11 @@ enum ctdb_runstate { CTDB_RUNSTATE_SHUTDOWN, }; +struct ctdb_pid_srvid { + pid_t pid; + uint64_t srvid; +}; + struct ctdb_req_control_data { uint32_t opcode; union { @@ -876,6 +882,7 @@ struct ctdb_req_control_data { struct ctdb_key_data *key; struct ctdb_traverse_start_ext *traverse_start_ext; struct ctdb_traverse_all_ext *traverse_all_ext; + struct ctdb_pid_srvid *pid_srvid; } data; }; diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h index 67f32a0b..e15bb97 100644 --- a/ctdb/protocol/protocol_api.h +++ b/ctdb/protocol/protocol_api.h @@ -596,6 +596,11 @@ void ctdb_req_control_db_attach_replicated(struct ctdb_req_control *request, int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply, uint32_t *db_id); +void ctdb_req_control_check_pid_srvid(struct ctdb_req_control *request, + struct ctdb_pid_srvid *pid_srvid); +int ctdb_reply_control_check_pid_srvid(struct ctdb_reply_control *reply, + int *status); + /* From protocol/protocol_debug.c */ void ctdb_packet_print(uint8_t *buf, size_t buflen, FILE *fp); diff --git a/ctdb/protocol/protocol_client.c b/ctdb/protocol/protocol_client.c index d750260..a741b11 100644 --- a/ctdb/protocol/protocol_client.c +++ b/ctdb/protocol/protocol_client.c @@ -2301,3 +2301,31 @@ int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply, } return reply->status; } + +/* CTDB_CONTROL_CHECK_PID_SRVID */ + +void ctdb_req_control_check_pid_srvid(struct ctdb_req_control *request, + struct ctdb_pid_srvid *pid_srvid) +{ + request->opcode = CTDB_CONTROL_CHECK_PID_SRVID; + request->pad = 0; + request->srvid = 0; + request->client_id = 0; + request->flags = 0; + + request->rdata.opcode = CTDB_CONTROL_CHECK_PID_SRVID; + request->rdata.data.pid_srvid = pid_srvid; +} + +int ctdb_reply_control_check_pid_srvid(struct ctdb_reply_control *reply, + int *status) +{ + if (reply->rdata.opcode != CTDB_CONTROL_CHECK_PID_SRVID) { + return EPROTO; + } + + *status = reply->status; + reply->status = 0; + + return reply->status; +} diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c index f76a1af..5abe037 100644 --- a/ctdb/protocol/protocol_control.c +++ b/ctdb/protocol/protocol_control.c @@ -416,6 +416,10 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd) case CTDB_CONTROL_DB_ATTACH_REPLICATED: len = ctdb_string_len(&cd->data.db_name); break; + + case CTDB_CONTROL_CHECK_PID_SRVID: + len = ctdb_pid_srvid_len(cd->data.pid_srvid); + break; } return len; @@ -697,6 +701,10 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd, case CTDB_CONTROL_DB_ATTACH_REPLICATED: ctdb_string_push(&cd->data.db_name, buf, &np); break; + + case CTDB_CONTROL_CHECK_PID_SRVID: + ctdb_pid_srvid_push(cd->data.pid_srvid, buf, &np); + break; } *npush = np; @@ -1027,6 +1035,11 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen, ret = ctdb_string_pull(buf, buflen, mem_ctx, &cd->data.db_name, &np); break; + + case CTDB_CONTROL_CHECK_PID_SRVID: + ret = ctdb_pid_srvid_pull(buf, buflen, mem_ctx, + &cd->data.pid_srvid, &np); + break; } if (ret != 0) { @@ -1400,6 +1413,9 @@ static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd) case CTDB_CONTROL_DB_ATTACH_REPLICATED: len = ctdb_uint32_len(&cd->data.db_id); break; + + case CTDB_CONTROL_CHECK_PID_SRVID: + break; } return len; @@ -1561,6 +1577,9 @@ static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd, case CTDB_CONTROL_DB_ATTACH_REPLICATED: ctdb_uint32_push(&cd->data.db_id, buf, &np); break; + + case CTDB_CONTROL_CHECK_PID_SRVID: + break; } *npush = np; @@ -1753,6 +1772,9 @@ static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen, case CTDB_CONTROL_DB_ATTACH_REPLICATED: ret = ctdb_uint32_pull(buf, buflen, &cd->data.db_id, &np); break; + + case CTDB_CONTROL_CHECK_PID_SRVID: + break; } if (ret != 0) { diff --git a/ctdb/protocol/protocol_debug.c b/ctdb/protocol/protocol_debug.c index 9cca76c..5a24d39 100644 --- a/ctdb/protocol/protocol_debug.c +++ b/ctdb/protocol/protocol_debug.c @@ -239,6 +239,7 @@ static void ctdb_opcode_print(uint32_t opcode, FILE *fp) { CTDB_CONTROL_DB_PUSH_CONFIRM, "DB_PUSH_CONFIRM" }, { CTDB_CONTROL_DB_OPEN_FLAGS, "DB_OPEN_FLAGS" }, { CTDB_CONTROL_DB_ATTACH_REPLICATED, "DB_ATTACH_REPLICATED" }, + { CTDB_CONTROL_CHECK_PID_SRVID, "CHECK_PID_SRVID" }, { MAP_END, "" }, }; diff --git a/ctdb/protocol/protocol_private.h b/ctdb/protocol/protocol_private.h index 9e3ae8d..c3fab3f 100644 --- a/ctdb/protocol/protocol_private.h +++ b/ctdb/protocol/protocol_private.h @@ -312,6 +312,12 @@ void ctdb_db_statistics_push(struct ctdb_db_statistics *in, uint8_t *buf, int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx, struct ctdb_db_statistics **out, size_t *npull); +size_t ctdb_pid_srvid_len(struct ctdb_pid_srvid *in); +void ctdb_pid_srvid_push(struct ctdb_pid_srvid *in, uint8_t *buf, + size_t *npush); +int ctdb_pid_srvid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx, + struct ctdb_pid_srvid **out, size_t *npull); + size_t ctdb_election_message_len(struct ctdb_election_message *in); void ctdb_election_message_push(struct ctdb_election_message *in, uint8_t *buf, size_t *npush); diff --git a/ctdb/protocol/protocol_types.c b/ctdb/protocol/protocol_types.c index 57ad07a..83d5d78 100644 --- a/ctdb/protocol/protocol_types.c +++ b/ctdb/protocol/protocol_types.c @@ -4704,6 +4704,59 @@ int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx, return 0; } +size_t ctdb_pid_srvid_len(struct ctdb_pid_srvid *in) +{ + return ctdb_pid_len(&in->pid) + + ctdb_uint64_len(&in->srvid); +} + +void ctdb_pid_srvid_push(struct ctdb_pid_srvid *in, uint8_t *buf, + size_t *npush) +{ + size_t offset = 0, np; + + ctdb_pid_push(&in->pid, buf+offset, &np); + offset += np; + + ctdb_uint64_push(&in->srvid, buf+offset, &np); + offset += np; + + *npush = offset; +} + +int ctdb_pid_srvid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx, + struct ctdb_pid_srvid **out, size_t *npull) +{ + struct ctdb_pid_srvid *val; + size_t offset = 0, np; + int ret; + + val = talloc(mem_ctx, struct ctdb_pid_srvid); + if (val == NULL) { + return ENOMEM; + } + + ret = ctdb_pid_pull(buf+offset, buflen-offset, &val->pid, &np); + if (ret != 0) { + goto fail; + } + offset += np; + + ret = ctdb_uint64_pull(buf+offset, buflen-offset, &val->srvid, &np); + if (ret != 0) { + goto fail; + } + offset += np; + + *out = val; + *npull = offset; + return 0; + +fail: + talloc_free(val); + return ret; +} + size_t ctdb_election_message_len(struct ctdb_election_message *in) { return ctdb_uint32_len(&in->num_connected) + diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 9f74011..9aeaa23 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -696,6 +696,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, return 0; } + case CTDB_CONTROL_CHECK_PID_SRVID: + CHECK_CONTROL_DATA_SIZE((sizeof(pid_t) + sizeof(uint64_t))); + return ctdb_control_check_pid_srvid(ctdb, indata); + default: DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode)); return -1; diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 8ae4351..90e8b71 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -1771,6 +1771,30 @@ int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid) return kill(pid, 0); } +int32_t ctdb_control_check_pid_srvid(struct ctdb_context *ctdb, + TDB_DATA indata) +{ + struct ctdb_client *client; + pid_t pid; + uint64_t srvid; + int ret; + + 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; + } + + return 0; +} + int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata) { struct ctdb_node_map_old *node_map = NULL; diff --git a/ctdb/tests/cunit/protocol_test_101.sh b/ctdb/tests/cunit/protocol_test_101.sh index 800c6b5..8813e18 100755 --- a/ctdb/tests/cunit/protocol_test_101.sh +++ b/ctdb/tests/cunit/protocol_test_101.sh @@ -2,7 +2,7 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -last_control=150 +last_control=151 generate_control_output () { diff --git a/ctdb/tests/simple/07_ctdb_process_exists.sh b/ctdb/tests/simple/07_ctdb_process_exists.sh index f24e93a..b3b8e51 100755 --- a/ctdb/tests/simple/07_ctdb_process_exists.sh +++ b/ctdb/tests/simple/07_ctdb_process_exists.sh @@ -36,11 +36,12 @@ set -e cluster_is_healthy test_node=1 +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 >/dev/null 2>&1 & echo \$!" + "$CTDB_TEST_WRAPPER exec dummy_client -S ${srvid} >/dev/null 2>&1 & echo \$!" client_pid="$out" cleanup () @@ -65,6 +66,23 @@ else testfailures=1 fi +echo "Checking for PID $client_pid with SRVID $srvid on node $test_node" +status=0 +try_command_on_node $test_node \ + "$CTDB process-exists ${client_pid} ${srvid}" || status=$? +echo "$out" + +if [ $status -eq 0 ] ; then + echo "OK" +else + echo "BAD" + testfailures=1 +fi + +echo "Checking for PID $client_pid with SRVID $client_pid on node $test_node" +try_command_on_node -v $test_node \ + "! $CTDB process-exists ${client_pid} ${client_pid}" + # Now just echo the PID of the ctdb daemon on test node. # This is not a ctdb client and process-exists should return error. try_command_on_node $test_node "ctdb getpid" diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c index 4d51dc5..8b3a0c4 100644 --- a/ctdb/tests/src/fake_ctdbd.c +++ b/ctdb/tests/src/fake_ctdbd.c @@ -40,6 +40,7 @@ #include "common/system.h" #include "common/logging.h" #include "common/tunable.h" -- Samba Shared Repository