diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-07-30 09:23:00 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-08-01 10:44:29 -0400 |
commit | ebec63d57182db2d21bdcd3b7a95636c06991190 (patch) | |
tree | 196565145b430396c9803ff000554f7a562e96aa /jstests/mmap_v1 | |
parent | d7a94e259c94a46feab8fabebbd8c4dc0eebce8f (diff) | |
download | mongo-ebec63d57182db2d21bdcd3b7a95636c06991190.tar.gz |
SERVER-13635: move mmap_v1 specific tests and make other generic
Diffstat (limited to 'jstests/mmap_v1')
-rw-r--r-- | jstests/mmap_v1/update.js | 40 | ||||
-rw-r--r-- | jstests/mmap_v1/use_power_of_2.js | 52 |
2 files changed, 92 insertions, 0 deletions
diff --git a/jstests/mmap_v1/update.js b/jstests/mmap_v1/update.js new file mode 100644 index 00000000000..37bf6378c64 --- /dev/null +++ b/jstests/mmap_v1/update.js @@ -0,0 +1,40 @@ + +asdf = db.getCollection( "asdf" ); +asdf.drop(); + +var txt = "asdf"; +for(var i=0; i<10; i++) { + txt = txt + txt; +} + +var iterations = _isWindows() ? 2500 : 5000 + +// fill db +for(var i=1; i<=iterations; i++) { + var obj = {txt : txt}; + asdf.save(obj); + + var obj2 = {txt: txt, comments: [{num: i, txt: txt}, {num: [], txt: txt}, {num: true, txt: txt}]}; + asdf.update(obj, obj2); + + if(i%100 == 0) { + var c = asdf.count(); + assert.eq(c , i); + } +} + +assert(asdf.validate().valid); + +var stats = db.runCommand({ collstats: "asdf" }); + +// some checks. want to check that padding factor is working; in addition this lets us do a little basic +// testing of the collstats command at the same time +assert(stats.count == iterations); +assert(stats.size < 140433012 * 5 && stats.size > 1000000); +assert(stats.numExtents < 20); +assert(stats.nindexes == 1); +var pf = stats.paddingFactor; +print("update.js padding factor: " + pf); +assert(pf > 1.7 && pf <= 2); + +asdf.drop(); diff --git a/jstests/mmap_v1/use_power_of_2.js b/jstests/mmap_v1/use_power_of_2.js new file mode 100644 index 00000000000..8eb24233cf1 --- /dev/null +++ b/jstests/mmap_v1/use_power_of_2.js @@ -0,0 +1,52 @@ +/* + * This test ensures that the usePowerOf2 user flag effectively reuses space. + */ + +// prepare a doc of 14K +var doc = { _id: new Object(), data: "a" }; +var bigDoc = { _id: new Object(), data: "a" }; + +while (doc.data.length < 14 * 1024) doc.data += "a"; +while (bigDoc.data.length < 15 * 1024) bigDoc.data += "a"; + +var collName = "usepower1"; +var t = db.getCollection(collName); + +function checkStorageSize(expectedSize, sameLoc) { + t.insert(doc); + assert.eq(t.stats().size, expectedSize, "size should be expected"); + + var oldLoc = t.find()._addSpecial("$showDiskLoc" , true).toArray()[0].$diskLoc; + + // Remvoe smaller doc, insert a bigger one. + t.remove(doc); + t.insert(bigDoc); + + var newLoc = t.find()._addSpecial("$showDiskLoc" , true).toArray()[0].$diskLoc; + + // Check the diskloc of two docs. + assert.eq(oldLoc.file == newLoc.file && oldLoc.offset == newLoc.offset, sameLoc); +} + +t.drop(); +db.createCollection(collName); +var res = db.runCommand( { "collMod" : collName , "usePowerOf2Sizes" : false } ); +assert( res.ok, "collMod failed" ); +checkStorageSize(15344, false); // 15344 = 14369 (bsonsize) + overhead + +t.drop(); +db.createCollection(collName); +var res = db.runCommand( { "collMod" : collName , "usePowerOf2Sizes" : true } ); +assert( res.ok, "collMod failed" ); +checkStorageSize(16 * 1023, true); // power of 2 + + +// Create collection with flag +t.drop(); +db.runCommand({"create" : collName, "flags" : 0 }); +checkStorageSize(15344, false); + +t.drop(); +db.runCommand({"create" : collName, "flags" : 1 }); +checkStorageSize(16 * 1023, true); // power of 2 + |