diff options
Diffstat (limited to 'src/third_party/wiredtiger/test/suite/test_backup13.py')
-rw-r--r-- | src/third_party/wiredtiger/test/suite/test_backup13.py | 80 |
1 files changed, 13 insertions, 67 deletions
diff --git a/src/third_party/wiredtiger/test/suite/test_backup13.py b/src/third_party/wiredtiger/test/suite/test_backup13.py index 8992440c038..73bc4aad9a5 100644 --- a/src/third_party/wiredtiger/test/suite/test_backup13.py +++ b/src/third_party/wiredtiger/test/suite/test_backup13.py @@ -57,18 +57,18 @@ class test_backup13(backup_base): def simulate_crash_restart(self, olddir, newdir): ''' Simulate a crash from olddir and restart in newdir. ''' - # with the connection still open, copy files to new directory + # with the connection still open, copy files to new directory. 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 since it is locked + # Skip lock file on Windows since it is locked. if os.path.isfile(fullname) and \ "WiredTiger.lock" not in fullname and \ "Tmplog" not in fullname and \ "Preplog" not in fullname: shutil.copy(fullname, newdir) - # close the original connection and open to new directory + # close the original connection and open to new directory. self.close_conn() self.conn = self.setUpConnectionOpen(newdir) self.session = self.setUpSessionOpen(self.conn) @@ -87,79 +87,26 @@ class test_backup13(backup_base): def test_backup13(self): self.session.create(self.uri, "key_format=S,value_format=S") self.add_data_and_check() + + os.mkdir(self.dir) + + # Add more data while the backup cursor is open. + self.add_data_and_check() + # 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) config = 'incremental=(enabled,granularity=1M,this_id="ID1")' bkup_c = self.session.open_cursor('backup:', None, config) - # Add more data while the backup cursor is open. - self.add_data_and_check() - - # Now copy the files returned by the backup cursor. - all_files = [] - - # We cannot use 'for newfile in bkup_c:' usage because backup cursors don't have - # values and adding in get_values returns ENOTSUP and causes the usage to fail. - # If that changes then this, and the use of the duplicate below can change. - 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 and track the files. + all_files = self.take_full_backup(self.dir, bkup_c) bkup_c.close() - # Add more data. self.add_data_and_check() - # 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] - self.assertTrue(curtype == wiredtiger.WT_BACKUP_FILE or curtype == wiredtiger.WT_BACKUP_RANGE) - if curtype == wiredtiger.WT_BACKUP_FILE: - 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_set = set(all_files) bkup_set = set(bkup_files) @@ -178,7 +125,6 @@ class test_backup13(backup_base): # Make sure after a force stop we cannot access old backup info. config = 'incremental=(src_id="ID1",this_id="ID3")' - self.assertRaises(wiredtiger.WiredTigerError, lambda: self.session.open_cursor('backup:', None, config)) |