diff options
author | Tad Marshall <tad@10gen.com> | 2013-06-10 06:05:19 -0400 |
---|---|---|
committer | Dan Pasette <dan@10gen.com> | 2013-06-19 19:04:43 -0400 |
commit | 9f975ab30ef2f579ea2bbb2bebeadd7abf1d69d2 (patch) | |
tree | e9461649f3a212388fadc787fa6d7e4e5bfe3f15 /jstests | |
parent | 6ab83d2992c3432f03951ca96a8d5f078a954664 (diff) | |
download | mongo-9f975ab30ef2f579ea2bbb2bebeadd7abf1d69d2.tar.gz |
SERVER-9824 Add jstest
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/grow_hash_table.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/jstests/grow_hash_table.js b/jstests/grow_hash_table.js new file mode 100644 index 00000000000..3e148b7240f --- /dev/null +++ b/jstests/grow_hash_table.js @@ -0,0 +1,45 @@ +// This test creates a large projection, which causes a set of field names to +// be stored in a StringMap (based on UnorderedFastKeyTable). The hash table +// starts with 20 slots, but must be grown repeatedly to hold the complete set +// of fields. This test verifies that we can grow the hash table repeatedly +// with no failures. +// +// Related to SERVER-9824. + +var testDB = db.getSiblingDB('grow_hash_table'); + +var doTest = function(count) { + print('Testing with count of ' + count); + testDB.dropDatabase(); + var id = { data: 1 }; + var doc = { _id: id }; + var projection = { }; + + // Create a document and a projection with fields r1, r2, r3 ... + for (var i = 1; i <= count; ++i) { + var r = 'r' + i; + doc[r] = i; + projection[r] = 1; + } + + // Store the document + testDB.collection.insert(doc); + var errorObj = testDB.getLastErrorObj(); + assert(errorObj.err == null, + 'Failed to insert document, getLastErrorObj = ' + tojsononeline(errorObj)); + + // Try to read the document using a large projection + try { + var findCount = testDB.collection.find({ _id: id }, projection).itcount(); + assert(findCount == 1, + 'Failed to find single stored document, find().itcount() == ' + findCount); + } + catch (e) { + testDB.dropDatabase(); + doassert('Test FAILED! Caught exception ' + tojsononeline(e)); + } + testDB.dropDatabase(); + jsTest.log('Test PASSED'); +} + +doTest(10000); |