1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
/*
baseName = "jstests_disk_norepeat";
ports = allocatePorts( 1 );
m = startMongod( "--port", ports[ 0 ], "--deDupMem", "200", "--dbpath", "/data/db/" + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
t = m.getDB( baseName ).getCollection( baseName );
t.drop();
t.ensureIndex( { i: 1 } );
for( i = 0; i < 3; ++i ) {
t.save( { i: i } );
}
c = t.find().hint( { i: 1 } ).limit( 2 );
assert.eq( 0, c.next().i );
t.update( { i: 0 }, { i: 3 } );
assert.eq( 1, c.next().i );
assert.eq( 2, c.next().i );
assert.throws( function() { c.next() }, [], "unexpected: object found" );
// now force upgrade to disk storage
t.drop();
t.ensureIndex( { i: 1 } );
for( i = 0; i < 10; ++i ) {
t.save( { i: i } );
}
// apparently this means we also request 2 in subsequent getMore's
c = t.find().hint( {i:1} ).limit( 2 );
assert.eq( 0, c.next().i );
t.update( { i: 0 }, { i: 10 } );
for( i = 1; i < 10; ++i ) {
if ( i == 7 ) {
t.update( { i: 6 }, { i: 11 } );
t.update( { i: 9 }, { i: 12 } );
}
if ( i == 9 ) {
i = 12;
}
assert.eq( i, c.next().i );
}
assert.throws( function() { c.next() }, [], "unexpected: object found" );
m.getDB( "local" ).getCollectionNames().forEach( function( x ) { assert( !x.match( /^temp/ ), "temp collection found" ); } );
t.drop();
m.getDB( baseName ).createCollection( baseName, { capped:true, size:100000, autoIndexId:false } );
t = m.getDB( baseName ).getCollection( baseName );
t.insert( {_id:"a"} );
t.insert( {_id:"a"} );
t.insert( {_id:"a"} );
c = t.find().limit( 2 );
assert.eq( "a", c.next()._id );
assert.eq( "a", c.next()._id );
assert.eq( "a", c.next()._id );
assert( !c.hasNext() );
assert( t.validate().valid );
*/
|