summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2012-04-24 13:36:16 -0700
committerAaron <aaron@10gen.com>2012-04-24 19:56:25 -0700
commit961ce2b665e97251ed988f20ba3dff09209aaab9 (patch)
treea5858a21039bee4b0effe98690df836a51a332a4 /jstests
parenta819ffa4b40cc3905fac6a11db9ae04da9bd401d (diff)
downloadmongo-961ce2b665e97251ed988f20ba3dff09209aaab9.tar.gz
Try to clarify repl13 test.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/repl/repl13.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/jstests/repl/repl13.js b/jstests/repl/repl13.js
index 403effeb846..460e5a8fdde 100644
--- a/jstests/repl/repl13.js
+++ b/jstests/repl/repl13.js
@@ -1,10 +1,17 @@
// Test update modifier uassert during initial sync. SERVER-4781
+function debug( x ) {
+ if ( 0 ) {
+ printjson( x );
+ }
+}
+
rt = new ReplTest( "repl13tests" );
m = rt.start( true );
mc = m.getDB( 'd' )[ 'c' ];
+// Insert some documents with a:{} fields.
for( i = 0; i < 100000; ++i ) {
mc.save( {_id:i,a:{}} );
}
@@ -13,16 +20,27 @@ m.getDB( 'd' ).getLastError();
s = rt.start( false );
sc = s.getDB( 'd' )[ 'c' ];
-assert.soon( function() { printjson( sc.count() ); return sc.count() > 0; } );
+// Wait for the initial clone to begin.
+assert.soon( function() { debug( sc.count() ); return sc.count() > 0; } );
+// Update documents that will be cloned last with the intent that an updated version will be cloned.
+// This may cause an assertion when an update that was successfully applied to the original version
+// of a document is replayed against an updated version of the same document.
for( i = 99999; i >= 90000; --i ) {
// If the document is cloned as {a:1}, the {$set:{'a.b':1}} modifier will uassert.
mc.update( {_id:i}, {$set:{'a.b':1}} );
mc.update( {_id:i}, {$set:{a:1}} );
}
-mc.save( {} )
+// The initial sync completes and subsequent writes succeed, in spite of any assertions that occur
+// when the update operations above are replicated.
+mc.save( {} );
assert.soon( function() { return sc.count() == 100001; } );
+mc.save( {} );
+assert.soon( function() { return sc.count() == 100002; } );
+
+debug( sc.findOne( {_id:99999} ) );
+debug( sc.findOne( {_id:90000} ) );
-printjson( sc.findOne( {_id:99999} ) );
-printjson( sc.findOne( {_id:90000} ) );
+assert.eq( 1, sc.findOne( {_id:99999} ).a );
+assert.eq( 1, sc.findOne( {_id:90000} ).a );