summaryrefslogtreecommitdiff
path: root/test/suite/helper.py
diff options
context:
space:
mode:
authorDon Anderson <dda@ddanderson.com>2015-07-08 13:06:30 -0400
committerDon Anderson <dda@ddanderson.com>2015-07-08 13:06:30 -0400
commit69191f1a24d5bee5826c1e69208940cba5e9792e (patch)
tree8291111d77fa9c3a0f3efeafb8ad30d1b4bdfec2 /test/suite/helper.py
parent144a383393d3ee158d4b3e364f45aec8653f8db8 (diff)
downloadmongo-69191f1a24d5bee5826c1e69208940cba5e9792e.tar.gz
WT-18899 followup to abstract copying a WT home directory into a function,
and create two callers to the function.
Diffstat (limited to 'test/suite/helper.py')
-rw-r--r--test/suite/helper.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/suite/helper.py b/test/suite/helper.py
index cd34811904a..dce5312b966 100644
--- a/test/suite/helper.py
+++ b/test/suite/helper.py
@@ -27,7 +27,7 @@
# OTHER DEALINGS IN THE SOFTWARE.
#
-import glob, os, string
+import glob, os, shutil, string, subprocess
import wiredtiger
# python has a filecmp.cmp function, but different versions of python approach
@@ -96,6 +96,29 @@ def confirm_empty(self, uri):
self.assertEqual(cursor.next(), wiredtiger.WT_NOTFOUND)
cursor.close()
+# copy a WT home directory
+def copy_live_wiredtiger_home(olddir, newdir, aligned=True):
+ # unaligned copy requires 'dd', which may not be available on Windows
+ if not aligned and os.name == "nt":
+ raise AssertionError(
+ 'copy_live_wiredtiger_home: unaligned copy impossible on Windows')
+ shutil.rmtree(newdir, ignore_errors=True)
+ os.mkdir(newdir)
+ for fname in os.listdir(olddir):
+ fullname = os.path.join(olddir, fname)
+ # Skip lock file, on Windows it is locked.
+ if os.path.isfile(fullname) and "WiredTiger.lock" not in fullname:
+ # Use a dd command that does not align on a block boundary.
+ if aligned:
+ shutil.copy(fullname, newdir)
+ else:
+ fullname = os.path.join(olddir, fname)
+ inpf = 'if=' + fullname
+ outf = 'of=' + newdir + '/' + fullname
+ cmd_list = ['dd', inpf, outf, 'bs=300']
+ a = subprocess.Popen(cmd_list)
+ a.wait()
+
# create a simple_populate or complex_populate key
def key_populate(cursor, i):
key_format = cursor.key_format