diff options
author | Robert Guo <robert.guo@10gen.com> | 2016-04-14 11:42:16 -0400 |
---|---|---|
committer | Robert Guo <robert.guo@10gen.com> | 2016-04-14 14:48:14 -0400 |
commit | f727ca5fc4ba892273b86f0c87df9832984c1fc1 (patch) | |
tree | f4f1ffd42b88010b44129375f09888cb79433ba9 /jstests/noPassthroughWithMongod | |
parent | 4562dd814feb56086d1af158a64e5dad3a6018aa (diff) | |
download | mongo-f727ca5fc4ba892273b86f0c87df9832984c1fc1.tar.gz |
SERVER-23604 make validate_interrupt.js not depend on timing
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r-- | jstests/noPassthroughWithMongod/validate_interrupt.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/jstests/noPassthroughWithMongod/validate_interrupt.js b/jstests/noPassthroughWithMongod/validate_interrupt.js index 6b471953aa8..758eaa6839b 100644 --- a/jstests/noPassthroughWithMongod/validate_interrupt.js +++ b/jstests/noPassthroughWithMongod/validate_interrupt.js @@ -1,4 +1,5 @@ -// Tests that the validate command can be interrupted by specifying a low maxTimeMS. +// Tests that the validate command can be interrupted by enabling the maxTimeAlwaysTimeOut +// failpoint. This should cause validate() to fail with an ExceededTimeLimit error. 'use strict'; @@ -14,19 +15,32 @@ } assert.writeOK(bulk.execute()); + function setTimeoutFailPoint(mode) { + var res = db.adminCommand({configureFailPoint: 'maxTimeAlwaysTimeOut', mode: mode}); + assert.commandWorked(res); + } + + setTimeoutFailPoint('alwaysOn'); var res = t.runCommand({validate: t.getName(), full: true, maxTimeMS: 1}); + setTimeoutFailPoint('off'); + + // Sanity check to make sure the failpoint is turned off. + assert.commandWorked(t.runCommand({validate: t.getName(), full: true})); if (res.ok === 0) { - assert.eq(res.code, ErrorCodes.ExceededTimeLimit, 'validate command did not time out'); + assert.eq(res.code, + ErrorCodes.ExceededTimeLimit, + 'validate command did not time out:\n' + tojson(res)); } else { // validate() should only succeed if it EBUSY'd. See SERVER-23131. var numWarnings = res.warnings.length; // validate() could EBUSY when verifying the index and/or the RecordStore, so EBUSY could // appear once or twice. - assert((numWarnings === 1) || (numWarnings === 2), tojson(res)); - assert(res.warnings[0].includes('EBUSY'), tojson(res)); + assert((numWarnings === 1) || (numWarnings === 2), + 'Expected 1 or 2 validation warnings:\n' + tojson(res)); + assert(res.warnings[0].includes('EBUSY'), 'Expected an EBUSY warning:\n' + tojson(res)); if (numWarnings === 2) { - assert(res.warnings[1].includes('EBUSY'), tojson(res)); + assert(res.warnings[1].includes('EBUSY'), 'Expected an EBUSY warning:\n' + tojson(res)); } } })(); |