summaryrefslogtreecommitdiff
path: root/jstests/repl/repl14.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/repl/repl14.js')
-rw-r--r--jstests/repl/repl14.js87
1 files changed, 48 insertions, 39 deletions
diff --git a/jstests/repl/repl14.js b/jstests/repl/repl14.js
index 5359221e607..c9d39686034 100644
--- a/jstests/repl/repl14.js
+++ b/jstests/repl/repl14.js
@@ -1,65 +1,74 @@
// Test replication of an array by $push-ing to a missing field in the presence of a sparse index on
// the field. SERVER-4907
-function testWithCollectionIndexIds( capped, sparse, useIds ) {
- printjson( { capped:capped, sparse:sparse, useIds:useIds } );
-
- rt = new ReplTest( "repl14tests" );
-
- m = rt.start( true ); // master
- if ( capped ) {
- m.getDB( 'd' ).createCollection( 'c', { capped:true, size:5*1024 } );
+function testWithCollectionIndexIds(capped, sparse, useIds) {
+ printjson({capped: capped, sparse: sparse, useIds: useIds});
+
+ rt = new ReplTest("repl14tests");
+
+ m = rt.start(true); // master
+ if (capped) {
+ m.getDB('d').createCollection('c', {capped: true, size: 5 * 1024});
}
- mc = m.getDB( 'd' )[ 'c' ]; // master collection
-
- mc.ensureIndex( {a:1}, {sparse:sparse} );
+ mc = m.getDB('d')['c']; // master collection
+
+ mc.ensureIndex({a: 1}, {sparse: sparse});
toInsert = {};
- if ( capped ) {
+ if (capped) {
// Add a singleton array as padding, so the push later on will not change document size.
- toInsert = {p:[1]};
- }
- if ( useIds ) { // Insert wiith an auto generated _id.
- mc.insert( toInsert );
+ toInsert = {
+ p: [1]
+ };
}
- else { // Otherwise avoid the auto generated _id.
- mc._mongo.insert( mc._fullName, toInsert, 0 );
+ if (useIds) { // Insert wiith an auto generated _id.
+ mc.insert(toInsert);
+ } else { // Otherwise avoid the auto generated _id.
+ mc._mongo.insert(mc._fullName, toInsert, 0);
}
assert.eq(mc.count(), 1);
-
- s = rt.start( false ); // slave
- sc = s.getDB( 'd' )[ 'c' ]; // slave collection
+
+ s = rt.start(false); // slave
+ sc = s.getDB('d')['c']; // slave collection
// Wait for the document to be cloned.
- assert.soon( function() { return sc.count() > 0; },"doc not replicated soon enough", 60*1000 );
-
- modifiers = {$push:{a:1}};
- if ( capped ) {
+ assert.soon(function() {
+ return sc.count() > 0;
+ }, "doc not replicated soon enough", 60 * 1000);
+
+ modifiers = {
+ $push: {a: 1}
+ };
+ if (capped) {
// Delete our singleton array to balance the new singleton array we're going to create.
- modifiers['$unset'] = {p:1};
+ modifiers['$unset'] = {
+ p: 1
+ };
}
- assert.writeOK(mc.update( {}, modifiers ));
-
+ assert.writeOK(mc.update({}, modifiers));
+
// Wait for the update to be replicated.
- assert.soon( function() { return sc.count( {a:1} ) > 0; } );
-
+ assert.soon(function() {
+ return sc.count({a: 1}) > 0;
+ });
+
rt.stop();
}
-function testWithCollectionIndex( capped, sparse ) {
- testWithCollectionIndexIds( capped, sparse, true );
- if ( capped ) {
- testWithCollectionIndexIds( capped, sparse, false );
+function testWithCollectionIndex(capped, sparse) {
+ testWithCollectionIndexIds(capped, sparse, true);
+ if (capped) {
+ testWithCollectionIndexIds(capped, sparse, false);
}
}
-function testWithCollection( capped ) {
- testWithCollectionIndex( capped, true );
- testWithCollectionIndex( capped, false );
+function testWithCollection(capped) {
+ testWithCollectionIndex(capped, true);
+ testWithCollectionIndex(capped, false);
}
function test() {
- testWithCollection( true );
- testWithCollection( false );
+ testWithCollection(true);
+ testWithCollection(false);
}
test();