diff options
Diffstat (limited to 'src/third_party/wiredtiger/test/suite/test_tiered04.py')
-rwxr-xr-x | src/third_party/wiredtiger/test/suite/test_tiered04.py | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/src/third_party/wiredtiger/test/suite/test_tiered04.py b/src/third_party/wiredtiger/test/suite/test_tiered04.py index efb5630eda6..05fbbc44a5e 100755 --- a/src/third_party/wiredtiger/test/suite/test_tiered04.py +++ b/src/third_party/wiredtiger/test/suite/test_tiered04.py @@ -26,7 +26,7 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -import os, wiredtiger, wttest +import os, time, wiredtiger, wttest from wiredtiger import stat StorageSource = wiredtiger.StorageSource # easy access to constants @@ -35,8 +35,11 @@ StorageSource = wiredtiger.StorageSource # easy access to constants class test_tiered04(wttest.WiredTigerTestCase): # If the 'uri' changes all the other names must change with it. - fileuri_base = 'file:test_tiered04-000000000' - objuri = 'object:test_tiered04-0000000001.wtobj' + base = 'test_tiered04-000000000' + fileuri_base = 'file:' + base + obj1file = base + '1.wtobj' + obj2file = base + '2.wtobj' + objuri = 'object:' + base + '1.wtobj' tiereduri = "tiered:test_tiered04" uri = "table:test_tiered04" @@ -53,8 +56,8 @@ class test_tiered04(wttest.WiredTigerTestCase): object_sys_val = 9 * 1024 * 1024 object_uri = "15M" object_uri_val = 15 * 1024 * 1024 - retention = 600 - retention1 = 350 + retention = 3 + retention1 = 600 def conn_config(self): os.mkdir(self.bucket) os.mkdir(self.bucket1) @@ -120,19 +123,50 @@ class test_tiered04(wttest.WiredTigerTestCase): self.pr("flush tier") c = self.session.open_cursor(self.uri) + c1 = self.session.open_cursor(self.uri1) + cn = self.session.open_cursor(self.uri_none) c["0"] = "0" + c1["0"] = "0" + cn["0"] = "0" self.check(c, 1) + self.check(c1, 1) + self.check(cn, 1) c.close() + + # Check the local retention. After a flush_tier call the object file should exist in + # the local database. Then after sleeping long enough it should be removed. + self.session.checkpoint() + self.session.flush_tier(None) + self.pr("Check for ") + self.pr(self.obj1file) + self.assertTrue(os.path.exists(self.obj1file)) + self.assertTrue(os.path.exists(self.obj2file)) + self.pr("Sleep") + time.sleep(self.retention + 1) + # We call flush_tier here because otherwise the internal thread that + # processes the work units won't run for a while. This call will signal + # the internal thread to process the work units. self.session.flush_tier(None) + time.sleep(1) + self.pr("Check removal of ") + self.pr(self.obj1file) + self.assertFalse(os.path.exists(self.obj1file)) c = self.session.open_cursor(self.uri) c["1"] = "1" + c1["1"] = "1" + cn["1"] = "1" self.check(c, 2) c.close() c = self.session.open_cursor(self.uri) c["2"] = "2" + c1["2"] = "2" + cn["2"] = "2" self.check(c, 3) + c1.close() + cn.close() + self.session.checkpoint() self.pr("flush tier again, holding open cursor") self.session.flush_tier(None) @@ -142,7 +176,7 @@ class test_tiered04(wttest.WiredTigerTestCase): c.close() calls = self.get_stat(stat.conn.flush_tier, None) - flush = 2 + flush = 3 self.assertEqual(calls, flush) obj = self.get_stat(stat.conn.tiered_object_size, None) self.assertEqual(obj, self.object_sys_val) @@ -174,26 +208,27 @@ class test_tiered04(wttest.WiredTigerTestCase): self.assertEqual(retain, self.retention) self.session.flush_tier(None) self.session.flush_tier('force=true') + flush += 2 calls = self.get_stat(stat.conn.flush_tier, None) - self.assertEqual(calls, 4) + self.assertEqual(calls, flush) # Test reconfiguration. - new = self.retention * 2 - config = 'tiered_storage=(local_retention=%d)' % new + config = 'tiered_storage=(local_retention=%d)' % self.retention1 self.pr("reconfigure") self.conn.reconfigure(config) retain = self.get_stat(stat.conn.tiered_retention, None) - self.assertEqual(retain, new) - self.pr("reconfigure flush_tier") + self.assertEqual(retain, self.retention1) + # Call flush_tier with its various configuration arguments. It is difficult # to force a timeout or lock contention with a unit test. So just test the # call for now. self.session.flush_tier('timeout=10') self.session.flush_tier('lock_wait=false') self.session.flush_tier('sync=off') + flush += 3 self.pr("reconfigure get stat") calls = self.get_stat(stat.conn.flush_tier, None) - self.assertEqual(calls, 7) + self.assertEqual(calls, flush) if __name__ == '__main__': wttest.run() |