summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-08-02 15:00:54 +1000
committerStefan Metzmacher <metze@samba.org>2016-08-10 11:24:35 +0200
commit106e572077a548f07d7337c6a8337392a92e4307 (patch)
tree6e91a6937b756af453fc2150f718a57c46616a44
parent21cbbb19c2193819a024026ca2b985671d78cc93 (diff)
downloadsamba-106e572077a548f07d7337c6a8337392a92e4307.tar.gz
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 <amitay@gmail.com> Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit 18b41fcb51942ebcd4041fe3e3694712a5a5e43a)
-rw-r--r--ctdb/tests/src/transaction_loop.c19
1 files changed, 13 insertions, 6 deletions
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; i<state->num_nodes; i++) {
- printf("%6u ", state->counter[i]);
+ if (state->interactive == 1) {
+ printf("Transaction[%u]: ", ctdb_client_pnn(state->client));
+ for (i=0; i<state->num_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; i<state->num_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);