diff options
author | Keith Bostic <keith@wiredtiger.com> | 2014-06-15 10:01:33 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2014-06-15 10:01:33 -0400 |
commit | 6d0e066d5dcd349de3f95ee830e6e1b2a7c740fc (patch) | |
tree | 07f00348a0bbb0a39d7f631f995c355ffcfb937e /test/suite/test_bug008.py | |
parent | 07849501aeab1b5cb80649e6e68fa4a1e2a0ed8f (diff) | |
download | mongo-6d0e066d5dcd349de3f95ee830e6e1b2a7c740fc.tar.gz |
Add a slightly different test, where there are visible records in the
insert list as well as in the on-page records.
Diffstat (limited to 'test/suite/test_bug008.py')
-rw-r--r-- | test/suite/test_bug008.py | 77 |
1 files changed, 71 insertions, 6 deletions
diff --git a/test/suite/test_bug008.py b/test/suite/test_bug008.py index 1c4a67a1411..d4f89da1a74 100644 --- a/test/suite/test_bug008.py +++ b/test/suite/test_bug008.py @@ -39,7 +39,9 @@ class test_bug008(wttest.WiredTigerTestCase): ('var', dict(fmt='key_format=r', empty=0)) ] - def test_search_invisible(self): + # Verify cursor search and search-near operations on a file with a set of + # on-page visible records, and a set of insert-list invisible records. + def test_search_invisible_one(self): uri = 'file:test_bug008' # This is a btree layer test. # Populate the tree and reopen the connection, forcing it to disk @@ -50,7 +52,7 @@ class test_bug008(wttest.WiredTigerTestCase): # Begin a transaction, and add some additional records. self.session.begin_transaction() cursor = self.session.open_cursor(uri, None) - for i in range(100, 120): + for i in range(100, 140): cursor.set_key(key_populate(cursor, i)) cursor.set_value(value_populate(cursor, i)) cursor.insert() @@ -60,14 +62,14 @@ class test_bug008(wttest.WiredTigerTestCase): cursor = s.open_cursor(uri, None) # Search for an invisible record. - cursor.set_key(key_populate(cursor, 110)) + cursor.set_key(key_populate(cursor, 130)) if self.empty: # Invisible updates to fixed-length column-store objects are # invisible to the reader, but the fact that they exist past # the end of the initial records causes the instantiation of # empty records: confirm successful return of an empty row. cursor.search() - self.assertEqual(cursor.get_key(), 110) + self.assertEqual(cursor.get_key(), 130) self.assertEqual(cursor.get_value(), 0) else: # Otherwise, we should not find any matching records. @@ -75,7 +77,7 @@ class test_bug008(wttest.WiredTigerTestCase): # Search-near for an invisible record, which should succeed, returning # the last visible record. - cursor.set_key(key_populate(cursor, 110)) + cursor.set_key(key_populate(cursor, 130)) cursor.search_near() if self.empty: # Invisible updates to fixed-length column-store objects are @@ -83,7 +85,7 @@ class test_bug008(wttest.WiredTigerTestCase): # the end of the initial records causes the instantiation of # empty records: confirm successful return of an empty row. cursor.search() - self.assertEqual(cursor.get_key(), 110) + self.assertEqual(cursor.get_key(), 130) self.assertEqual(cursor.get_value(), 0) else: # Otherwise, we should find the closest record for which we can see @@ -91,6 +93,69 @@ class test_bug008(wttest.WiredTigerTestCase): self.assertEqual(cursor.get_key(), key_populate(cursor, 100)) self.assertEqual(cursor.get_value(), value_populate(cursor, 100)) + # Verify cursor search and search-near operations on a file with a set of + # on-page visible records, a set of insert-list visible records, and a set + # of insert-list invisible records. + def test_search_invisible_two(self): + uri = 'file:test_bug008' # This is a btree layer test. + + # Populate the tree and reopen the connection, forcing it to disk + # and moving the records to an on-page format. + simple_populate(self, uri, self.fmt, 100) + self.reopen_conn() + + # Add some additional visible records. + cursor = self.session.open_cursor(uri, None) + for i in range(100, 120): + cursor.set_key(key_populate(cursor, i)) + cursor.set_value(value_populate(cursor, i)) + cursor.insert() + cursor.close() + + # Begin a transaction, and add some additional records. + self.session.begin_transaction() + cursor = self.session.open_cursor(uri, None) + for i in range(120, 140): + cursor.set_key(key_populate(cursor, i)) + cursor.set_value(value_populate(cursor, i)) + cursor.insert() + + # Open a separate session and cursor. + s = self.conn.open_session() + cursor = s.open_cursor(uri, None) + + # Search for an invisible record. + cursor.set_key(key_populate(cursor, 130)) + if self.empty: + # Invisible updates to fixed-length column-store objects are + # invisible to the reader, but the fact that they exist past + # the end of the initial records causes the instantiation of + # empty records: confirm successful return of an empty row. + cursor.search() + self.assertEqual(cursor.get_key(), 130) + self.assertEqual(cursor.get_value(), 0) + else: + # Otherwise, we should not find any matching records. + self.assertEqual(cursor.search(), wiredtiger.WT_NOTFOUND) + + # Search-near for an invisible record, which should succeed, returning + # the last visible record. + cursor.set_key(key_populate(cursor, 130)) + cursor.search_near() + if self.empty: + # Invisible updates to fixed-length column-store objects are + # invisible to the reader, but the fact that they exist past + # the end of the initial records causes the instantiation of + # empty records: confirm successful return of an empty row. + cursor.search() + self.assertEqual(cursor.get_key(), 130) + self.assertEqual(cursor.get_value(), 0) + else: + # Otherwise, we should find the closest record for which we can see + # the value. + self.assertEqual(cursor.get_key(), key_populate(cursor, 119)) + self.assertEqual(cursor.get_value(), value_populate(cursor, 119)) + if __name__ == '__main__': wttest.run() |