diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-08-04 12:33:52 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-08-05 08:51:41 -0400 |
commit | addfc302ecf617dfe46e4ce09d629e6bf8367f85 (patch) | |
tree | 2bfe6c2196492faf2052d46a2ea07c1ead623824 /jstests/mmap_v1/capped3.js | |
parent | 5d311d9f0583e3d74ce1aa47c66965cd0b39276f (diff) | |
download | mongo-addfc302ecf617dfe46e4ce09d629e6bf8367f85.tar.gz |
SERVER-13635: make all capped jstests generic
Diffstat (limited to 'jstests/mmap_v1/capped3.js')
-rw-r--r-- | jstests/mmap_v1/capped3.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/jstests/mmap_v1/capped3.js b/jstests/mmap_v1/capped3.js new file mode 100644 index 00000000000..2e5e6790cb7 --- /dev/null +++ b/jstests/mmap_v1/capped3.js @@ -0,0 +1,45 @@ +t = db.jstests_capped3; +t2 = db.jstests_capped3_clone; +t.drop(); +t2.drop(); +for( i = 0; i < 1000; ++i ) { + t.save( {i:i} ); +} +assert.commandWorked( db.runCommand( { cloneCollectionAsCapped:"jstests_capped3", toCollection:"jstests_capped3_clone", size:100000 } ), "A" ); +c = t2.find(); +for( i = 0; i < 1000; ++i ) { + assert.eq( i, c.next().i, "B" ); +} +assert( !c.hasNext(), "C" ); + +t.drop(); +t2.drop(); + +for( i = 0; i < 1000; ++i ) { + t.save( {i:i} ); +} +assert.commandWorked( db.runCommand( { cloneCollectionAsCapped:"jstests_capped3", toCollection:"jstests_capped3_clone", size:1000 } ), "D" ); +c = t2.find().sort( {$natural:-1} ); +i = 999; +while( c.hasNext() ) { + assert.eq( i--, c.next().i, "E" ); +} +//print( "i: " + i ); +var str = tojson( t2.stats() ); +//print( "stats: " + tojson( t2.stats() ) ); +assert( i < 990, "F" ); + +t.drop(); +t2.drop(); + +for( i = 0; i < 1000; ++i ) { + t.save( {i:i} ); +} +assert.commandWorked( t.convertToCapped( 1000 ), "G" ); +c = t.find().sort( {$natural:-1} ); +i = 999; +while( c.hasNext() ) { + assert.eq( i--, c.next().i, "H" ); +} +assert( i < 990, "I" ); +assert( i > 900, "J" ); |