diff options
author | Keith Bostic <keith@wiredtiger.com> | 2016-01-01 16:14:23 -0500 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2016-01-01 16:14:23 -0500 |
commit | da9b67d933e5ad13829ba21d3eada5a7188cb7c7 (patch) | |
tree | e8a5657b24ec2f5954b7a937ec30b09e9590570f /test | |
parent | 67f76e0a711fedc290cb7f5d4319a5fb1a87e831 (diff) | |
parent | f1a56169ba8d6bcaefac26d05aa08d7b170e8b89 (diff) | |
download | mongo-da9b67d933e5ad13829ba21d3eada5a7188cb7c7.tar.gz |
Merge branch 'develop' into wt-2287-rebalance
Diffstat (limited to 'test')
-rw-r--r-- | test/format/ops.c | 2 | ||||
-rw-r--r-- | test/suite/test_compact02.py | 5 | ||||
-rw-r--r-- | test/suite/test_cursor_random02.py | 84 |
3 files changed, 88 insertions, 3 deletions
diff --git a/test/format/ops.c b/test/format/ops.c index c705d362fe8..7e299b7d975 100644 --- a/test/format/ops.c +++ b/test/format/ops.c @@ -504,7 +504,7 @@ skip_insert: if (col_update(tinfo, */ if (!insert) { dir = (int)mmrand(&tinfo->rnd, 0, 1); - for (np = 0; np < mmrand(&tinfo->rnd, 1, 8); ++np) { + for (np = 0; np < mmrand(&tinfo->rnd, 1, 30); ++np) { if (notfound) break; if (nextprev(cursor, dir, ¬found)) diff --git a/test/suite/test_compact02.py b/test/suite/test_compact02.py index 3f3a388a5aa..f2d5c1fa283 100644 --- a/test/suite/test_compact02.py +++ b/test/suite/test_compact02.py @@ -49,11 +49,12 @@ class test_compact02(wttest.WiredTigerTestCase): # There's a balance between the pages we create and the size of the records # being stored: compaction doesn't work on tables with many overflow items # because we don't rewrite them. Experimentally, 8KB is as small as the test - # can go. + # can go. Additionally, we can't set the maximum page size too large because + # there won't be enough pages to rewrite. Experimentally, 32KB (the default) + # is as large as the test can go. fileConfig = [ ('default', dict(fileConfig='')), ('8KB', dict(fileConfig='leaf_page_max=8kb')), - ('128KB', dict(fileConfig='leaf_page_max=128kb')), ] scenarios = \ number_scenarios(multiply_scenarios('.', types, cacheSize, fileConfig)) diff --git a/test/suite/test_cursor_random02.py b/test/suite/test_cursor_random02.py new file mode 100644 index 00000000000..7c9e0e38cb9 --- /dev/null +++ b/test/suite/test_cursor_random02.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# +# Public Domain 2014-2015 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 +from helper import complex_populate, simple_populate +from helper import key_populate, value_populate +from wtscenario import check_scenarios, multiply_scenarios, number_scenarios + +# test_cursor_random02.py +# Cursor next_random operations +class test_cursor_random02(wttest.WiredTigerTestCase): + type = 'table:random' + config = [ + ('not-sample', dict(config='next_random=true')) + ] + records = [ + ('1', dict(records=1)), + ('250', dict(records=250)), + ('500', dict(records=500)), + ('5000', dict(records=5000)), + ('10000', dict(records=10000)), + ('50000', dict(records=50000)), + ] + scenarios = number_scenarios(multiply_scenarios('.', config, records)) + + # Check that next_random works in the presence of a larger set of values, + # where the values are in an insert list. + def test_cursor_random_reasonable_distribution(self): + uri = self.type + num_entries = self.records + + # Set the leaf-page-max value, otherwise the page might split. + simple_populate(self, uri, + 'leaf_page_max=100MB,key_format=S', num_entries) + # Setup an array to track which keys are seen + visitedKeys = [0] * (num_entries + 1) + + cursor = self.session.open_cursor(uri, None, 'next_random=true') + for i in range(0, num_entries): + self.assertEqual(cursor.next(), 0) + current = cursor.get_key() + current = int(current) + visitedKeys[current] = visitedKeys[current] + 1 + + differentKeys = sum(x > 0 for x in visitedKeys) + + #print visitedKeys + #print differentKeys + ''' + self.tty('differentKeys: ' + str(differentKeys) + ' of ' + \ + str(num_entries) + ', ' + \ + str((int)((differentKeys * 100) / num_entries)) + '%') + ''' + + self.assertGreater(differentKeys, num_entries / 4, + 'next_random random distribution not adequate') + +if __name__ == '__main__': + wttest.run() |