From 981b10d10a6d32710b9e4c5095773e6bac2b09a3 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Thu, 20 Jan 2022 23:38:27 +0300 Subject: [PATCH] mdbx-test: add `--geometry-jitter=YES|no` option. --- test/config.cc | 9 ++++++- test/jitter.cc | 42 +++++++++++++++++++-------------- test/long_stochastic.sh | 9 +++++-- test/main.cc | 52 +++++++++++++++++++++++------------------ test/test.h | 1 + 5 files changed, 69 insertions(+), 44 deletions(-) diff --git a/test/config.cc b/test/config.cc index 5c797620..9db481fd 100644 --- a/test/config.cc +++ b/test/config.cc @@ -447,6 +447,8 @@ void dump(const char *title) { global::config::progress_indicator ? "Yes" : "No"); log_verbose("console mode: %s\n", global::config::console_mode ? "Yes" : "No"); + log_verbose("geometry jitter: %s\n", + global::config::geometry_jitter ? "Yes" : "No"); } } /* namespace config */ @@ -501,6 +503,8 @@ const std::string actor_config::serialize(const char *prefix) const { checksum.push(global::config::progress_indicator); result.push_back(global::config::console_mode ? 'Y' : 'N'); checksum.push(global::config::console_mode); + result.push_back(global::config::geometry_jitter ? 'Y' : 'N'); + checksum.push(global::config::geometry_jitter); result.push_back('|'); result.append(osal_serialize(checksum)); @@ -578,11 +582,14 @@ bool actor_config::deserialize(const char *str, actor_config &config) { TRACE("<< actor_config::deserialize: slash-5\n"); return false; } - if ((str[0] == 'Y' || str[0] == 'N') && (str[1] == 'Y' || str[1] == 'N')) { + if ((str[0] == 'Y' || str[0] == 'N') && (str[1] == 'Y' || str[1] == 'N') && + (str[2] == 'Y' || str[2] == 'N')) { global::config::progress_indicator = str[0] == 'Y'; checksum.push(global::config::progress_indicator); global::config::console_mode = str[1] == 'Y'; checksum.push(global::config::console_mode); + global::config::geometry_jitter = str[2] != 'N'; + checksum.push(global::config::geometry_jitter); str = slash + 1; slash = strchr(str, '|'); diff --git a/test/jitter.cc b/test/jitter.cc index 1c2b9f5e..10519f00 100644 --- a/test/jitter.cc +++ b/test/jitter.cc @@ -110,21 +110,25 @@ bool testcase_jitter::run() { if (!mode_readonly()) { fetch_canary(); update_canary(1); - err = mdbx_env_set_geometry( - db_guard.get(), -1, -1, - coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1); - if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE && - err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) - failure_perror("mdbx_env_set_geometry-1", err); + if (global::config::geometry_jitter) { + err = mdbx_env_set_geometry( + db_guard.get(), -1, -1, + coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1); + if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE && + err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) + failure_perror("mdbx_env_set_geometry-1", err); + } } txn_end(flipcoin()); - err = mdbx_env_set_geometry( - db_guard.get(), -1, -1, - !coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1); - if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE && - err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) - failure_perror("mdbx_env_set_geometry-2", err); + if (global::config::geometry_jitter) { + err = mdbx_env_set_geometry( + db_guard.get(), -1, -1, + !coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1); + if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE && + err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) + failure_perror("mdbx_env_set_geometry-2", err); + } if (flipcoin()) { jitter_delay(); @@ -133,12 +137,14 @@ bool testcase_jitter::run() { txn_end(flipcoin()); } - jitter_delay(); - err = - mdbx_env_set_geometry(db_guard.get(), -1, -1, upper_limit, -1, -1, -1); - if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE && - err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) - failure_perror("mdbx_env_set_geometry-3", err); + if (global::config::geometry_jitter) { + jitter_delay(); + err = mdbx_env_set_geometry(db_guard.get(), -1, -1, upper_limit, -1, -1, + -1); + if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE && + err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) + failure_perror("mdbx_env_set_geometry-3", err); + } db_close(); diff --git a/test/long_stochastic.sh b/test/long_stochastic.sh index 996cd310..8c2a3d1c 100755 --- a/test/long_stochastic.sh +++ b/test/long_stochastic.sh @@ -10,6 +10,7 @@ UPTO=9999999 MONITOR= LOOPS= SKIP_MAKE=no +GEOMETRY_JITTER=yes BANNER="$(which banner 2>/dev/null | echo echo)" UNAME="$(uname -s 2>/dev/null || echo Unknown)" DB_UPTO_MB=17408 @@ -27,6 +28,7 @@ do echo "--loops NN Stop after the NN loops" echo "--dir PATH Specifies directory for test DB and other files (it will be cleared)" echo "--db-upto-mb NN Limits upper size of test DB to the NN megabytes" + echo "--no-geometry-jitter Disable jitter for geometry upper-size" echo "--help Print this usage help and exit" exit -2 ;; @@ -88,6 +90,9 @@ do fi shift ;; + --no-geometry-jitter) + GEOMETRY_JITTER=no + ;; *) echo "Unknown option '$1'" exit -2 @@ -296,8 +301,8 @@ function probe { rm -f ${TESTDB_DIR}/* || failed for case in $LIST do - echo "Run ./mdbx_test ${speculum} --random-writemap=no --ignore-dbfull --repeat=11 --pathname=${TESTDB_DIR}/long.db --cleanup-after=no $@ $case" - ${MONITOR} ./mdbx_test ${speculum} --random-writemap=no --ignore-dbfull --repeat=11 --pathname=${TESTDB_DIR}/long.db --cleanup-after=no "$@" $case | check_deep \ + echo "Run ./mdbx_test ${speculum} --random-writemap=no --ignore-dbfull --repeat=11 --pathname=${TESTDB_DIR}/long.db --cleanup-after=no --geometry-jitter=${GEOMETRY_JITTER} $@ $case" + ${MONITOR} ./mdbx_test ${speculum} --random-writemap=no --ignore-dbfull --repeat=11 --pathname=${TESTDB_DIR}/long.db --cleanup-after=no --geometry-jitter=${GEOMETRY_JITTER} "$@" $case | check_deep \ && ${MONITOR} ./mdbx_chk ${TESTDB_DIR}/long.db | tee ${TESTDB_DIR}/long-chk.log \ && ([ ! -e ${TESTDB_DIR}/long.db-copy ] || ${MONITOR} ./mdbx_chk ${TESTDB_DIR}/long.db-copy | tee ${TESTDB_DIR}/long-chk-copy.log) \ || failed diff --git a/test/main.cc b/test/main.cc index ef2cf782..17825a19 100644 --- a/test/main.cc +++ b/test/main.cc @@ -73,6 +73,7 @@ MDBX_NORETURN void usage(void) { " --ignore-dbfull[=yes|NO] Ignore MDBX_MAP_FULL error\n" " --speculum[=yes|NO] Use internal `speculum` to check " "dataset\n" + " --geometry-jitter[=YES|no] Use jitter for geometry upper-limit\n" "Keys and Value:\n" " --keylen.min=N Minimal keys length\n" " --keylen.max=N Miximal keys length\n" @@ -181,6 +182,7 @@ void actor_params::set_defaults(const std::string &tmpdir) { global::config::failfast = true; global::config::progress_indicator = true; global::config::console_mode = osal_istty(STDERR_FILENO); + global::config::geometry_jitter = true; } namespace global { @@ -202,6 +204,7 @@ bool cleanup_after; bool failfast; bool progress_indicator; bool console_mode; +bool geometry_jitter; } /* namespace config */ } /* namespace global */ @@ -290,8 +293,33 @@ int main(int argc, char *const argv[]) { unsigned last_space_id = 0; for (int narg = 1; narg < argc; ++narg) { - const char *value = nullptr; + if (config::parse_option(argc, argv, narg, "dump-config", + global::config::dump_config)) + continue; + if (config::parse_option(argc, argv, narg, "cleanup-before", + global::config::cleanup_before)) + continue; + if (config::parse_option(argc, argv, narg, "cleanup-after", + global::config::cleanup_after)) + continue; + if (config::parse_option(argc, argv, narg, "failfast", + global::config::failfast)) + continue; + if (config::parse_option(argc, argv, narg, "progress", + global::config::progress_indicator)) + continue; + if (config::parse_option(argc, argv, narg, "console", + global::config::console_mode)) + continue; + if (config::parse_option(argc, argv, narg, "geometry-jitter", + global::config::geometry_jitter)) + continue; + if (config::parse_option(argc, argv, narg, "timeout", + global::config::timeout_duration_seconds, + config::duration, 1)) + continue; + const char *value = nullptr; if (config::parse_option(argc, argv, narg, "case", &value)) { fixup4qemu(params); testcase_setup(value, params, last_space_id); @@ -357,10 +385,6 @@ int main(int argc, char *const argv[]) { if (config::parse_option(argc, argv, narg, "threads", params.nthreads, config::no_scale, 1, 64)) continue; - if (config::parse_option(argc, argv, narg, "timeout", - global::config::timeout_duration_seconds, - config::duration, 1)) - continue; if (config::parse_option_intptr(argc, argv, narg, "size-lower", params.size_lower, @@ -491,15 +515,6 @@ int main(int argc, char *const argv[]) { continue; if (config::parse_option(argc, argv, narg, "speculum", params.speculum)) continue; - if (config::parse_option(argc, argv, narg, "dump-config", - global::config::dump_config)) - continue; - if (config::parse_option(argc, argv, narg, "cleanup-before", - global::config::cleanup_before)) - continue; - if (config::parse_option(argc, argv, narg, "cleanup-after", - global::config::cleanup_after)) - continue; if (config::parse_option(argc, argv, narg, "max-readers", params.max_readers, config::no_scale, 1, 255)) continue; @@ -570,15 +585,6 @@ int main(int argc, char *const argv[]) { configure_actor(last_space_id, ac_nested, value, params); continue; } - if (config::parse_option(argc, argv, narg, "failfast", - global::config::failfast)) - continue; - if (config::parse_option(argc, argv, narg, "progress", - global::config::progress_indicator)) - continue; - if (config::parse_option(argc, argv, narg, "console", - global::config::console_mode)) - continue; if (*argv[narg] != '-') { fixup4qemu(params); diff --git a/test/test.h b/test/test.h index fa816c28..aa80d56c 100644 --- a/test/test.h +++ b/test/test.h @@ -68,6 +68,7 @@ extern bool cleanup_after; extern bool failfast; extern bool progress_indicator; extern bool console_mode; +extern bool geometry_jitter; } /* namespace config */ } /* namespace global */