diff options
Diffstat (limited to 'src/third_party/wiredtiger/test/suite')
16 files changed, 172 insertions, 27 deletions
diff --git a/src/third_party/wiredtiger/test/suite/test_backup02.py b/src/third_party/wiredtiger/test/suite/test_backup02.py index 7d8f653feae..c0410b41708 100644 --- a/src/third_party/wiredtiger/test/suite/test_backup02.py +++ b/src/third_party/wiredtiger/test/suite/test_backup02.py @@ -32,7 +32,7 @@ from wtthread import backup_thread, checkpoint_thread, op_thread from wtscenario import make_scenarios # test_backup02.py -# Run background checkpoints and backsups repeatedly while doing inserts +# Run background checkpoints and backups repeatedly while doing inserts # in another thread class test_backup02(wttest.WiredTigerTestCase): scenarios = make_scenarios([ diff --git a/src/third_party/wiredtiger/test/suite/test_bug018.py b/src/third_party/wiredtiger/test/suite/test_bug018.py index 7d20ebcaacb..b904b688586 100644 --- a/src/third_party/wiredtiger/test/suite/test_bug018.py +++ b/src/third_party/wiredtiger/test/suite/test_bug018.py @@ -65,7 +65,7 @@ class test_bug018(wttest.WiredTigerTestCase): # table out from underneath WiredTiger. We do this right before # closing the connection so that the write error happens during close # when writing out the final data. Allow table 1 to succeed and force - # an erorr writing out table 2. + # an error writing out table 2. # # This is Linux-specific code to figure out the file descriptor. for f in os.listdir('/proc/self/fd'): diff --git a/src/third_party/wiredtiger/test/suite/test_collator.py b/src/third_party/wiredtiger/test/suite/test_collator.py index 320c4e7d7b4..c614ea10c83 100644 --- a/src/third_party/wiredtiger/test/suite/test_collator.py +++ b/src/third_party/wiredtiger/test/suite/test_collator.py @@ -108,6 +108,7 @@ class test_collator(wttest.WiredTigerTestCase): key = c.get_key() self.assertEqual(value, expect) i += 1 + cursor.close() self.assertEqual(self.nentries, i) for i in range(0, self.nindices): c = icursor[i] diff --git a/src/third_party/wiredtiger/test/suite/test_compact02.py b/src/third_party/wiredtiger/test/suite/test_compact02.py index eb1eb641191..bea370280d1 100644 --- a/src/third_party/wiredtiger/test/suite/test_compact02.py +++ b/src/third_party/wiredtiger/test/suite/test_compact02.py @@ -30,7 +30,7 @@ # Test that compact reduces the file size. # -import wiredtiger, wttest +import time, wiredtiger, wttest from wiredtiger import stat from wtscenario import make_scenarios @@ -146,7 +146,12 @@ class test_compact02(wttest.WiredTigerTestCase): self.session.checkpoint() # 5. Call compact. - self.session.compact(self.uri, None) + # Compact can collide with eviction, if that happens we retry. + for i in range(1, 5): + if not self.raisesBusy( + lambda: self.session.compact(self.uri, None)): + break + time.sleep(2) # 6. Get stats on compacted table. sz = self.getSize() diff --git a/src/third_party/wiredtiger/test/suite/test_config05.py b/src/third_party/wiredtiger/test/suite/test_config05.py index 5960f01dc8e..0004851b905 100644 --- a/src/third_party/wiredtiger/test/suite/test_config05.py +++ b/src/third_party/wiredtiger/test/suite/test_config05.py @@ -90,7 +90,7 @@ class test_config05(wttest.WiredTigerTestCase): self.conn = self.wiredtiger_open('.', 'create,session_max=1') self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: [self.conn.open_session(None) for i in range(100)], - '/configured to support/') + '/out of sessions/') def test_exclusive_create(self): self.conn = self.wiredtiger_open('.', 'create,exclusive') diff --git a/src/third_party/wiredtiger/test/suite/test_index03.py b/src/third_party/wiredtiger/test/suite/test_index03.py new file mode 100644 index 00000000000..1052cc291d6 --- /dev/null +++ b/src/third_party/wiredtiger/test/suite/test_index03.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# Public Domain 2014-2017 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 wiredtiger, wttest + +# test_index03.py +# Make sure cursors cannot stay open while a new index is created. +class test_index03(wttest.WiredTigerTestCase): + + def key(self, i): + return str('%015d' % i) + + def value(self, i): + return tuple([str(i+1), str(i+2), str(i+3), str(i+4)]) + + def test_index_create(self): + uri = 'table:test_index03' + index1_uri = 'index:test_index03:indx1' + index2_uri = 'index:test_index03:indx2' + config = ',key_format=S,value_format=SSSS' + + session = self.session + session.create(uri, 'columns=(key,col1,col2,col3,col4)' + config) + session.create(index1_uri, 'columns=(col1)' + config) + c1 = session.open_cursor(uri, None) + + # Having cursors open across index creates is not currently allowed. + with self.expectedStderrPattern("Can't create an index for table"): + self.assertRaises(wiredtiger.WiredTigerError, + lambda: session.create(index2_uri, 'columns=(col2)' + config)) + c1.close() + + session.create(index2_uri, 'columns=(col2)' + config) + c1 = session.open_cursor(uri, None) + # Having cursors open across drops is not currently allowed. + # On the drop side, we need to begin using the cursor + for i in xrange(100, 200): + c1[self.key(i)] = self.value(i) + + self.assertRaises(wiredtiger.WiredTigerError, + lambda: session.drop(index2_uri)) + c1.close() + session.drop(index2_uri) + +if __name__ == '__main__': + wttest.run() diff --git a/src/third_party/wiredtiger/test/suite/test_las.py b/src/third_party/wiredtiger/test/suite/test_las.py index 07938c6d80b..d07476382b9 100644 --- a/src/third_party/wiredtiger/test/suite/test_las.py +++ b/src/third_party/wiredtiger/test/suite/test_las.py @@ -41,7 +41,7 @@ class test_las(wttest.WiredTigerTestCase): return 'cache_size=50MB' def large_updates(self, session, uri, value, ds, nrows, timestamp=False): - # Insert a large number of records, we'll hang if the lookaside table + # Update a large number of records, we'll hang if the lookaside table # isn't doing its thing. cursor = session.open_cursor(uri) for i in range(1, 10000): @@ -54,6 +54,23 @@ class test_las(wttest.WiredTigerTestCase): session.commit_transaction('commit_timestamp=' + timestamp_str(i + 1)) cursor.close() + def large_modifies(self, session, uri, offset, ds, nrows, timestamp=False): + # Modify a large number of records, we'll hang if the lookaside table + # isn't doing its thing. + cursor = session.open_cursor(uri) + for i in range(1, 10000): + if timestamp == True: + session.begin_transaction() + cursor.set_key(ds.key(nrows + i)) + mods = [] + mod = wiredtiger.Modify('A', offset, 1) + mods.append(mod) + + self.assertEqual(cursor.modify(mods), 0) + if timestamp == True: + session.commit_transaction('commit_timestamp=' + timestamp_str(i + 1)) + cursor.close() + def durable_check(self, check_value, uri, ds, nrows): # Checkpoint and backup so as to simulate recovery self.session.checkpoint() @@ -66,8 +83,9 @@ class test_las(wttest.WiredTigerTestCase): # Skip the initial rows, which were not updated for i in range(0, nrows+1): self.assertEquals(cursor.next(), 0) - #print "Check value : " + str(check_value) - #print "value : " + str(cursor.get_value()) + if (check_value != cursor.get_value()): + print "Check value : " + str(check_value) + print "value : " + str(cursor.get_value()) self.assertTrue(check_value == cursor.get_value()) cursor.close() session.close() @@ -77,7 +95,7 @@ class test_las(wttest.WiredTigerTestCase): # Create a small table. uri = "table:test_las" nrows = 100 - ds = SimpleDataSet(self, uri, nrows, key_format="S") + ds = SimpleDataSet(self, uri, nrows, key_format="S", value_format='u') ds.populate() bigvalue = "aaaaa" * 100 @@ -112,16 +130,30 @@ class test_las(wttest.WiredTigerTestCase): session2.close() # Scenario: 3 + # Check to see LAS working with modify operations + bigvalue3 = "ccccc" * 100 + bigvalue3 = 'AA' + bigvalue3[2:] + session2 = self.conn.open_session() + session2.begin_transaction('isolation=snapshot') + # Apply two modify operations - replacing the first two items with 'A' + self.large_modifies(self.session, uri, 0, ds, nrows) + self.large_modifies(self.session, uri, 1, ds, nrows) + # Check to see the value after recovery + self.durable_check(bigvalue3, uri, ds, nrows) + session2.rollback_transaction() + session2.close() + + # Scenario: 4 # Check to see LAS working with old timestamp - bigvalue3 = "ddddd" * 100 + bigvalue4 = "ddddd" * 100 self.conn.set_timestamp('stable_timestamp=' + timestamp_str(1)) - self.large_updates(self.session, uri, bigvalue3, ds, nrows, timestamp=True) + self.large_updates(self.session, uri, bigvalue4, ds, nrows, timestamp=True) # Check to see data can be see only till the stable_timestamp - self.durable_check(bigvalue2, uri, ds, nrows) + self.durable_check(bigvalue3, uri, ds, nrows) self.conn.set_timestamp('stable_timestamp=' + timestamp_str(i + 1)) # Check to see latest data can be seen - self.durable_check(bigvalue3, uri, ds, nrows) + self.durable_check(bigvalue4, uri, ds, nrows) if __name__ == '__main__': wttest.run() diff --git a/src/third_party/wiredtiger/test/suite/test_pack.py b/src/third_party/wiredtiger/test/suite/test_pack.py index a24ef4fdfe1..6e5614f1a01 100644 --- a/src/third_party/wiredtiger/test/suite/test_pack.py +++ b/src/third_party/wiredtiger/test/suite/test_pack.py @@ -74,6 +74,8 @@ class test_pack(wttest.WiredTigerTestCase): forw_idx.set_key(*v) self.assertEquals(forw_idx.search(), 0) self.assertEquals(forw_idx.get_value(), 1234) + forw.close() + forw_idx.close() def test_packing(self): self.check('iii', 0, 101, -99) diff --git a/src/third_party/wiredtiger/test/suite/test_readonly01.py b/src/third_party/wiredtiger/test/suite/test_readonly01.py index ee5f78294f4..cd769bc4e88 100644 --- a/src/third_party/wiredtiger/test/suite/test_readonly01.py +++ b/src/third_party/wiredtiger/test/suite/test_readonly01.py @@ -44,8 +44,8 @@ class test_readonly01(wttest.WiredTigerTestCase, suite_subprocess): # We want a list of directory writable or readonly. # basecfg_list = [ - ('basecfg', dict(basecfg='config_base=true,')), - ('no_basecfg', dict(basecfg='config_base=false,')), + ('basecfg', dict(basecfg='config_base=true,operation_tracking=(enabled=false),')), + ('no_basecfg', dict(basecfg='config_base=false,operation_tracking=(enabled=false),')), ] dir_list = [ ('write', dict(dirchmod=False)), diff --git a/src/third_party/wiredtiger/test/suite/test_readonly02.py b/src/third_party/wiredtiger/test/suite/test_readonly02.py index 3d3de8186d9..5fceb9e2ea8 100644 --- a/src/third_party/wiredtiger/test/suite/test_readonly02.py +++ b/src/third_party/wiredtiger/test/suite/test_readonly02.py @@ -42,11 +42,16 @@ class test_readonly02(wttest.WiredTigerTestCase, suite_subprocess): entries = 10 conn_params = \ - 'create,statistics=(fast),log=(enabled,file_max=100K,zero_fill=true),' + 'create,statistics=(fast),' + \ + 'log=(enabled,file_max=100K,zero_fill=true),' + \ + 'operation_tracking=(enabled=false),' conn_params_rd = \ - 'create,readonly=true,statistics=(fast),log=(enabled,zero_fill=false),' + 'create,readonly=true,statistics=(fast),' + \ + 'log=(enabled,zero_fill=false),' + \ + 'operation_tracking=(enabled=false),' conn_params_rdcfg = \ - 'create,readonly=true,statistics=(fast),log=(enabled),' + 'create,readonly=true,statistics=(fast),log=(enabled),' + \ + 'operation_tracking=(enabled=false),' # # Run to make sure incompatible configuration options return an error. diff --git a/src/third_party/wiredtiger/test/suite/test_readonly03.py b/src/third_party/wiredtiger/test/suite/test_readonly03.py index 474e23981a2..e3e92edd8fc 100644 --- a/src/third_party/wiredtiger/test/suite/test_readonly03.py +++ b/src/third_party/wiredtiger/test/suite/test_readonly03.py @@ -40,8 +40,8 @@ class test_readonly03(wttest.WiredTigerTestCase, suite_subprocess): uri2 = 'table:test_readonly03_2' create = True - conn_params = 'create,log=(enabled),' - conn_params_rd = 'readonly=true' + conn_params = 'create,log=(enabled),operation_tracking=(enabled=false),' + conn_params_rd = 'readonly=true,operation_tracking=(enabled=false),' session_ops = [ 'alter', 'create', 'compact', 'drop', 'log_flush', 'log_printf', 'rebalance', 'rename', 'salvage', 'truncate', 'upgrade', ] diff --git a/src/third_party/wiredtiger/test/suite/test_schema05.py b/src/third_party/wiredtiger/test/suite/test_schema05.py index f3a75447ee4..98044cdca09 100644 --- a/src/third_party/wiredtiger/test/suite/test_schema05.py +++ b/src/third_party/wiredtiger/test/suite/test_schema05.py @@ -122,6 +122,7 @@ class test_schema05(wttest.WiredTigerTestCase): value = c.get_value() self.assertEqual(value, expect) i += 1 + cursor.close() self.assertEqual(self.nentries, i) for i in range(0, self.nindices): icursor[i].close() diff --git a/src/third_party/wiredtiger/test/suite/test_sweep01.py b/src/third_party/wiredtiger/test/suite/test_sweep01.py index 4d11942dc54..ac6150262ad 100644 --- a/src/third_party/wiredtiger/test/suite/test_sweep01.py +++ b/src/third_party/wiredtiger/test/suite/test_sweep01.py @@ -44,7 +44,7 @@ class test_sweep01(wttest.WiredTigerTestCase, suite_subprocess): numkv = 1000 conn_config = 'file_manager=(close_handle_minimum=0,' + \ 'close_idle_time=6,close_scan_interval=2),' + \ - 'statistics=(fast),' + 'statistics=(fast),operation_tracking=(enabled=false),' types = [ ('row', dict(tabletype='row', diff --git a/src/third_party/wiredtiger/test/suite/test_txn06.py b/src/third_party/wiredtiger/test/suite/test_txn06.py index 520c25f9b86..21d5d886a6a 100644 --- a/src/third_party/wiredtiger/test/suite/test_txn06.py +++ b/src/third_party/wiredtiger/test/suite/test_txn06.py @@ -40,11 +40,6 @@ class test_txn06(wttest.WiredTigerTestCase, suite_subprocess): source_uri = 'table:' + tablename + "_src" nrows = 100000 - def conn_config(self): - if not wiredtiger.verbose_build(): - self.skipTest('requires a verbose build') - return '' - def test_long_running(self): # Populate a table SimpleDataSet(self, self.source_uri, self.nrows).populate() diff --git a/src/third_party/wiredtiger/test/suite/test_txn18.py b/src/third_party/wiredtiger/test/suite/test_txn18.py index ec3cc7bae00..e139ebe60b5 100644 --- a/src/third_party/wiredtiger/test/suite/test_txn18.py +++ b/src/third_party/wiredtiger/test/suite/test_txn18.py @@ -93,7 +93,7 @@ class test_txn18(wttest.WiredTigerTestCase, suite_subprocess): lambda:self.wiredtiger_open(errdir, self.conn_recerror), msg) # If recover=error is run on the directory and returns an error, - # make sure when we subsequenty open with recover=on it properly + # make sure when we subsequently open with recover=on it properly # recovers all the data. self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda:self.wiredtiger_open(newdir, self.conn_recerror), msg) diff --git a/src/third_party/wiredtiger/test/suite/wttest.py b/src/third_party/wiredtiger/test/suite/wttest.py index c654370718c..f6d81d88b86 100644 --- a/src/third_party/wiredtiger/test/suite/wttest.py +++ b/src/third_party/wiredtiger/test/suite/wttest.py @@ -490,6 +490,39 @@ class WiredTigerTestCase(unittest.TestCase): with self.expectedStderr(message): self.assertRaises(exceptionType, expr) + def assertRaisesException(self, exceptionType, expr, + exceptionString=None, optional=False): + """ + Like TestCase.assertRaises(), with some additional options. + If the exceptionString argument is used, the exception's string + must match it. If optional is set, then no assertion occurs + if the exception doesn't occur. + Returns true if the assertion is raised. + """ + raised = False + try: + expr() + except BaseException, err: + if not isinstance(err, exceptionType): + self.fail('Exception of incorrect type raised, got type: ' + \ + str(type(err))) + if exceptionString != None and exceptionString != str(err): + self.fail('Exception with incorrect string raised, got: "' + \ + str(err) + '"') + raised = True + if not raised and not optional: + self.fail('no assertion raised') + return raised + + def raisesBusy(self, expr): + """ + Execute the expression, returning true if a 'Resource busy' + exception is raised, returning false if no exception is raised. + Any other exception raises a test suite failure. + """ + return self.assertRaisesException(wiredtiger.WiredTigerError, \ + expr, exceptionString='Resource busy', optional=True) + def assertTimestampsEqual(self, ts1, ts2): """ TestCase.assertEqual() for timestamps |