summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2017-08-25 15:28:56 -0400
committerBernard Gorman <bernard.gorman@gmail.com>2018-05-25 16:35:01 -0400
commitae53ff0702ae4e9b8432564afcc8eb193c02fc27 (patch)
treec080a15bc3cabbb1d605103637a47b1a3e4765ef /jstests
parentae478a54041292e32f40aec32162276ad62355f5 (diff)
downloadmongo-ae53ff0702ae4e9b8432564afcc8eb193c02fc27.tar.gz
SERVER-30557 Make max_time_ms.js more robust
(cherry picked from commit c07190d3bba7b755d234f8c722ba87213a29cd81)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/max_time_ms.js90
1 files changed, 45 insertions, 45 deletions
diff --git a/jstests/core/max_time_ms.js b/jstests/core/max_time_ms.js
index efe3dabcc6d..e50e70560f6 100644
--- a/jstests/core/max_time_ms.js
+++ b/jstests/core/max_time_ms.js
@@ -51,23 +51,23 @@ assert.doesNotThrow(function() {
//
// Simple positive test for getmore:
// - Issue a find() that returns 2 batches: a fast batch, then a slow batch.
-// - The find() has a 1-second time limit; the first batch should run "instantly", but the second
+// - The find() has a 4-second time limit; the first batch should run "instantly", but the second
// batch takes ~15 seconds, so the getmore should be aborted.
//
t.drop();
-t.insert([{}, {}, {}]); // fast batch
-t.insert([{slow: true}, {slow: true}, {slow: true}]); // slow batch
+t.insert([{_id: 0}, {_id: 1}, {_id: 2}]); // fast batch
+t.insert([{_id: 3, slow: true}, {_id: 4, slow: true}, {_id: 5, slow: true}]); // slow batch
cursor = t.find({
- $where: function() {
- if (this.slow) {
- sleep(5 * 1000);
- }
- return true;
- }
-});
+ $where: function() {
+ if (this.slow) {
+ sleep(5 * 1000);
+ }
+ return true;
+ }
+ }).sort({_id: 1});
cursor.batchSize(3);
-cursor.maxTimeMS(1000);
+cursor.maxTimeMS(4 * 1000);
assert.doesNotThrow(function() {
cursor.next();
cursor.next();
@@ -87,16 +87,16 @@ assert.throws(function() {
//
t.drop();
-t.insert([{}, {}, {}]); // fast batch
-t.insert([{}, {}, {slow: true}]); // slow batch
+t.insert([{_id: 0}, {_id: 1}, {_id: 2}]); // fast batch
+t.insert([{_id: 3}, {_id: 4}, {_id: 5, slow: true}]); // slow batch
cursor = t.find({
- $where: function() {
- if (this.slow) {
- sleep(2 * 1000);
- }
- return true;
- }
-});
+ $where: function() {
+ if (this.slow) {
+ sleep(2 * 1000);
+ }
+ return true;
+ }
+ }).sort({_id: 1});
cursor.batchSize(3);
cursor.maxTimeMS(10 * 1000);
assert.doesNotThrow(function() {
@@ -118,16 +118,16 @@ assert.doesNotThrow(function() {
t.drop();
for (var i = 0; i < 5; i++) {
- t.insert([{}, {}, {slow: true}]);
+ t.insert([{_id: 3 * i}, {_id: (3 * i) + 1}, {_id: (3 * i) + 2, slow: true}]);
}
cursor = t.find({
- $where: function() {
- if (this.slow) {
- sleep(2 * 1000);
- }
- return true;
- }
-});
+ $where: function() {
+ if (this.slow) {
+ sleep(2 * 1000);
+ }
+ return true;
+ }
+ }).sort({_id: 1});
cursor.batchSize(3);
cursor.maxTimeMS(6 * 1000);
assert.throws(function() {
@@ -142,16 +142,16 @@ assert.throws(function() {
t.drop();
for (var i = 0; i < 5; i++) {
- t.insert([{}, {}, {slow: true}]);
+ t.insert([{_id: 3 * i}, {_id: (3 * i) + 1}, {_id: (3 * i) + 2, slow: true}]);
}
cursor = t.find({
- $where: function() {
- if (this.slow) {
- sleep(2 * 1000);
- }
- return true;
- }
-});
+ $where: function() {
+ if (this.slow) {
+ sleep(2 * 1000);
+ }
+ return true;
+ }
+ }).sort({_id: 1});
cursor.batchSize(3);
cursor.maxTimeMS(20 * 1000);
assert.doesNotThrow(function() {
@@ -356,16 +356,16 @@ assert.eq(1, t.getDB().adminCommand({configureFailPoint: "maxTimeAlwaysTimeOut",
// maxTimeNeverTimeOut positive test for getmore.
t.drop();
-t.insert([{}, {}, {}]); // fast batch
-t.insert([{slow: true}, {slow: true}, {slow: true}]); // slow batch
+t.insert([{_id: 0}, {_id: 1}, {_id: 2}]); // fast batch
+t.insert([{_id: 3, slow: true}, {_id: 4, slow: true}, {_id: 5, slow: true}]); // slow batch
cursor = t.find({
- $where: function() {
- if (this.slow) {
- sleep(2 * 1000);
- }
- return true;
- }
-});
+ $where: function() {
+ if (this.slow) {
+ sleep(2 * 1000);
+ }
+ return true;
+ }
+ }).sort({_id: 1});
cursor.batchSize(3);
cursor.maxTimeMS(2 * 1000);
assert.doesNotThrow(function() {