1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/**
* Tests that inserting into a time-series collection fails if the corresponding buckets collection
* does not exist.
*/
(function() {
'use strict';
load('jstests/libs/fail_point_util.js');
load("jstests/libs/parallel_shell_helpers.js");
const conn = MongoRunner.runMongod();
const testDB = conn.getDB('test');
const timeFieldName = 'time';
let testCounter = 0;
const runTest = function(ordered, insertBeforeDrop, dropBucketsColl) {
const coll = testDB[jsTestName() + '_' + testCounter++];
assert.commandWorked(
testDB.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
if (insertBeforeDrop) {
assert.commandWorked(coll.insert({_id: 0, [timeFieldName]: ISODate()}));
}
const fp = configureFailPoint(conn, 'hangTimeseriesInsertBeforeWrite');
const awaitDrop = startParallelShell(
funWithArgs(
function(collName, fpName, fpTimesEntered) {
load("jstests/libs/fail_point_util.js");
assert.commandWorked(db.adminCommand({
waitForFailPoint: fpName,
timesEntered: fpTimesEntered + 1,
maxTimeMS: kDefaultWaitForFailPointTimeout,
}));
assert(db[collName].drop());
assert.commandWorked(db.adminCommand({configureFailPoint: fpName, mode: 'off'}));
},
dropBucketsColl ? 'system.buckets.' + coll.getName() : coll.getName(),
fp.failPointName,
fp.timesEntered),
conn.port);
assert.commandFailedWithCode(
coll.insert({_id: 1, [timeFieldName]: ISODate()}, {ordered: ordered}),
ErrorCodes.NamespaceNotFound);
awaitDrop();
};
for (const dropBucketsColl of [false, true]) {
runTest(false /* ordered */, false /* insertBeforeDrop */, dropBucketsColl);
runTest(false /* ordered */, true /* insertBeforeDrop */, dropBucketsColl);
runTest(true /* ordered */, false /* insertBeforeDrop */, dropBucketsColl);
runTest(true /* ordered */, true /* insertBeforeDrop */, dropBucketsColl);
}
MongoRunner.stopMongod(conn);
})();
|