~ubuntu-branches/ubuntu/trusty/mongodb/trusty-proposed

« back to all changes in this revision

Viewing changes to jstests/disk/norepeat.js

  • Committer: Bazaar Package Importer
  • Author(s): Antonin Kral
  • Date: 2010-01-29 19:48:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100129194845-8wbmkf626fwcavc9
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
baseName = "jstests_disk_norepeat";
 
3
 
 
4
ports = allocatePorts( 1 );
 
5
m = startMongod( "--port", ports[ 0 ], "--deDupMem", "200", "--dbpath", "/data/db/" + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
 
6
 
 
7
t = m.getDB( baseName ).getCollection( baseName );
 
8
 
 
9
t.drop();
 
10
t.ensureIndex( { i: 1 } );
 
11
for( i = 0; i < 3; ++i ) {
 
12
    t.save( { i: i } );
 
13
}
 
14
 
 
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" );
 
21
 
 
22
// now force upgrade to disk storage
 
23
 
 
24
t.drop();
 
25
t.ensureIndex( { i: 1 } );
 
26
for( i = 0; i < 10; ++i ) {
 
27
    t.save( { i: i } );
 
28
}
 
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 ) {
 
34
    if ( i == 7 ) {
 
35
        t.update( { i: 6 }, { i: 11 } );
 
36
        t.update( { i: 9 }, { i: 12 } );
 
37
    }
 
38
    if ( i == 9 ) {
 
39
        i = 12;
 
40
    }
 
41
    assert.eq( i, c.next().i );
 
42
}
 
43
assert.throws( function() { c.next() }, [], "unexpected: object found" );
 
44
 
 
45
m.getDB( "local" ).getCollectionNames().forEach( function( x ) { assert( !x.match( /^temp/ ), "temp collection found" ); } );
 
46
 
 
47
t.drop();
 
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"} );
 
53
 
 
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() );
 
59
 
 
60
assert( t.validate().valid );
 
61
*/