summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2022-09-26 08:27:15 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-25 23:02:16 +0000
commit9992580ec57ad678e59a21a564389ba66e5594e9 (patch)
treed0cf9d9256e1f5f7ccb0a20a850740731f7aa2f0
parenteb7e2ad19725cbf2a3024e1e4362535509a3491a (diff)
downloadmongo-9992580ec57ad678e59a21a564389ba66e5594e9.tar.gz
Import wiredtiger: 06926a917a9c92cc7407612d0638397a51cc8e44 from branch mongodb-master
ref: 7739da50a2..06926a917a for: 6.2.0-rc0 WT-9739 test tiered: test_util command line parsing (#8285)
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/test/utility/misc.c8
-rw-r--r--src/third_party/wiredtiger/test/utility/parse_opts.c85
-rw-r--r--src/third_party/wiredtiger/test/utility/test_util.h12
4 files changed, 98 insertions, 9 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 9da754bc186..042ed27ae7a 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "7739da50a2c6a51a044915e01bf20cd33bc28eef"
+ "commit": "06926a917a9c92cc7407612d0638397a51cc8e44"
}
diff --git a/src/third_party/wiredtiger/test/utility/misc.c b/src/third_party/wiredtiger/test/utility/misc.c
index ea808e14c41..ac7f2252540 100644
--- a/src/third_party/wiredtiger/test/utility/misc.c
+++ b/src/third_party/wiredtiger/test/utility/misc.c
@@ -207,6 +207,7 @@ testutil_progress(TEST_OPTS *opts, const char *message)
void
testutil_cleanup(TEST_OPTS *opts)
{
+ int i;
if (opts->conn != NULL)
testutil_check(opts->conn->close(opts->conn, NULL));
@@ -220,6 +221,13 @@ testutil_cleanup(TEST_OPTS *opts)
free(opts->progress_file_name);
free(opts->home);
free(opts->build_dir);
+ if (opts->tiered_storage) {
+ for (i = 0; i <= opts->nargc; ++i)
+ free(opts->nargv[i]);
+ free(opts->nargv);
+ }
+ if (opts->tiered_storage_source != NULL)
+ free(opts->tiered_storage_source);
}
/*
diff --git a/src/third_party/wiredtiger/test/utility/parse_opts.c b/src/third_party/wiredtiger/test/utility/parse_opts.c
index 98eabe89b7e..d87b89c7666 100644
--- a/src/third_party/wiredtiger/test/utility/parse_opts.c
+++ b/src/third_party/wiredtiger/test/utility/parse_opts.c
@@ -26,10 +26,80 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "test_util.h"
+#define DIR_STORE "dir_store"
extern char *__wt_optarg; /* argument associated with option */
/*
+ * parse_tiered_opts --
+ * Parse command line options for the tiered storage configurations.
+ */
+static inline void
+parse_tiered_opts(int argc, char *const *argv, TEST_OPTS *opts)
+{
+ int index, i;
+ int number_of_tiered_options;
+
+ number_of_tiered_options = 0;
+ index = 0;
+ opts->tiered_storage = false;
+ opts->tiered_storage_source = NULL;
+
+ for (i = 1; i < argc; i++) {
+ /* Tiered storage command line options starts with -P. */
+ if (strstr(argv[i], "-P")) {
+ /* Many more options to come here. */
+ if (argv[i][2] == 'o') {
+ if (argv[i + 1] == NULL)
+ testutil_die(
+ EINVAL, "%s option requires an argument %s", opts->progname, argv[i]);
+ number_of_tiered_options += 2;
+ } else if (argv[i][2] == 'T') {
+ /* This parsing is different because -PT does not accept any arguments. */
+ ++number_of_tiered_options;
+ opts->tiered_storage = true;
+ }
+ }
+ }
+
+ /* Return from here if tiered arguments are not passed. */
+ if (!opts->tiered_storage) {
+ if (number_of_tiered_options == 0)
+ return;
+ else
+ testutil_die(
+ EINVAL, "Error - Tiered storage command line arguments are passed without -PT.");
+ }
+
+ opts->nargc = argc - number_of_tiered_options;
+
+ /* Allocate the memory for the new argv without tiered options. */
+ opts->nargv = dmalloc(((size_t)opts->nargc + 1) * sizeof(char *));
+
+ /* Copy other command line arguments except tiered. */
+ for (i = 0; i < argc; ++i) {
+ if (strcmp(argv[i], "-Po") == 0) {
+ opts->tiered_storage_source = dstrdup(argv[i + 1]);
+ /* Move the index because this option has an argument. */
+ i++;
+ } else if (strcmp(argv[i], "-PT") == 0)
+ continue;
+ else
+ opts->nargv[index++] = dstrdup(argv[i]);
+ }
+
+ testutil_assert(index == opts->nargc);
+ /*
+ * Allocating an extra empty space at the end of the new argv just to replicate the system argv
+ * implementation.
+ */
+ opts->nargv[index++] = dstrdup("");
+
+ if (opts->tiered_storage_source == NULL)
+ opts->tiered_storage_source = dstrdup(DIR_STORE);
+}
+
+/*
* testutil_parse_opts --
* Parse command line options for a test case.
*/
@@ -39,6 +109,8 @@ testutil_parse_opts(int argc, char *const *argv, TEST_OPTS *opts)
size_t len;
int ch;
+ opts->nargc = 0;
+ opts->nargv = NULL;
opts->do_data_ops = false;
opts->preserve = false;
opts->running = true;
@@ -49,14 +121,19 @@ testutil_parse_opts(int argc, char *const *argv, TEST_OPTS *opts)
testutil_print_command_line(argc, argv);
- while ((ch = __wt_getopt(opts->progname, argc, argv, "A:Bb:dh:n:o:pR:T:t:vW:")) != EOF)
+ parse_tiered_opts(argc, argv, opts);
+
+ if (!opts->tiered_storage) {
+ opts->nargv = (char **)argv;
+ opts->nargc = argc;
+ }
+
+ while (
+ (ch = __wt_getopt(opts->progname, opts->nargc, opts->nargv, "A:b:dh:n:o:pR:T:t:vW:")) != EOF)
switch (ch) {
case 'A': /* Number of append threads */
opts->n_append_threads = (uint64_t)atoll(__wt_optarg);
break;
- case 'B': /* Use tiered storage objects and buckets. */
- opts->tiered = true;
- break;
case 'b': /* Build directory */
opts->build_dir = dstrdup(__wt_optarg);
break;
diff --git a/src/third_party/wiredtiger/test/utility/test_util.h b/src/third_party/wiredtiger/test/utility/test_util.h
index c22770ce5e7..7b255d233d0 100644
--- a/src/third_party/wiredtiger/test/utility/test_util.h
+++ b/src/third_party/wiredtiger/test/utility/test_util.h
@@ -52,9 +52,13 @@
/* Generic option parsing structure shared by all test cases. */
typedef struct {
char *home;
- const char *argv0; /* Exec name */
- const char *progname; /* Truncated program name */
- char *build_dir; /* Build directory path */
+ const char *argv0; /* Exec name */
+ char **nargv; /* New argument vector */
+ int nargc; /* New argument count */
+
+ const char *progname; /* Truncated program name */
+ char *build_dir; /* Build directory path */
+ char *tiered_storage_source; /* Tiered storage source */
enum {
TABLE_COL = 1, /* Fixed-length column store */
@@ -67,7 +71,7 @@ typedef struct {
bool do_data_ops; /* Have schema ops use data */
bool preserve; /* Don't remove files on exit */
- bool tiered; /* Configure tiered storage */
+ bool tiered_storage; /* Configure tiered storage */
bool verbose; /* Run in verbose mode */
uint64_t nrecords; /* Number of records */
uint64_t nops; /* Number of operations */