summaryrefslogtreecommitdiff
path: root/jstests/repl
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2012-02-12 16:01:33 -0800
committerAaron <aaron@10gen.com>2012-02-12 16:01:33 -0800
commit61c3988d373a3e2d497feb577a4f9a6da334d938 (patch)
tree235bd8f2249641f99367d7724689c358f16554fa /jstests/repl
parentff08bdf03056665a1cc8366afe7de73cb1c237f8 (diff)
downloadmongo-61c3988d373a3e2d497feb577a4f9a6da334d938.tar.gz
SERVER-4945 test
Diffstat (limited to 'jstests/repl')
-rw-r--r--jstests/repl/repl21.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/repl/repl21.js b/jstests/repl/repl21.js
new file mode 100644
index 00000000000..a94a4b5b779
--- /dev/null
+++ b/jstests/repl/repl21.js
@@ -0,0 +1,39 @@
+// Test initial sync cloning of an $addToSet operation.
+// SERVER-4945
+
+if ( 0 ) { // SERVER-4945
+
+rt = new ReplTest( "repl21tests" );
+
+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; } );
+
+// $addToSet the number '2'.
+mc.update( { _id:targetId }, { $addToSet:{ val:2 } } );
+// Modify the value that was just added.
+mc.update( { _id:targetId }, { $set:{ 'val.1':3 } } );
+
+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, 3 ], mc.findOne( { _id:targetId } ).val );
+assert.eq( [ 1, 3 ], sc.findOne( { _id:targetId } ).val );
+
+} \ No newline at end of file