Skip to content

Commit fd97808

Browse files
authored
test(NODE-3288): sync command-monitoring spec tests to 3.6 (#2838)
* refactor: rename apm spec directory to command-monitoring * Sync redacted commands spec tests * Skip failing spec tests * Move legacy command-monitoring spec tests into their own folder * Skip unrelated failing tests
1 parent bf8b21b commit fd97808

25 files changed

+782
-3
lines changed

test/functional/apm.test.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const ignoreNsNotFound = shared.ignoreNsNotFound;
99
const loadSpecTests = require('../spec').loadSpecTests;
1010
const chai = require('chai');
1111
const expect = chai.expect;
12+
const runUnifiedTest = require('./unified-spec-runner/runner').runUnifiedTest;
1213

1314
describe('APM', function() {
1415
before(function() {
@@ -879,7 +880,7 @@ describe('APM', function() {
879880
}
880881
});
881882

882-
describe('spec tests', function() {
883+
describe('command monitoring spec tests', function() {
883884
before(function() {
884885
return setupDatabase(this.configuration);
885886
});
@@ -1087,7 +1088,7 @@ describe('APM', function() {
10871088
});
10881089
}
10891090

1090-
loadSpecTests('apm').forEach(scenario => {
1091+
loadSpecTests('command-monitoring/legacy').forEach(scenario => {
10911092
describe(scenario.name, function() {
10921093
scenario.tests.forEach(test => {
10931094
const requirements = { topology: ['single', 'replicaset', 'sharded'] };
@@ -1106,6 +1107,13 @@ describe('APM', function() {
11061107
it(test.description, {
11071108
metadata: { requires: requirements },
11081109
test: function() {
1110+
// NODE-3308
1111+
if (
1112+
test.description ===
1113+
'A successful find event with a getmore and the server kills the cursor'
1114+
) {
1115+
this.skip();
1116+
}
11091117
const client = this.configuration.newClient({}, { monitorCommands: true });
11101118
return client.connect().then(client => {
11111119
expect(client).to.exist;
@@ -1117,4 +1125,30 @@ describe('APM', function() {
11171125
});
11181126
});
11191127
});
1128+
1129+
describe('command monitoring unified spec tests', () => {
1130+
for (const loadedSpec of loadSpecTests('command-monitoring/unified')) {
1131+
expect(loadedSpec).to.include.all.keys(['description', 'tests']);
1132+
// TODO: NODE-3356 unskip redaction tests
1133+
const testsToSkip =
1134+
loadedSpec.description === 'redacted-commands'
1135+
? loadedSpec.tests
1136+
.map(test => test.description)
1137+
.filter(
1138+
description =>
1139+
description !== 'hello without speculative authenticate is not redacted'
1140+
)
1141+
: [];
1142+
context(String(loadedSpec.description), function() {
1143+
for (const test of loadedSpec.tests) {
1144+
it(String(test.description), {
1145+
metadata: { sessions: { skipLeakTests: true } },
1146+
test: async function() {
1147+
await runUnifiedTest(this, loadedSpec, test, testsToSkip);
1148+
}
1149+
});
1150+
}
1151+
});
1152+
}
1153+
});
11201154
});

test/functional/unified-spec-runner/unified-runner.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ const SKIPPED_TESTS = [
2424
// These two tests need to run against multiple mongoses
2525
'Dirty explicit session is discarded',
2626
// Will be implemented as part of NODE-2034
27-
'Client side error in command starting transaction'
27+
'Client side error in command starting transaction',
28+
// NODE-3308
29+
'A successful find event with a getmore and the server kills the cursor'
2830
];
2931

3032
describe('Unified test format runner', function unifiedTestRunner() {

test/spec/apm/README.rst renamed to test/spec/command-monitoring/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Command Monitoring
1212
Testing
1313
=======
1414

15+
Tests in ``unified`` are implemented in the `Unified Test Format <../../unified-test-format/unified-test-format.rst>`__ and require
16+
schema version 1.0. Tests in ``legacy`` should be run as described below.
17+
1518
Tests are provided in YML and JSON format to assert proper upconversion of commands.
1619

1720
Data
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)