summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-09-22 14:14:00 +1000
committerKarolin Seeger <kseeger@samba.org>2017-10-25 08:43:04 +0200
commit8455844f6a5fd575f46a098ffde0f364a8f238b8 (patch)
tree010d2eaffd135eb28980303e2b88ddf27fdf2d95 /ctdb
parentf007f3c5faf967b48a41e203abaad93c39841323 (diff)
downloadsamba-8455844f6a5fd575f46a098ffde0f364a8f238b8.tar.gz
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 <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> (cherry picked from commit 90f7e06c2553a13779dd24739aeefea96f55ba3e)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/tests/src/dummy_client.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/ctdb/tests/src/dummy_client.c b/ctdb/tests/src/dummy_client.c
index 6af41f3b1f9..6f30512ee65 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);
}