summaryrefslogtreecommitdiff
path: root/jstests/disk/norepeat.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
committerAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
commit4eefaf421bfeddf040d96a3dafb12e09673423d7 (patch)
treecb2e5ccc7f98158894f977ff131949da36673591 /jstests/disk/norepeat.js
downloadmongodb-4eefaf421bfeddf040d96a3dafb12e09673423d7.tar.gz
Imported Upstream version 1.3.1
Diffstat (limited to 'jstests/disk/norepeat.js')
-rw-r--r--jstests/disk/norepeat.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/jstests/disk/norepeat.js b/jstests/disk/norepeat.js
new file mode 100644
index 0000000..d9f1cd3
--- /dev/null
+++ b/jstests/disk/norepeat.js
@@ -0,0 +1,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, autoIdIndex: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 );
+*/