summaryrefslogtreecommitdiff
path: root/jstests/repl
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2012-02-12 15:59:53 -0800
committerAaron <aaron@10gen.com>2012-02-12 15:59:53 -0800
commitff08bdf03056665a1cc8366afe7de73cb1c237f8 (patch)
treedb068927522a9c32326e674d417ae5ce5d884ad0 /jstests/repl
parent48c1fe51df8736f12be2954e61d9516f25cb2b46 (diff)
downloadmongo-ff08bdf03056665a1cc8366afe7de73cb1c237f8.tar.gz
SERVER-4944 test
Diffstat (limited to 'jstests/repl')
-rw-r--r--jstests/repl/repl20.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/jstests/repl/repl20.js b/jstests/repl/repl20.js
new file mode 100644
index 00000000000..02e50f58f1f
--- /dev/null
+++ b/jstests/repl/repl20.js
@@ -0,0 +1,41 @@
+// Test initial sync cloning of a $pull operation.
+// SERVER-4944
+
+if ( 0 ) { // SERVER-4944
+
+rt = new ReplTest( "repl20tests" );
+
+master = rt.start( true );
+mc = master.getDB( 'd' )[ 'c' ];
+
+for( i = 0; i < 100000; ++i ) {
+ mc.insert( { _id:i, z:i } );
+}
+
+targetId = 1000*1000;
+mc.insert( { _id:targetId, val:[ 1 ] } );
+master.getDB( 'd' ).getLastError();
+
+slave = rt.start( false );
+sc = slave.getDB( 'd' )[ 'c' ];
+
+// Wait for slave to start cloning.
+assert.soon( function() { c = sc.count(); /*print( c );*/ return c > 0; } );
+
+// $pull the '1' element.
+mc.update( { _id:targetId }, { $pull:{ val:1 } } );
+// $push a new '1' element.
+mc.update( { _id:targetId }, { $push:{ val:1 } } );
+// $push a new '2' element.
+mc.update( { _id:targetId }, { $push:{ val:2 } } );
+
+mc.insert( { _id:'sentinel' } );
+
+// Wait for the updates to be applied.
+assert.soon( function() { return sc.count( { _id:'sentinel' } ) > 0; } );
+
+// Check that the val array is as expected.
+assert.eq( [ 1, 2 ], mc.findOne( { _id:targetId } ).val );
+assert.eq( [ 1, 2 ], sc.findOne( { _id:targetId } ).val );
+
+}