From: Martin Schwenke Date: Tue, 2 Aug 2016 05:00:54 +0000 (+1000) Subject: ctdb-tests: Implement --interactive/-i option in transaction_loop X-Git-Tag: tevent-0.9.30~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18b41fcb51942ebcd4041fe3e3694712a5a5e43a;p=thirdparty%2Fsamba.git ctdb-tests: Implement --interactive/-i option in transaction_loop Also add PNNs to output. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12109 Pair-programmed-with: Amitay Isaacs Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/src/transaction_loop.c b/ctdb/tests/src/transaction_loop.c index 660270c1699..3b325fd384d 100644 --- a/ctdb/tests/src/transaction_loop.c +++ b/ctdb/tests/src/transaction_loop.c @@ -36,6 +36,7 @@ struct transaction_loop_state { struct ctdb_db_context *ctdb_db; int num_nodes; int timelimit; + int interactive; TDB_DATA key; uint32_t pnn; struct ctdb_transaction_handle *h; @@ -55,7 +56,7 @@ static struct tevent_req *transaction_loop_send( struct tevent_context *ev, struct ctdb_client_context *client, struct ctdb_db_context *ctdb_db, - int num_nodes, int timelimit) + int num_nodes, int timelimit, int interactive) { struct tevent_req *req, *subreq; struct transaction_loop_state *state; @@ -71,6 +72,7 @@ static struct tevent_req *transaction_loop_send( state->ctdb_db = ctdb_db; state->num_nodes = num_nodes; state->timelimit = timelimit; + state->interactive = interactive; state->key.dptr = discard_const(TESTKEY); state->key.dsize = strlen(TESTKEY); state->pnn = ctdb_client_pnn(client); @@ -248,11 +250,14 @@ static void transaction_loop_each_second(struct tevent_req *subreq) return; } - for (i=0; inum_nodes; i++) { - printf("%6u ", state->counter[i]); + if (state->interactive == 1) { + printf("Transaction[%u]: ", ctdb_client_pnn(state->client)); + for (i=0; inum_nodes; i++) { + printf("%6u ", state->counter[i]); + } + printf("\n"); + fflush(stdout); } - printf("\n"); - fflush(stdout); subreq = tevent_wakeup_send(state, state->ev, tevent_timeval_current_ofs(1, 0)); @@ -304,6 +309,7 @@ static void transaction_loop_finish(struct tevent_req *subreq) return; } + printf("Transaction[%u]: ", ctdb_client_pnn(state->client)); for (i=0; inum_nodes; i++) { printf("%6u ", state->counter[i]); } @@ -373,7 +379,8 @@ int main(int argc, const char *argv[]) } req = transaction_loop_send(mem_ctx, ev, client, ctdb_db, - opts->num_nodes, opts->timelimit); + opts->num_nodes, opts->timelimit, + opts->interactive); if (req == NULL) { fprintf(stderr, "Memory allocation error\n"); exit(1);