From: John Mulligan Date: Wed, 31 Jul 2024 20:29:44 +0000 (-0400) Subject: ctdb-tests: add USENODESCOMMAND directive to fake ctdb X-Git-Tag: tdb-1.4.12~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a5b743c436216f05926fabfec4a23be7f782b94;p=thirdparty%2Fsamba.git ctdb-tests: add USENODESCOMMAND directive to fake ctdb Add a single line USENODESCOMMAND directive to the fake ctdb in order to enable use of a nodes script instead of a nodes file. For simplicity the fake ctdb always uses `nodes.sh` in the CTDB_BASE. Signed-off-by: John Mulligan Reviewed-by: Martin Schwenke --- diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c index cceba225bb9..f50604d134e 100644 --- a/ctdb/tests/src/fake_ctdbd.c +++ b/ctdb/tests/src/fake_ctdbd.c @@ -286,14 +286,23 @@ fail: } +static bool use_nodes_command; + static struct ctdb_node_map *read_nodes_file(TALLOC_CTX *mem_ctx, uint32_t pnn) { struct ctdb_node_map *nodemap; char nodes_list[PATH_MAX]; const char *ctdb_base; + const char *per_node_template = "%s/nodes.%d"; + const char *node_template = "%s/nodes"; int num; + if (use_nodes_command) { + per_node_template = "!%s/nodes.sh %d"; + node_template = "!%s/nodes.sh"; + } + ctdb_base = getenv("CTDB_BASE"); if (ctdb_base == NULL) { D_ERR("CTDB_BASE is not set\n"); @@ -302,7 +311,7 @@ static struct ctdb_node_map *read_nodes_file(TALLOC_CTX *mem_ctx, /* read optional node-specific nodes file */ num = snprintf(nodes_list, sizeof(nodes_list), - "%s/nodes.%d", ctdb_base, pnn); + per_node_template, ctdb_base, pnn); if (num == sizeof(nodes_list)) { D_ERR("nodes file path too long\n"); return NULL; @@ -321,7 +330,7 @@ static struct ctdb_node_map *read_nodes_file(TALLOC_CTX *mem_ctx, } /* read normal nodes file */ - num = snprintf(nodes_list, sizeof(nodes_list), "%s/nodes", ctdb_base); + num = snprintf(nodes_list, sizeof(nodes_list), node_template, ctdb_base); if (num == sizeof(nodes_list)) { D_ERR("nodes file path too long\n"); return NULL; @@ -1229,6 +1238,10 @@ static struct ctdbd_context *ctdbd_setup(TALLOC_CTX *mem_ctx, status = control_failures_parse(ctdb); } else if (strcmp(line, "RUNSTATE") == 0) { status = runstate_parse(ctdb); + } else if (strcmp(line, "USENODESCOMMAND") == 0) { + fprintf(stderr, "Using nodes command\n"); + use_nodes_command = true; + status = true; } else { fprintf(stderr, "Unknown line %s\n", line); status = false;