summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/suite/test_config07.py
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2018-08-13 15:46:37 +1000
committerLuke Chen <luke.chen@mongodb.com>2018-08-13 15:46:37 +1000
commitec6f2a54d8b901e95e556d53647944be8ce441d5 (patch)
treea75c521f1918cf0343acf2ced1669567e2a7b854 /src/third_party/wiredtiger/test/suite/test_config07.py
parent1c52af393ebc9040fbc300293835f68f827304ce (diff)
downloadmongo-ec6f2a54d8b901e95e556d53647944be8ce441d5.tar.gz
Import wiredtiger: c91b80412603f283532e267893f9238dd4a5ec0f from branch mongodb-4.2
ref: 65531924e3..c91b804126 for: 4.1.2 WT-3856 Create a test that runs recovery to different points of time with schema operations WT-4026 Add implementation for existing file extension configuration API WT-4193 test/format snapshot-isolation search mismatch WT-4194 Improve fairness of eviction with multiple tables WT-4207 Coverity #1394567: null pointer dereference WT-4210 schema abort child process failing prematurely WT-4215 Allow recovery of backup without salvage WT-4229 Lint WT-4234 Remove documentation mention of legacy tool statlog.py WT-4235 Fix workgen tracking of table state across workloads WT-4242 New log file extension Python test failure
Diffstat (limited to 'src/third_party/wiredtiger/test/suite/test_config07.py')
-rw-r--r--src/third_party/wiredtiger/test/suite/test_config07.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/third_party/wiredtiger/test/suite/test_config07.py b/src/third_party/wiredtiger/test/suite/test_config07.py
new file mode 100644
index 00000000000..edf37577d4b
--- /dev/null
+++ b/src/third_party/wiredtiger/test/suite/test_config07.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+#
+# Public Domain 2014-2018 MongoDB, Inc.
+# Public Domain 2008-2014 WiredTiger, Inc.
+#
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+import fnmatch, os, time
+import wiredtiger, wttest
+from wtscenario import make_scenarios
+
+# test_config07.py
+# Test that log files extend as configured and as documented.
+class test_config07(wttest.WiredTigerTestCase):
+ uri = "table:test"
+ entries = 100000
+ K = 1024
+ log_size = K * K
+
+ extend_len = [
+ ('default', dict(log_extend_len='()', expected_log_size = log_size)),
+ ('empty', dict(log_extend_len='(log=)', expected_log_size = log_size)),
+ ('disable', dict(log_extend_len='(log=0)', expected_log_size = 128)),
+ ('100K', dict(log_extend_len='(log=100K)', expected_log_size = 100 * K)),
+ ('too_small', dict(log_extend_len='(log=20K)', expected_log_size = None)),
+ ('too_large', dict(log_extend_len='(log=20G)', expected_log_size = None)),
+ ('small_in_allowed range', dict(log_extend_len='(log=200K)',
+ expected_log_size = 200 * K)),
+ ('large_in_allowed_range', dict(log_extend_len='(log=900K)',
+ expected_log_size = 900 * K)),
+ ('larger_than_log_file_size', dict(log_extend_len='(log=20M)',
+ expected_log_size = log_size)),
+ ('with_data_file_extend_conf', dict(log_extend_len='(log=100K,data=16M)',
+ expected_log_size = 100 * K)),
+ ]
+
+ scenarios = make_scenarios(extend_len)
+
+ def populate(self):
+ cur = self.session.open_cursor(self.uri, None, None)
+ for i in range(0, self.entries):
+ cur[i] = i
+ cur.close()
+
+ def checkLogFileSize(self, size):
+ # Wait for a log file to be preallocated. Avoid timing problems, but
+ # assert that a file is created within 1 minute.
+ for i in range(1,60):
+ logs = fnmatch.filter(os.listdir('.'), "*Prep*")
+ if logs:
+ f = logs[-1]
+ file_size = os.stat(f).st_size
+ self.assertEqual(size, file_size)
+ break
+ time.sleep(1)
+ self.assertTrue(logs)
+
+ def test_log_extend(self):
+ self.conn.close()
+ msg = '/invalid log extend length/'
+
+ config = 'log=(enabled,file_max=1M),file_extend=' + self.log_extend_len
+ configarg = 'create,statistics=(fast)' + ',' + config
+
+ # Expect an error when an invalid log extend size is provided.
+ if self.expected_log_size is None:
+ self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
+ lambda: self.wiredtiger_open('.', configarg), msg)
+ return
+
+ self.conn = self.wiredtiger_open('.', configarg)
+ self.session = self.conn.open_session(None)
+
+ # Create a table, insert data in it to trigger log file writes.
+ self.session.create(self.uri, 'key_format=i,value_format=i')
+ self.populate()
+ self.session.checkpoint()
+
+ self.checkLogFileSize(self.expected_log_size)
+
+if __name__ == '__main__':
+ wttest.run()