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
|
/**
* Checks that API version 2 will behave correctly with mongod/mongos.
*
* @tags: [
* requires_fcv_47,
* requires_journaling,
* ]
*/
(function() {
"use strict";
const runTest = testDB => {
// Test command in V2 but not V1.
assert.commandWorked(testDB.runCommand({testVersion2: 1, apiVersion: "2", apiStrict: true}));
assert.commandFailedWithCode(
testDB.runCommand({testVersion2: 1, apiVersion: "1", apiStrict: true}),
ErrorCodes.APIStrictError,
"testVersion2 is not in API V1");
// Test command in both V1 and V2.
assert.commandWorked(
testDB.runCommand({testVersions1And2: 1, apiVersion: "1", apiStrict: true}));
assert.commandWorked(
testDB.runCommand({testVersions1And2: 1, apiVersion: "2", apiStrict: true}));
// Test command in V1, deprecated in V2.
assert.commandWorked(testDB.runCommand({
testDeprecationInVersion2: 1,
apiVersion: "1",
apiStrict: true,
apiDeprecationErrors: true
}));
assert.commandFailedWithCode(
testDB.runCommand({
testDeprecationInVersion2: 1,
apiVersion: "2",
apiStrict: true,
apiDeprecationErrors: true
}),
ErrorCodes.APIDeprecationError,
"Provided apiDeprecationErrors: true, but testDeprecationInVersion2 is deprecated in V2");
// Test command in V1, removed in V2.
assert.commandWorked(testDB.runCommand({testRemoval: 1, apiVersion: "1", apiStrict: true}));
assert.commandFailedWithCode(
testDB.runCommand({testRemoval: 1, apiVersion: "2", apiStrict: true}),
ErrorCodes.APIStrictError,
"testRemoval is not in API V2");
};
const conn = MongoRunner.runMongod({setParameter: {acceptApiVersion2: true}});
const db = conn.getDB(jsTestName());
runTest(db);
MongoRunner.stopMongod(conn);
const st = new ShardingTest({mongosOptions: {setParameter: {acceptApiVersion2: true}}});
runTest(st.s0.getDB(jsTestName()));
st.stop();
})();
|