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
65
66
67
68
69
70
|
/**
* Test the behavior of a dropDatabase command during an aggregation containing $out.
*
* @tags: [
* assumes_unsharded_collection,
* do_not_wrap_aggregations_in_facets,
* assumes_read_concern_unchanged,
* requires_replication,
* requires_sharding,
* ]
*/
(function() {
"use strict";
load("jstests/libs/curop_helpers.js"); // For waitForCurOpByFailPointNoNS.
load("jstests/libs/fixture_helpers.js"); // For FixtureHelpers.
load("jstests/noPassthrough/libs/index_build.js");
function runTest(st, testDb, portNum) {
const failpointName = "outWaitAfterTempCollectionCreation";
const coll = testDb.out_source_coll;
coll.drop();
const targetColl = testDb.out_target_coll;
targetColl.drop();
assert.commandWorked(coll.insert({val: 0}));
assert.commandWorked(coll.createIndex({val: 1}));
let res = FixtureHelpers.runCommandOnEachPrimary({
db: testDb.getSiblingDB("admin"),
cmdObj: {
configureFailPoint: failpointName,
mode: "alwaysOn",
}
});
res.forEach(cmdResult => assert.commandWorked(cmdResult));
const aggDone = startParallelShell(() => {
const targetDB = db.getSiblingDB("out_drop_temp");
// There are a number of possible error codes depending on configuration and index build
// options.
assert.commandFailed(targetDB.runCommand(
{aggregate: "out_source_coll", pipeline: [{$out: "out_target_coll"}], cursor: {}}));
const collList = assert.commandWorked(targetDB.runCommand({listCollections: 1}));
assert.eq(collList.cursor.firstBatch.length, 0);
}, portNum);
waitForCurOpByFailPointNoNS(testDb, failpointName);
assert.commandWorked(testDb.runCommand({dropDatabase: 1}));
FixtureHelpers.runCommandOnEachPrimary({
db: testDb.getSiblingDB("admin"),
cmdObj: {
configureFailPoint: failpointName,
mode: "off",
}
});
aggDone();
}
const conn = MongoRunner.runMongod({});
runTest(null, conn.getDB("out_drop_temp"), conn.port);
MongoRunner.stopMongod(conn);
const st = new ShardingTest({shards: 2, mongos: 1, config: 1});
runTest(st, st.s.getDB("out_drop_temp"), st.s.port);
st.stop();
})();
|