Skip to content

Commit d098a78

Browse files
chore: resolve merge conlicts
1 parent 60b1b2f commit d098a78

File tree

5 files changed

+85
-131
lines changed

5 files changed

+85
-131
lines changed

test/integration/collection-management/collection_management.spec.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ const { runUnifiedSuite } = require('../../tools/unified-spec-runner/runner');
77
const SKIPPED_TESTS = ['modifyCollection to changeStreamPreAndPostImages enabled'];
88

99
describe('Collection management unified spec tests', function () {
10-
runUnifiedSuite(loadSpecTests('collection-management'), SKIPPED_TESTS);
10+
runUnifiedSuite(loadSpecTests('collection-management'), ({ description }) =>
11+
SKIPPED_TESTS.includes(description) ? `the Node driver does not have a collMod helper.` : null
12+
);
1113
});

test/integration/command-monitoring/command_monitoring.spec.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
1212
const SKIP = ['A successful unordered bulk write with an unacknowledged write concern'];
1313

1414
describe('Command Monitoring Spec (unified)', () => {
15-
runUnifiedSuite(loadSpecTests(path.join('command-monitoring', 'unified')), SKIP);
15+
runUnifiedSuite(loadSpecTests(path.join('command-monitoring', 'unified')), ({ description }) =>
16+
SKIP.includes(description) ? `TODO(NODE-4261): support skip reasons in unified tests` : null
17+
);
1618
});

test/integration/load-balancers/load_balancers.spec.test.js

Lines changed: 35 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,44 @@ const path = require('path');
33
const { loadSpecTests } = require('../../spec/index');
44
const { runUnifiedSuite } = require('../../tools/unified-spec-runner/runner');
55

6-
const SKIP = [
7-
// Verified they use the same connection but the Node implementation executes
8-
// a getMore before the killCursors even though the stream is immediately
9-
// closed.
10-
// TODO(NODE-3970): implement and reference a node specific integration test for this
11-
'change streams pin to a connection',
6+
const filter = ({ description }) => {
7+
if (description === 'change streams pin to a connection') {
8+
// Verified they use the same connection but the Node implementation executes
9+
// a getMore before the killCursors even though the stream is immediately
10+
// closed.
11+
// TODO(NODE-3970): implement and reference a node specific integration test for this
12+
return 'TODO(NODE-3970)';
13+
}
1214

13-
// TODO(DRIVERS-1847): The following three tests are skipped pending a decision made on DRIVERS-1847,
14-
// since pinning the connection on any getMore error is very awkward in node and likely results
15-
// in sub-optimal pinning.
16-
'pinned connections are not returned after an network error during getMore',
17-
'pinned connections are not returned to the pool after a non-network error on getMore',
18-
'stale errors are ignored',
15+
if (
16+
[
17+
'pinned connections are not returned after an network error during getMore',
18+
'pinned connections are not returned to the pool after a non-network error on getMore',
19+
'stale errors are ignored'
20+
].includes(description)
21+
) {
22+
// TODO(DRIVERS-1847): The following three tests are skipped pending a decision made on DRIVERS-1847,
23+
// since pinning the connection on any getMore error is very awkward in node and likely results
24+
// in sub-optimal pinning.
25+
return 'TODO(DRIVERS-1847)';
26+
}
1927

20-
// This test is skipped because it assumes drivers attempt connections on the first operation,
21-
// but Node has a connect() method that is called before the first operation is ever run.
22-
// TODO(NODE-2149): Refactor connect()
23-
'errors during the initial connection hello are ignored',
28+
if (
29+
process.env.AUTH === 'auth' &&
30+
[
31+
'errors during authentication are processed',
32+
'wait queue timeout errors include cursor statistics',
33+
'wait queue timeout errors include transaction statistics',
34+
'operations against non-load balanced clusters fail if URI contains loadBalanced=true',
35+
'operations against non-load balanced clusters succeed if URI contains loadBalanced=false'
36+
].includes(description)
37+
) {
38+
return 'TODO(NODE-3891): fix tests broken when AUTH enabled';
39+
}
2440

25-
...(process.env.SERVERLESS
26-
? [
27-
// TODO(NODE-2471): Unskip these when there isn't a ping command sent when credentials are defined
28-
'no connection is pinned if all documents are returned in the initial batch',
29-
'pinned connections are returned when the cursor is drained',
30-
'pinned connections are returned to the pool when the cursor is closed',
31-
'pinned connections are returned after a network error during a killCursors request',
32-
'aggregate pins the cursor to a connection',
33-
'errors during the initial connection hello are ignored',
34-
'all operations go to the same mongos',
35-
'transaction can be committed multiple times',
36-
'pinned connection is not released after a non-transient CRUD error',
37-
'pinned connection is not released after a non-transient commit error',
38-
'pinned connection is released after a non-transient abort error',
39-
'pinned connection is released after a transient network commit error',
40-
'pinned connection is released after a transient non-network abort error',
41-
'pinned connection is released after a transient network abort error',
42-
'pinned connection is released on successful abort',
43-
'pinned connection is returned when a new transaction is started',
44-
'pinned connection is returned when a non-transaction operation uses the session',
45-
'a connection can be shared by a transaction and a cursor',
46-
'wait queue timeout errors include cursor statistics',
47-
'wait queue timeout errors include transaction statistics'
48-
]
49-
: []),
50-
51-
// TODO: NODE-3891 - fix tests broken when AUTH enabled
52-
...(process.env.AUTH === 'auth'
53-
? [
54-
'errors during authentication are processed',
55-
'wait queue timeout errors include cursor statistics',
56-
'wait queue timeout errors include transaction statistics',
57-
'operations against non-load balanced clusters fail if URI contains loadBalanced=true',
58-
'operations against non-load balanced clusters succeed if URI contains loadBalanced=false'
59-
]
60-
: [])
61-
];
41+
return null;
42+
};
6243

6344
describe('Load Balancer Unified Tests', function () {
64-
runUnifiedSuite(loadSpecTests(path.join('load-balancers')), SKIP);
45+
runUnifiedSuite(loadSpecTests(path.join('load-balancers')), filter);
6546
});
Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
11
import { loadSpecTests } from '../../spec/index';
22
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
3+
import { TestFilter } from '../../tools/unified-spec-runner/schema';
34

4-
// TODO: NODE-3891 - fix tests broken when AUTH enabled
5-
const FAILING_TESTS_AUTH_ENABLED = [
6-
'FindOneAndUpdate is committed on first attempt',
7-
'FindOneAndUpdate is not committed on first attempt',
8-
'FindOneAndUpdate is never committed',
9-
'eventType defaults to command if unset',
10-
'events are captured during an operation',
11-
'eventType can be set to command and cmap'
12-
];
5+
const filter: TestFilter = ({ description }) => {
6+
if (description === 'unpin after transient error within a transaction and commit') {
7+
// OLD COMMENT: commitTransaction retry seems to be swallowed by mongos in this case
8+
// TODO(NODE-3943):
9+
return `TODO(NODE-3943)`;
10+
}
1311

14-
const SKIPPED_TESTS = [
15-
// TODO(NODE-3943):
16-
// OLD COMMENT: commitTransaction retry seems to be swallowed by mongos in this case
17-
'unpin after transient error within a transaction and commit',
12+
if (description === 'Client side error in command starting transaction') {
13+
// TODO(NODE-2034): Will be implemented as part of NODE-2034
14+
return 'TODO(NODE-2034)';
15+
}
1816

19-
// TODO(NODE-2034): Will be implemented as part of NODE-2034
20-
'Client side error in command starting transaction',
17+
if (description === 'Dirty explicit session is discarded') {
18+
// TODO(NODE-3951): investigate why this is failing while the legacy version is passing
19+
return 'TODO(NODE-3951)';
20+
}
2121

22-
// TODO(NODE-3308):
23-
'A successful find event with a getmore and the server kills the cursor',
22+
if (description === 'A successful find event with a getmore and the server kills the cursor') {
23+
return 'TODO(NODE-3308)';
24+
}
2425

25-
// TODO(NODE-4125): Fix change streams resume logic when used in iterator mode
26-
'Test consecutive resume'
27-
].concat(process.env.AUTH === 'auth' ? FAILING_TESTS_AUTH_ENABLED : []);
26+
if (
27+
process.env.AUTH === 'auth' &&
28+
[
29+
'FindOneAndUpdate is committed on first attempt',
30+
'FindOneAndUpdate is not committed on first attempt',
31+
'FindOneAndUpdate is never committed',
32+
'eventType defaults to command if unset',
33+
'events are captured during an operation',
34+
'eventType can be set to command and cmap'
35+
].includes(description)
36+
) {
37+
return 'TODO(NODE-3891): fix tests broken when AUTH enabled';
38+
}
39+
40+
return null;
41+
};
2842

2943
describe('Unified test format runner', function unifiedTestRunner() {
3044
// Valid tests that should pass
31-
runUnifiedSuite(loadSpecTests('unified-test-format/valid-pass'), SKIPPED_TESTS);
45+
runUnifiedSuite(loadSpecTests('unified-test-format/valid-pass'), filter);
3246
});

test/tools/unified-spec-runner/runner.ts

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -36,51 +36,22 @@ async function terminateOpenTransactions(client: MongoClient) {
3636
}
3737
}
3838

39-
export async function runUnifiedTest(
40-
ctx: Mocha.Context,
41-
unifiedSuite: uni.UnifiedSuite,
42-
test: uni.Test
43-
): Promise<void>;
44-
45-
/**
46-
* @deprecated use the overload that provides a function filter instead
39+
/*
40+
* @param skipFilter - a function that returns null if the test should be run,
41+
* or a skip reason if the test should be skipped
4742
*/
4843
export async function runUnifiedTest(
4944
ctx: Mocha.Context,
5045
unifiedSuite: uni.UnifiedSuite,
5146
test: uni.Test,
52-
testsToSkip?: string[]
53-
): Promise<void>;
54-
55-
/**
56-
*
57-
* @param skipFilter - a function that returns true if the test should be skipped
58-
*/
59-
export async function runUnifiedTest(
60-
ctx: Mocha.Context,
61-
unifiedSuite: uni.UnifiedSuite,
62-
test: uni.Test,
63-
skipFilter?: uni.TestFilter
64-
): Promise<void>;
65-
66-
export async function runUnifiedTest(
67-
ctx: Mocha.Context,
68-
unifiedSuite: uni.UnifiedSuite,
69-
test: uni.Test,
70-
testsToSkipOrFilter?: string[] | uni.TestFilter
47+
skipFilter: uni.TestFilter = () => null
7148
): Promise<void> {
7249
// Some basic expectations we can catch early
7350
expect(test).to.exist;
7451
expect(unifiedSuite).to.exist;
7552
expect(ctx).to.exist;
7653
expect(ctx.configuration).to.exist;
7754

78-
if (Array.isArray(testsToSkipOrFilter)) {
79-
const testsToSkip = testsToSkipOrFilter;
80-
testsToSkipOrFilter = ({ description }) =>
81-
testsToSkip.includes(description) ? 'Test was filtered without a skip reason' : null;
82-
}
83-
8455
const schemaVersion = patchVersion(unifiedSuite.schemaVersion);
8556
expect(semverSatisfies(schemaVersion, uni.SupportedVersion)).to.be.true;
8657

@@ -91,7 +62,7 @@ export async function runUnifiedTest(
9162
ctx.skip();
9263
}
9364

94-
const skipReason = testsToSkipOrFilter?.(test);
65+
const skipReason = skipFilter(test);
9566

9667
if (typeof skipReason === 'string') {
9768
if (skipReason.length === 0) {
@@ -101,10 +72,6 @@ export async function runUnifiedTest(
10172
ctx.skip();
10273
}
10374

104-
if (testsToSkipOrFilter?.(test)) {
105-
ctx.skip();
106-
}
107-
10875
let utilClient;
10976
if (ctx.configuration.isLoadBalanced) {
11077
// The util client can always point at the single mongos LB frontend.
@@ -279,32 +246,20 @@ export async function runUnifiedTest(
279246
}
280247
}
281248

282-
export function runUnifiedSuite(specTests: uni.UnifiedSuite[]): void;
283-
284-
/**
285-
* @deprecated use the overload that provides a function filter instead
286-
*/
287-
export function runUnifiedSuite(specTests: uni.UnifiedSuite[], testsToSkip?: string[]): void;
288-
289249
/**
290250
*
291-
* @param skipFilter - a function that returns true if the test should be skipped
251+
* @param skipFilter - a function that returns null if the test should be run,
252+
* or a skip reason if the test should be skipped
292253
*/
293-
export function runUnifiedSuite(specTests: uni.UnifiedSuite[], skipFilter?: uni.TestFilter): void;
294-
295254
export function runUnifiedSuite(
296255
specTests: uni.UnifiedSuite[],
297-
testsToSkipOrFilter?: string[] | uni.TestFilter
256+
skipFilter: uni.TestFilter = () => null
298257
): void {
299258
for (const unifiedSuite of specTests) {
300259
context(String(unifiedSuite.description), function () {
301260
for (const test of unifiedSuite.tests) {
302261
it(String(test.description), async function () {
303-
if (Array.isArray(testsToSkipOrFilter)) {
304-
await runUnifiedTest(this, unifiedSuite, test, testsToSkipOrFilter);
305-
} else {
306-
await runUnifiedTest(this, unifiedSuite, test, testsToSkipOrFilter);
307-
}
262+
await runUnifiedTest(this, unifiedSuite, test, skipFilter);
308263
});
309264
}
310265
});

0 commit comments

Comments
 (0)