1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ctdb-tests: Update fetch_ring to take database and key on command line

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2020-05-04 16:58:38 +10:00 committed by Amitay Isaacs
parent 53b73b9b0f
commit fb38252677
2 changed files with 21 additions and 12 deletions

View File

@ -23,7 +23,8 @@ try_command_on_node 0 "$CTDB listnodes | wc -l"
num_nodes="$out"
echo "Running fetch_ring on all $num_nodes nodes."
try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND fetch_ring -n $num_nodes
testprog_onnode -v -p all \
fetch_ring -n "$num_nodes" -D "fetch_ring.tdb" -k "testkey"
pat='^(Waiting for cluster|Fetch\[[[:digit:]]+\]: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec)$'
sanity_check_output 1 "$pat"

View File

@ -28,9 +28,6 @@
#include "tests/src/test_options.h"
#include "tests/src/cluster_wait.h"
#define TESTDB "fetch_ring.tdb"
#define TESTKEY "testkey"
#define MSG_ID_FETCH 0
static uint32_t next_node(struct ctdb_client_context *client, uint32_t num_nodes)
@ -63,7 +60,9 @@ static struct tevent_req *fetch_ring_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
struct ctdb_db_context *ctdb_db,
uint32_t num_nodes, int timelimit,
const char *keystr,
uint32_t num_nodes,
int timelimit,
int interactive)
{
struct tevent_req *req, *subreq;
@ -80,8 +79,8 @@ static struct tevent_req *fetch_ring_send(TALLOC_CTX *mem_ctx,
state->num_nodes = num_nodes;
state->timelimit = timelimit;
state->interactive = interactive;
state->key.dptr = discard_const(TESTKEY);
state->key.dsize = strlen(TESTKEY);
state->key.dptr = discard_const(keystr);
state->key.dsize = strlen(keystr);
subreq = ctdb_client_set_message_handler_send(
state, ev, client, MSG_ID_FETCH,
@ -334,7 +333,7 @@ int main(int argc, const char *argv[])
setup_logging("fetch_ring", DEBUG_STDERR);
status = process_options_basic(argc, argv, &opts);
status = process_options_database(argc, argv, &opts);
if (! status) {
exit(1);
}
@ -362,15 +361,24 @@ int main(int argc, const char *argv[])
exit(1);
}
ret = ctdb_attach(ev, client, tevent_timeval_zero(), TESTDB, 0,
ret = ctdb_attach(ev,
client,
tevent_timeval_zero(),
opts->dbname,
0,
&ctdb_db);
if (ret != 0) {
fprintf(stderr, "Failed to attach to DB %s\n", TESTDB);
fprintf(stderr, "Failed to attach to DB %s\n", opts->dbname);
exit(1);
}
req = fetch_ring_send(mem_ctx, ev, client, ctdb_db,
opts->num_nodes, opts->timelimit,
req = fetch_ring_send(mem_ctx,
ev,
client,
ctdb_db,
opts->keystr,
opts->num_nodes,
opts->timelimit,
opts->interactive);
if (req == NULL) {
fprintf(stderr, "Memory allocation error\n");