diff options
author | David Storch <david.storch@10gen.com> | 2014-04-15 09:58:30 -0400 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-04-15 18:44:28 -0400 |
commit | 12279052c851ae5a1ed43d98433ced9db7682d3a (patch) | |
tree | 77fad4f4bf02f8a51c66e9c179dec4e53e8e2d48 /jstests | |
parent | 5636fd6504b1b5a649468e62f48b7bae00f24b0f (diff) | |
download | mongo-12279052c851ae5a1ed43d98433ced9db7682d3a.tar.gz |
SERVER-13566 oplog start stage uses only 'ts' field as a filter
(cherry picked from commit 29d7dcd55a761cfa6a1a7e1586b80f9d1083b4f4)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/query_oplogreplay.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/jstests/core/query_oplogreplay.js b/jstests/core/query_oplogreplay.js new file mode 100644 index 00000000000..ab291af2be1 --- /dev/null +++ b/jstests/core/query_oplogreplay.js @@ -0,0 +1,45 @@ +// Test queries that set the OplogReplay flag. + +var t = db.jstests_query_oplogreplay; +t.drop(); + +for (var i = 0; i < 100; i++) { + t.save({_id: i, ts: i}); +} + +// Missing 'ts' field. +assert.throws(function() { + t.find().addOption(DBQuery.Option.oplogReplay).next(); +}); +assert.throws(function() { + t.find({_id: 3}).addOption(DBQuery.Option.oplogReplay).next(); +}); + +// 'ts' field is not top-level. +assert.throws(function() { + t.find({$or: [{ts: {$gt: 3}}, {foo: 3}]}) + .addOption(DBQuery.Option.oplogReplay).next(); +}); +assert.throws(function() { + t.find({$nor: [{ts: {$gt: 4}}, {foo: 4}]}) + .addOption(DBQuery.Option.oplogReplay).next(); +}); + +// Predicate over 'ts' is not $gt or $gte. +assert.throws(function() { + t.find({ts: {$lt: 4}}).addOption(DBQuery.Option.oplogReplay).next(); +}); +assert.throws(function() { + t.find({ts: {$lt: 4}, _id: 3}).addOption(DBQuery.Option.oplogReplay).next(); +}); + +// Query on just the 'ts' field. +var cursor = t.find({ts: {$gt: 20}}).addOption(DBQuery.Option.oplogReplay); +assert.eq(21, cursor.next()["_id"]); +assert.eq(22, cursor.next()["_id"]); + +// Query over both 'ts' and '_id' should only pay attention to the 'ts' +// field for finding the oplog start (SERVER-13566). +cursor = t.find({ts: {$gte: 20}, _id: 25}).addOption(DBQuery.Option.oplogReplay); +assert.eq(25, cursor.next()["_id"]); +assert(!cursor.hasNext()); |