mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
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>
This commit is contained in:
parent
6ed2ed7e2d
commit
90f7e06c25
@ -31,6 +31,7 @@
|
|||||||
static struct {
|
static struct {
|
||||||
const char *sockpath;
|
const char *sockpath;
|
||||||
const char *debuglevel;
|
const char *debuglevel;
|
||||||
|
int num_connections;
|
||||||
int timelimit;
|
int timelimit;
|
||||||
const char *srvidstr;
|
const char *srvidstr;
|
||||||
} options;
|
} options;
|
||||||
@ -41,6 +42,8 @@ static struct poptOption cmdline_options[] = {
|
|||||||
"Unix domain socket path", "filename" },
|
"Unix domain socket path", "filename" },
|
||||||
{ "debug", 'd', POPT_ARG_STRING, &options.debuglevel, 0,
|
{ "debug", 'd', POPT_ARG_STRING, &options.debuglevel, 0,
|
||||||
"debug level", "ERR|WARNING|NOTICE|INFO|DEBUG" } ,
|
"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,
|
{ "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0,
|
||||||
"time limit", "seconds" },
|
"time limit", "seconds" },
|
||||||
{ "srvid", 'S', POPT_ARG_STRING, &options.srvidstr, 0,
|
{ "srvid", 'S', POPT_ARG_STRING, &options.srvidstr, 0,
|
||||||
@ -59,16 +62,18 @@ int main(int argc, const char *argv[])
|
|||||||
{
|
{
|
||||||
TALLOC_CTX *mem_ctx;
|
TALLOC_CTX *mem_ctx;
|
||||||
struct tevent_context *ev;
|
struct tevent_context *ev;
|
||||||
struct ctdb_client_context *client;
|
struct ctdb_client_context **client;
|
||||||
|
struct ctdb_client_context *last_client;
|
||||||
const char *ctdb_socket;
|
const char *ctdb_socket;
|
||||||
poptContext pc;
|
poptContext pc;
|
||||||
int opt, ret;
|
int opt, ret, i;
|
||||||
int log_level;
|
int log_level;
|
||||||
bool status, done;
|
bool status, done;
|
||||||
|
|
||||||
/* Set default options */
|
/* Set default options */
|
||||||
options.sockpath = CTDB_SOCKET;
|
options.sockpath = CTDB_SOCKET;
|
||||||
options.debuglevel = "ERR";
|
options.debuglevel = "ERR";
|
||||||
|
options.num_connections = 1;
|
||||||
options.timelimit = 60;
|
options.timelimit = 60;
|
||||||
options.srvidstr = NULL;
|
options.srvidstr = NULL;
|
||||||
|
|
||||||
@ -112,19 +117,32 @@ int main(int argc, const char *argv[])
|
|||||||
setup_logging("dummy_client", DEBUG_STDERR);
|
setup_logging("dummy_client", DEBUG_STDERR);
|
||||||
DEBUGLEVEL = log_level;
|
DEBUGLEVEL = log_level;
|
||||||
|
|
||||||
ret = ctdb_client_init(mem_ctx, ev, options.sockpath, &client);
|
client = talloc_array(mem_ctx, struct ctdb_client_context *,
|
||||||
if (ret != 0) {
|
options.num_connections);
|
||||||
D_ERR("Failed to initialize client, ret=%d\n", ret);
|
if (client == NULL) {
|
||||||
|
fprintf(stderr, "Memory allocation error\n");
|
||||||
exit(1);
|
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;
|
done = false;
|
||||||
if (options.srvidstr != NULL) {
|
if (options.srvidstr != NULL) {
|
||||||
uint64_t srvid;
|
uint64_t srvid;
|
||||||
|
|
||||||
srvid = strtoull(options.srvidstr, NULL, 0);
|
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);
|
dummy_handler, &done);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
D_ERR("Failed to register srvid, ret=%d\n", ret);
|
D_ERR("Failed to register srvid, ret=%d\n", ret);
|
||||||
@ -143,6 +161,6 @@ int main(int argc, const char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
talloc_free(client);
|
talloc_free(mem_ctx);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user