summaryrefslogtreecommitdiff
path: root/pytests
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2018-08-10 10:30:32 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2018-08-10 10:30:32 -0400
commite89b80e6e56d8a049fe076954346391cec5bda4b (patch)
treefd9ad4078a109e56e27d1304929884e6ac918361 /pytests
parent073e9af2911b55850157b6a0d6be3543814c2bc7 (diff)
downloadmongo-e89b80e6e56d8a049fe076954346391cec5bda4b.tar.gz
Revert "Revert "SERVER-33695 Include the loop name in the before and after recovery files in powertest.py""
This reverts commit b16e6049b06c21a2a67141c20d30d4eb9933d782.
Diffstat (limited to 'pytests')
-rwxr-xr-xpytests/powertest.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/pytests/powertest.py b/pytests/powertest.py
index 136092a1376..d851f387fd3 100755
--- a/pytests/powertest.py
+++ b/pytests/powertest.py
@@ -108,7 +108,7 @@ if _IS_WINDOWS:
# pylint: disable=too-many-lines
-__version__ = "0.1"
+__version__ = "1.0"
LOGGER = logging.getLogger(__name__)
@@ -1257,8 +1257,14 @@ def remote_handler(options, operations): # pylint: disable=too-many-branches,to
ret = wait_for_mongod_shutdown(mongod)
elif operation == "rsync_data":
- ret, output = rsync(options.db_path, options.rsync_dest, options.rsync_exclude_files)
- LOGGER.info(output)
+ rsync_dir, new_rsync_dir = options.rsync_dest
+ ret, output = rsync(options.db_path, rsync_dir, options.rsync_exclude_files)
+ if output:
+ LOGGER.info(output)
+ # Rename the rsync_dir only if it has a different name than new_rsync_dir.
+ if ret == 0 and rsync_dir != new_rsync_dir:
+ LOGGER.info("Renaming directory {} to {}".format(rsync_dir, new_rsync_dir))
+ os.rename(rsync_dir, new_rsync_dir)
elif operation == "seed_docs":
mongo = pymongo.MongoClient(**mongo_client_opts)
@@ -1309,6 +1315,11 @@ def remote_handler(options, operations): # pylint: disable=too-many-branches,to
return 0
+def get_backup_path(path, loop_num):
+ """Return the backup path based on the loop_num."""
+ return re.sub("-{}$".format(loop_num - 1), "-{}".format(loop_num), path)
+
+
def rsync(src_dir, dest_dir, exclude_files=None):
"""Rsync 'src_dir' to 'dest_dir'."""
# Note rsync on Windows requires a Unix-style directory.
@@ -1981,8 +1992,8 @@ Examples:
program_options.add_option("--remoteOperation", dest="remote_operation",
help=optparse.SUPPRESS_HELP, action="store_true", default=False)
- program_options.add_option("--rsyncDest", dest="rsync_dest", help=optparse.SUPPRESS_HELP,
- default=None)
+ program_options.add_option("--rsyncDest", dest="rsync_dest", nargs=2,
+ help=optparse.SUPPRESS_HELP, default=None)
parser.add_option_group(test_options)
parser.add_option_group(crash_options)
@@ -2111,6 +2122,9 @@ Examples:
backup_path_after = options.backup_path_after
if not backup_path_after:
backup_path_after = "{}/data-afterrecovery".format(options.root_dir)
+ # Set the first backup directory, for loop 1.
+ backup_path_before = "{}-1".format(backup_path_before)
+ backup_path_after = "{}-1".format(backup_path_after)
else:
rsync_cmd = ""
rsync_opt = ""
@@ -2300,7 +2314,9 @@ Examples:
# Since rsync requires Posix style paths, we do not use os.path.join to
# construct the rsync destination directory.
if rsync_cmd:
- rsync_opt = "--rsyncDest {}".format(backup_path_before)
+ new_path_dir = get_backup_path(backup_path_before, loop_num)
+ rsync_opt = "--rsyncDest {} {}".format(backup_path_before, new_path_dir)
+ backup_path_before = new_path_dir
# Optionally, rsync the pre-recovery database.
# Start monogd on the secret port.
@@ -2366,7 +2382,9 @@ Examples:
# Since rsync requires Posix style paths, we do not use os.path.join to
# construct the rsync destination directory.
if rsync_cmd:
- rsync_opt = "--rsyncDest {}".format(backup_path_after)
+ new_path_dir = get_backup_path(backup_path_after, loop_num)
+ rsync_opt = "--rsyncDest {} {}".format(backup_path_after, new_path_dir)
+ backup_path_after = new_path_dir
# Optionally, rsync the post-recovery database.
# Start monogd on the standard port.