summaryrefslogtreecommitdiff
path: root/jstests/replsets/read_after_optime.js
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-09-28 17:44:20 -0400
committerBenety Goh <benety@mongodb.com>2016-09-29 10:18:52 -0400
commit0c481b535b57a1f2ab11cedf3547e74ec1178b50 (patch)
tree1751b0675fbb0eeab6bc14634f67e20d787adf6f /jstests/replsets/read_after_optime.js
parent8e5e8f0fc17c60c9bd1bf72611eac2cf084b57b6 (diff)
downloadmongo-0c481b535b57a1f2ab11cedf3547e74ec1178b50.tar.gz
SERVER-26379 read_after_optime.js should wait for parallel shell to start before running find command
Diffstat (limited to 'jstests/replsets/read_after_optime.js')
-rw-r--r--jstests/replsets/read_after_optime.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/jstests/replsets/read_after_optime.js b/jstests/replsets/read_after_optime.js
index 3b821fcf8ce..bb0e041c05f 100644
--- a/jstests/replsets/read_after_optime.js
+++ b/jstests/replsets/read_after_optime.js
@@ -9,7 +9,8 @@
var config = replTest.getReplSetConfigFromNode();
var runTest = function(testDB, primaryConn) {
- primaryConn.getDB('test').user.insert({x: 1}, {writeConcern: {w: 2}});
+ var dbName = testDB.getName();
+ assert.writeOK(primaryConn.getDB(dbName).user.insert({x: 1}, {writeConcern: {w: 2}}));
var localDB = primaryConn.getDB('local');
@@ -76,9 +77,18 @@
checkLog(msg, 2);
// Test read on future afterOpTime that will eventually occur.
- var insertFunc = startParallelShell(
- "sleep(2100); db.user.insert({ y: 1 }, { writeConcern: { w: 2 }});", primaryConn.port);
-
+ primaryConn.getDB(dbName).parallelShellStarted.drop();
+ var insertFunc =
+ startParallelShell('let testDB = db.getSiblingDB("' + dbName + '"); ' +
+ 'testDB.parallelShellStarted.insert({}); ' +
+ 'sleep(2100); ' +
+ 'testDB.user.insert({y: 1}, { writeConcern: { w: 2 }});',
+ primaryConn.port);
+ assert.soon(function() {
+ return primaryConn.getDB(dbName).parallelShellStarted.count();
+ });
+
+ oplogTS = localDB.oplog.rs.find().sort({$natural: -1}).limit(1).next();
var twoSecTS = new Timestamp(oplogTS.ts.getTime() + 2, 0);
var res = assert.commandWorked(testDB.runCommand({
find: 'user',
@@ -95,9 +105,8 @@
};
var primary = replTest.getPrimary();
- runTest(primary.getDB('test'), primary);
- runTest(replTest.getSecondary().getDB('test'), primary);
+ runTest(primary.getDB('test1'), primary);
+ runTest(replTest.getSecondary().getDB('test2'), primary);
replTest.stopSet();
-
})();