diff options
author | Keith Bostic <keith@wiredtiger.com> | 2012-11-29 15:19:50 +0000 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2012-11-29 15:19:50 +0000 |
commit | 96977a72e567c9b9f37d93f043b1de9656f956e6 (patch) | |
tree | dcbe92931ffedf79b2c0a8412576c354e7920f92 | |
parent | ad1a096b3669ee71e60832d77dcfacff83155ba9 (diff) | |
download | mongo-96977a72e567c9b9f37d93f043b1de9656f956e6.tar.gz |
Add a dump utility test that does end-to-end testing of complex tables.
-rw-r--r-- | test/suite/helper.py | 18 | ||||
-rw-r--r-- | test/suite/test_dump.py | 92 |
2 files changed, 104 insertions, 6 deletions
diff --git a/test/suite/helper.py b/test/suite/helper.py index 1a7f9216c85..46f3d7f0591 100644 --- a/test/suite/helper.py +++ b/test/suite/helper.py @@ -137,9 +137,7 @@ def simple_populate(self, uri, config, rows): cursor.insert() cursor.close() -def simple_populate_check(self, uri): - self.pr('simple_populate_check: ' + uri) - cursor = self.session.open_cursor(uri, None) +def simple_populate_check_cursor(self, cursor): i = 0 for key,val in cursor: i += 1 @@ -147,6 +145,11 @@ def simple_populate_check(self, uri): if cursor.value_format == '8t' and val == 0: # deleted continue; self.assertEqual(val, value_populate(cursor, i)) + +def simple_populate_check(self, uri): + self.pr('simple_populate_check: ' + uri) + cursor = self.session.open_cursor(uri, None) + simple_populate_check_cursor(cursor) cursor.close() # Return the value stored in a complex object. @@ -190,9 +193,7 @@ def complex_populate(self, uri, config, rows): cursor.insert() cursor.close() -def complex_populate_check(self, uri): - self.pr('complex_populate_check: ' + uri) - cursor = self.session.open_cursor(uri, None) +def complex_populate_check_cursor(self, cursor): i = 0 for key, s1, i2, s3, s4 in cursor: i += 1 @@ -202,4 +203,9 @@ def complex_populate_check(self, uri): self.assertEqual(i2, v[1]) self.assertEqual(s3, v[2]) self.assertEqual(s4, v[3]) + +def complex_populate_check(self, uri): + self.pr('complex_populate_check: ' + uri) + cursor = self.session.open_cursor(uri, None) + complex_populate_check_cursor(cursor) cursor.close() diff --git a/test/suite/test_dump.py b/test/suite/test_dump.py new file mode 100644 index 00000000000..b6aef26ec1f --- /dev/null +++ b/test/suite/test_dump.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +# +# Public Domain 2008-2012 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 os +import wiredtiger, wttest +from helper import \ + complex_populate, complex_populate_check_cursor,\ + simple_populate, simple_populate_check_cursor +from suite_subprocess import suite_subprocess +from wtscenario import multiply_scenarios, number_scenarios + +# test_dump.py +# Utilities: wt dump +# Test the dump utility (I'm not testing the dump cursors, that's what the +# utility uses underneath). +class test_dump(wttest.WiredTigerTestCase, suite_subprocess): + dir='dump.dir' # Backup directory name + + name = 'test_dump' + nentries = 2500 + + dumpfmt = [ + ('hex', dict(hex=1)), + ('txt', dict(hex=0)) + ] + keyfmt = [ + ('integer', dict(keyfmt='i')), + ('recno', dict(keyfmt='r')), + ('string', dict(keyfmt='S')) + ] + types = [ + ('file', dict(type='file:', + populate=simple_populate, + populate_check=simple_populate_check_cursor)), + ('table-simple', dict(type='table:', + populate=simple_populate, + populate_check=simple_populate_check_cursor)), + ('table-complex', dict(type='table:', + populate=complex_populate, + populate_check=complex_populate_check_cursor)) + ] + scenarios = number_scenarios( + multiply_scenarios('.', types, keyfmt, dumpfmt)) + + # Dump, re-load and do a content comparison. + def test_dump(self): + # Create the object. + uri = self.type + self.name + self.populate(self, uri, 'key_format=' + self.keyfmt, self.nentries) + + # Dump and re-load the object. + os.mkdir(self.dir) + if self.hex == 1: + self.runWt(['dump', '-x', uri], outfilename='dump.out') + else: + self.runWt(['dump', uri], outfilename='dump.out') + self.runWt(['-h', self.dir, 'load', '-f', 'dump.out']) + + # Check the loaded contents are correct. + conn = wiredtiger.wiredtiger_open(self.dir) + session = conn.open_session() + cursor = session.open_cursor(uri, None, None) + self.populate_check(self, cursor) + conn.close() + + +if __name__ == '__main__': + wttest.run() |