summaryrefslogtreecommitdiff
path: root/pytests
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2019-08-02 13:39:50 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2019-08-02 13:39:50 -0400
commite6ef0ca20e99b2b3a6682952c2588e6e2d1ba8a9 (patch)
tree9a77db43a18341148c1477f12cad5f3a4279f09a /pytests
parentebfc0dc2e6f80e61d6b94742a79d1194997a7959 (diff)
downloadmongo-e6ef0ca20e99b2b3a6682952c2588e6e2d1ba8a9.tar.gz
SERVER-42615 Run chkdsk command on Windows after each powercycle loop.
Diffstat (limited to 'pytests')
-rwxr-xr-xpytests/powertest.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/pytests/powertest.py b/pytests/powertest.py
index f330a645a3b..32c6cbe551a 100755
--- a/pytests/powertest.py
+++ b/pytests/powertest.py
@@ -1317,6 +1317,30 @@ def remote_handler(options, operations): # pylint: disable=too-many-branches,to
err)
ret = err.code
+ elif operation == "check_disk":
+ if _IS_WINDOWS:
+ partitions = psutil.disk_partitions()
+ for part in partitions:
+ if part.fstype != "NTFS" or part.mountpoint == "C:\\":
+ # Powercycle testing in Evergreen only writes to the D: and E: drives on the
+ # remote machine. We skip running the chkdsk command on the C: drive because
+ # it sometimes fails with a "Snapshot was deleted" error. We assume the
+ # system drive is functioning properly because the remote machine rebooted
+ # fine anyway.
+ continue
+
+ # The chkdsk command won't accept the drive if it has a trailing backslash.
+ # We use os.path.splitdrive()[0] to transform 'C:\\' into 'C:'.
+ drive_letter = os.path.splitdrive(part.mountpoint)[0]
+ LOGGER.info("Running chkdsk command for %s drive", drive_letter)
+ cmds = f"chkdsk '{drive_letter}'"
+ ret, output = execute_cmd(cmds, use_file=True)
+ LOGGER.warning("chkdsk command for %s drive exited with code %d:\n%s",
+ drive_letter, ret, output)
+
+ if ret != 0:
+ return ret
+
else:
LOGGER.error("Unsupported remote option specified '%s'", operation)
ret = 1
@@ -2569,6 +2593,11 @@ Examples:
if loop_num == options.num_loops or test_time >= options.test_time:
break
+ ret, output = call_remote_operation(local_ops, options.remote_python, script_name,
+ client_args, "--remoteOperation check_disk")
+ if ret != 0:
+ LOGGER.error("****check_disk: %d %s****", ret, output)
+
REPORT_JSON_SUCCESS = True
local_exit(0)