summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2015-11-05 14:22:49 -0500
committerGeert Bosch <geert@mongodb.com>2017-01-25 14:03:21 -0500
commit36d0d2daf79b3b62852ae795e104a74f93e8a9b7 (patch)
treeadf75a64d169ab6ec0b853c638f70f76dfcf8358
parentf888e8dcce90f70d052099aecff82e62964ae3fe (diff)
downloadmongo-36d0d2daf79b3b62852ae795e104a74f93e8a9b7.tar.gz
SERVER-21480: remove race condition in ttl1.js
(cherry picked from commit 56943a545ab503b11b747bb40779ab01be58766b)
-rw-r--r--jstests/noPassthroughWithMongod/ttl1.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/jstests/noPassthroughWithMongod/ttl1.js b/jstests/noPassthroughWithMongod/ttl1.js
index a2d923fc9f5..11469cf2f47 100644
--- a/jstests/noPassthroughWithMongod/ttl1.js
+++ b/jstests/noPassthroughWithMongod/ttl1.js
@@ -56,10 +56,13 @@ t.ensureIndex( { x : 1 } , { expireAfterSeconds : 20000 } );
assert.soon(
function() {
return t.count() < 30;
- }, "TTL index on x didn't delete" , 70 * 1000
-);
+ }, "TTL index on x didn't delete" , 70 * 1000);
-assert.eq( 0 , t.find( { x : { $lt : new Date( now - 20000000 ) } } ).count() );
+// We know the TTL thread has started deleting. Wait a few seconds to give it a chance to finish.
+assert.soon(
+ function() {
+ return t.find( { x : { $lt : new Date( now - ( 20000 * 1000 ) ) } } ).count() === 0;
+ }, "TTL index on x didn't finish deleting", 5 * 1000);
assert.eq( 12 , t.count() );
assert.lte( 18, db.serverStatus().metrics.ttl.deletedDocuments );
@@ -71,8 +74,10 @@ t.ensureIndex( { y : 1 } , { expireAfterSeconds : 10000 } );
assert.soon(
function() {
return t.count() < 12;
- }, "TTL index on y didn't delete" , 70 * 1000
-);
+ }, "TTL index on y didn't delete" , 70 * 1000);
-assert.eq( 0 , t.find( { y : { $lt : new Date( now - 10000000 ) } } ).count() );
+assert.soon(
+ function() {
+ return t.find( { y : { $lt : new Date( now - ( 10000 * 1000 ) ) } } ).count() === 0;
+ }, "TTL index on y didn't finish deleting", 5 * 1000);
assert.eq( 9 , t.count() );