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