summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/suite/test_backup14.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/test/suite/test_backup14.py')
-rw-r--r--src/third_party/wiredtiger/test/suite/test_backup14.py165
1 files changed, 27 insertions, 138 deletions
diff --git a/src/third_party/wiredtiger/test/suite/test_backup14.py b/src/third_party/wiredtiger/test/suite/test_backup14.py
index a4933140833..803dffd2562 100644
--- a/src/third_party/wiredtiger/test/suite/test_backup14.py
+++ b/src/third_party/wiredtiger/test/suite/test_backup14.py
@@ -57,125 +57,8 @@ class test_backup14(backup_base):
bigkey = 'Key' * 100
bigval = 'Value' * 100
- def take_full_backup(self):
- if self.counter != 0:
- hdir = self.home_full + '.' + str(self.counter)
- else:
- hdir = self.home_incr
-
- #
- # First time through we take a full backup into the incremental directories. Otherwise only
- # into the appropriate full directory.
- #
- buf = None
- if self.initial_backup == True:
- buf = 'incremental=(granularity=1M,enabled=true,this_id=ID0)'
-
- cursor = self.session.open_cursor('backup:', None, buf)
- while True:
- ret = cursor.next()
- if ret != 0:
- break
- newfile = cursor.get_key()
-
- if self.counter == 0:
- # Take a full backup into each incremental directory
- for i in range(0, self.max_iteration):
- copy_from = newfile
- # If it is a log file, prepend the path.
- if ("WiredTigerLog" in newfile):
- copy_to = self.home_incr + '.' + str(i) + '/' + self.logpath
- else:
- copy_to = self.home_incr + '.' + str(i)
- shutil.copy(copy_from, copy_to)
- else:
- copy_from = newfile
- # If it is log file, prepend the path.
- if ("WiredTigerLog" in newfile):
- copy_to = hdir + '/' + self.logpath
- else:
- copy_to = hdir
-
- shutil.copy(copy_from, copy_to)
- self.assertEqual(ret, wiredtiger.WT_NOTFOUND)
- cursor.close()
-
- def take_incr_backup(self):
- # Open the backup data source for incremental backup.
- buf = 'incremental=(src_id="ID' + str(self.counter - 1) + '",this_id="ID' + str(self.counter) + '")'
- bkup_c = self.session.open_cursor('backup:', None, buf)
- while True:
- ret = bkup_c.next()
- if ret != 0:
- break
- newfile = bkup_c.get_key()
- h = self.home_incr + '.0'
- copy_from = newfile
- # If it is log file, prepend the path.
- if ("WiredTigerLog" in newfile):
- copy_to = h + '/' + self.logpath
- else:
- copy_to = h
-
- shutil.copy(copy_from, copy_to)
- first = True
- config = 'incremental=(file=' + newfile + ')'
- dup_cnt = 0
- incr_c = self.session.open_cursor(None, bkup_c, config)
-
- # For each file listed, open a duplicate backup cursor and copy the blocks.
- while True:
- ret = incr_c.next()
- if ret != 0:
- break
- incrlist = incr_c.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:
- if first == True:
- h = self.home_incr + '.' + str(self.counter)
- first = False
-
- copy_from = newfile
- if ("WiredTigerLog" in newfile):
- copy_to = h + '/' + self.logpath
- else:
- copy_to = h
- shutil.copy(copy_from, copy_to)
- else:
- self.pr('Range copy file ' + newfile + ' offset ' + str(offset) + ' len ' + str(size))
- read_from = newfile
- write_to = self.home_incr + '.' + str(self.counter) + '/' + newfile
- rfp = open(read_from, "r+b")
- wfp = open(write_to, "w+b")
- rfp.seek(offset, 0)
- wfp.seek(offset, 0)
- buf = rfp.read(size)
- wfp.write(buf)
- rfp.close()
- wfp.close()
- dup_cnt += 1
- self.assertEqual(ret, wiredtiger.WT_NOTFOUND)
- incr_c.close()
-
- # For each file, we want to copy the file into each of the later incremental directories
- for i in range(self.counter, self.max_iteration):
- h = self.home_incr + '.' + str(i)
- copy_from = newfile
- if ("WiredTigerLog" in newfile):
- copy_to = h + '/' + self.logpath
- else:
- copy_to = h
- shutil.copy(copy_from, copy_to)
- self.assertEqual(ret, wiredtiger.WT_NOTFOUND)
- bkup_c.close()
-
#
- # Remove data from uri (table:main)
+ # Remove data from uri (table:main).
#
def remove_data(self):
c = self.session.open_cursor(self.uri)
@@ -191,7 +74,7 @@ class test_backup14(backup_base):
self.assertEquals(c.remove(), 0)
c.close()
# Increase the counter so that later backups have unique ids.
- self.counter += 1
+ self.bkup_id += 1
#
# This function will add records to the table (table:main), take incremental/full backups and
@@ -202,15 +85,16 @@ class test_backup14(backup_base):
self.initial_backup = True
self.add_data(self.uri, self.bigkey, self.bigval)
- self.take_full_backup()
+ self.take_full_backup(self.home_incr)
self.initial_backup = False
self.session.checkpoint()
self.add_data(self.uri, self.bigkey, self.bigval)
- self.take_full_backup()
- self.take_incr_backup()
- self.compare_backups(self.uri, self.home_full, self.home_incr, str(self.counter))
+ self.take_full_backup(self.home_full)
+ self.take_incr_backup(self.home_incr)
+ self.compare_backups(self.uri, self.home_full, self.home_incr, str(self.bkup_id))
+ self.setup_directories(self.home_incr, self.home_full)
#
# This function will remove all the records from table (table:main), take backup and validate the
@@ -218,9 +102,10 @@ class test_backup14(backup_base):
#
def remove_all_records_validate(self):
self.remove_data()
- self.take_full_backup()
- self.take_incr_backup()
- self.compare_backups(self.uri, self.home_full, self.home_incr, str(self.counter))
+ self.take_full_backup(self.home_full)
+ self.take_incr_backup(self.home_incr)
+ self.compare_backups(self.uri, self.home_full, self.home_incr, str(self.bkup_id))
+ self.setup_directories(self.home_incr, self.home_full)
#
# This function will drop the existing table uri (table:main) that is part of the backups and
@@ -231,18 +116,19 @@ class test_backup14(backup_base):
# Drop main table.
self.session.drop(self.uri)
- # Create uri2 (table:extra)
+ # Create uri2 (table:extra).
self.session.create(self.uri2, "key_format=S,value_format=S")
self.new_table = True
self.add_data(self.uri2, self.bigkey, self.bigval)
- self.take_incr_backup()
+ self.take_incr_backup(self.home_incr)
table_list = 'tablelist.txt'
# Assert if the dropped table (table:main) exists in the incremental folder.
self.runWt(['-R', '-h', self.home, 'list'], outfilename=table_list)
ret = os.system("grep " + self.uri + " " + table_list)
self.assertNotEqual(ret, 0, self.uri + " dropped, but table exists in " + self.home)
+ self.setup_directories(self.home_incr, self.home_full)
#
# This function will create previously dropped table uri (table:main) and add different content to
@@ -251,9 +137,10 @@ class test_backup14(backup_base):
def create_dropped_table_add_new_content(self):
self.session.create(self.uri, "key_format=S,value_format=S")
self.add_data(self.uri, self.bigkey, self.bigval)
- self.take_full_backup()
- self.take_incr_backup()
- self.compare_backups(self.uri, self.home_full, self.home_incr, str(self.counter))
+ self.take_full_backup(self.home_full)
+ self.take_incr_backup(self.home_incr)
+ self.compare_backups(self.uri, self.home_full, self.home_incr, str(self.bkup_id))
+ self.setup_directories(self.home_incr, self.home_full)
#
# This function will insert bulk data in logged and not-logged table, take backups and validate the
@@ -266,25 +153,27 @@ class test_backup14(backup_base):
self.session.create(self.uri_logged, "key_format=S,value_format=S")
self.add_data(self.uri_logged, self.bigkey, self.bigval)
- self.take_full_backup()
- self.take_incr_backup()
- self.compare_backups(self.uri_logged, self.home_full, self.home_incr, str(self.counter))
+ self.take_full_backup(self.home_full)
+ self.take_incr_backup(self.home_incr)
+ self.compare_backups(self.uri_logged, self.home_full, self.home_incr, str(self.bkup_id))
+ self.setup_directories(self.home_incr, self.home_full)
#
# Insert bulk data into uri4 (table:not_logged_table).
#
self.session.create(self.uri_not_logged, "key_format=S,value_format=S,log=(enabled=false)")
self.add_data(self.uri_not_logged, self.bigkey, self.bigval)
- self.take_full_backup()
- self.take_incr_backup()
- self.compare_backups(self.uri_not_logged, self.home_full, self.home_incr, str(self.counter))
+ self.take_full_backup(self.home_full)
+ self.take_incr_backup(self.home_incr)
+ self.compare_backups(self.uri_not_logged, self.home_full, self.home_incr, str(self.bkup_id))
+ self.setup_directories(self.home_incr, self.home_full)
def test_backup14(self):
os.mkdir(self.bkp_home)
self.home = self.bkp_home
self.session.create(self.uri, "key_format=S,value_format=S")
- self.setup_directories(self.max_iteration, self.home_incr, self.home_full, self.logpath)
+ self.setup_directories(self.home_incr, self.home_full)
self.pr('*** Add data, checkpoint, take backups and validate ***')
self.add_data_validate_backups()