mdbx-test: add --geometry-jitter=YES|no option.

This commit is contained in:
Leonid Yuriev 2022-01-20 23:38:27 +03:00
parent e1bcdb8e9a
commit 981b10d10a
5 changed files with 69 additions and 44 deletions

View File

@ -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, '|');

View File

@ -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();

View File

@ -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

View File

@ -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);

View File

@ -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 */