diff options
Diffstat (limited to 'src/third_party/wiredtiger/test/suite/test_backup12.py')
-rw-r--r-- | src/third_party/wiredtiger/test/suite/test_backup12.py | 87 |
1 files changed, 10 insertions, 77 deletions
diff --git a/src/third_party/wiredtiger/test/suite/test_backup12.py b/src/third_party/wiredtiger/test/suite/test_backup12.py index 53ad7845634..7fe72dd43fe 100644 --- a/src/third_party/wiredtiger/test/suite/test_backup12.py +++ b/src/third_party/wiredtiger/test/suite/test_backup12.py @@ -58,12 +58,12 @@ class test_backup12(backup_base): self.add_data(self.uri2, self.bigkey, self.bigval, True) self.add_data(self.uri_rem, self.bigkey, self.bigval, True) + os.mkdir(self.dir) + # # Open up the backup cursor. This causes a new log file to be created. # That log file is not part of the list returned. This is a full backup # primary cursor with incremental configured. - os.mkdir(self.dir) - # - # Note, this first backup is actually done before a checkpoint is taken. + # Note: this first backup is actually done before a checkpoint is taken. # config = 'incremental=(enabled,granularity=1M,this_id="ID1")' bkup_c = self.session.open_cursor('backup:', None, config) @@ -71,41 +71,15 @@ class test_backup12(backup_base): # Add more data while the backup cursor is open. self.add_data(self.uri, self.bigkey, self.bigval, True) - # Now copy the files returned by the backup cursor. - all_files = [] - while True: - ret = bkup_c.next() - if ret != 0: - break - newfile = bkup_c.get_key() - sz = os.path.getsize(newfile) - self.pr('Copy from: ' + newfile + ' (' + str(sz) + ') to ' + self.dir) - shutil.copy(newfile, self.dir) - all_files.append(newfile) - self.assertEqual(ret, wiredtiger.WT_NOTFOUND) + # Now make a full backup. + all_files = self.take_full_backup(self.dir, bkup_c) # Now open a duplicate backup cursor. # We *can* use a log target duplicate on an incremental primary backup so that # a backup process can get all the log files that occur while that primary cursor # is open. - config = 'target=("log:")' - dupc = self.session.open_cursor(None, bkup_c, config) - dup_logs = [] - while True: - ret = dupc.next() - if ret != 0: - break - newfile = dupc.get_key() - self.assertTrue("WiredTigerLog" in newfile) - sz = os.path.getsize(newfile) - if (newfile not in all_files): - self.pr('DUP: Copy from: ' + newfile + ' (' + str(sz) + ') to ' + self.dir) - shutil.copy(newfile, self.dir) - # Record all log files returned for later verification. - dup_logs.append(newfile) - all_files.append(newfile) - self.assertEqual(ret, wiredtiger.WT_NOTFOUND) - dupc.close() + dup_logs = self.take_log_backup(bkup_c, self.dir, all_files) + all_files += dup_logs bkup_c.close() # Add more data. @@ -115,50 +89,9 @@ class test_backup12(backup_base): # Drop a table. self.session.drop(self.uri_rem) - # Now do an incremental backup. - config = 'incremental=(src_id="ID1",this_id="ID2")' - bkup_c = self.session.open_cursor('backup:', None, config) - self.pr('Open backup cursor ID1') - bkup_files = [] - while True: - ret = bkup_c.next() - if ret != 0: - break - newfile = bkup_c.get_key() - config = 'incremental=(file=' + newfile + ')' - self.pr('Open incremental cursor with ' + config) - dup_cnt = 0 - dupc = self.session.open_cursor(None, bkup_c, config) - bkup_files.append(newfile) - all_files.append(newfile) - while True: - ret = dupc.next() - if ret != 0: - break - incrlist = dupc.get_keys() - offset = incrlist[0] - size = incrlist[1] - curtype = incrlist[2] - # 1 is WT_BACKUP_FILE - # 2 is WT_BACKUP_RANGE - self.assertTrue(curtype == 1 or curtype == 2) - if curtype == 1: - self.pr('Copy from: ' + newfile + ' (' + str(sz) + ') to ' + self.dir) - shutil.copy(newfile, self.dir) - else: - self.pr('Range copy file ' + newfile + ' offset ' + str(offset) + ' len ' + str(size)) - rfp = open(newfile, "r+b") - wfp = open(self.dir + '/' + newfile, "w+b") - rfp.seek(offset, 0) - wfp.seek(offset, 0) - buf = rfp.read(size) - wfp.write(buf) - rfp.close() - wfp.close() - dup_cnt += 1 - dupc.close() - self.assertEqual(ret, wiredtiger.WT_NOTFOUND) - bkup_c.close() + # Now do an incremental backup with id 2. + (bkup_files, _) = self.take_incr_backup(self.dir, 2) + all_files += bkup_files # We need to remove files in the backup directory that are not in the current backup. all_set = set(all_files) |