|
1 | 1 | 'use strict';
|
2 |
| -const { TestRunnerContext, generateTopologyTests } = require('../../tools/spec-runner'); |
3 | 2 | const { loadSpecTests } = require('../../spec');
|
4 |
| - |
5 |
| -class SDAMRunnerContext extends TestRunnerContext { |
6 |
| - constructor() { |
7 |
| - super(); |
8 |
| - |
9 |
| - this.currentPrimary = null; |
10 |
| - } |
11 |
| - |
12 |
| - configureFailPoint(args) { |
13 |
| - return this.enableFailPoint(args.failPoint); |
14 |
| - } |
15 |
| - |
16 |
| - recordPrimary(client) { |
17 |
| - const servers = client.topology.description.servers; |
18 |
| - const primary = Array.from(servers.values()).filter(sd => sd.type === 'RSPrimary')[0]; |
19 |
| - this.currentPrimary = primary.address; |
20 |
| - } |
21 |
| - |
22 |
| - waitForPrimaryChange(client) { |
23 |
| - const currentPrimary = this.currentPrimary; |
24 |
| - |
25 |
| - return new Promise(resolve => { |
26 |
| - function eventHandler(event) { |
27 |
| - if ( |
28 |
| - event.newDescription.type === 'RSPrimary' && |
29 |
| - event.newDescription.address !== currentPrimary |
30 |
| - ) { |
31 |
| - resolve(); |
32 |
| - client.removeListener('serverDescriptionChanged', eventHandler); |
33 |
| - } |
34 |
| - } |
35 |
| - |
36 |
| - client.on('serverDescriptionChanged', eventHandler); |
37 |
| - }); |
| 3 | +const { runUnifiedSuite } = require('../../tools/unified-spec-runner/runner'); |
| 4 | +const path = require('path'); |
| 5 | + |
| 6 | +const filter = ({ description }) => { |
| 7 | + // return description !== 'Concurrent shutdown error on insert' ? 'skip' : false; |
| 8 | + |
| 9 | + const isAuthEnabled = process.env.AUTH === 'auth'; |
| 10 | + switch (description) { |
| 11 | + case 'Reset server and pool after AuthenticationFailure error': |
| 12 | + case 'Reset server and pool after misc command error': |
| 13 | + case 'Reset server and pool after network error during authentication': |
| 14 | + case 'Reset server and pool after network timeout error during authentication': |
| 15 | + case 'Reset server and pool after shutdown error during authentication': |
| 16 | + // Some tests are failing when setting a failCommand when auth is enabled |
| 17 | + // and time out waiting for the PoolCleared event |
| 18 | + return isAuthEnabled ? 'TODO(NODE-3891): fix tests broken when AUTH enabled' : false; |
| 19 | + case 'Network error on Monitor check': |
| 20 | + case 'Network timeout on Monitor handshake': |
| 21 | + case 'Network timeout on Monitor check': |
| 22 | + case 'Driver extends timeout while streaming': |
| 23 | + return 'TODO(NODE-4573): fix socket leaks'; |
| 24 | + default: |
| 25 | + return false; |
38 | 26 | }
|
39 |
| -} |
40 |
| - |
41 |
| -// 'TODO: NODE-3891 - fix tests broken when AUTH enabled' |
42 |
| -// Some tests are failing when setting a failCommand when auth is enabled. |
43 |
| -const isAuthEnabled = process.env.AUTH === 'auth'; |
44 |
| -const failpointTests = [ |
45 |
| - 'Reset server and pool after AuthenticationFailure error', |
46 |
| - 'Reset server and pool after misc command error', |
47 |
| - 'Reset server and pool after network error during authentication', |
48 |
| - 'Reset server and pool after network timeout error during authentication', |
49 |
| - 'Reset server and pool after shutdown error during authentication' |
50 |
| -]; |
51 |
| -const skippedTests = [...(isAuthEnabled ? failpointTests : []), 'Network error on Monitor check']; |
52 |
| - |
53 |
| -function sdamDisabledTestFilter(test) { |
54 |
| - const { description } = test; |
55 |
| - return !skippedTests.includes(description); |
56 |
| -} |
57 |
| - |
58 |
| -describe('SDAM', function () { |
59 |
| - describe('integration spec tests', function () { |
60 |
| - const testContext = new SDAMRunnerContext(); |
61 |
| - const testSuites = loadSpecTests('server-discovery-and-monitoring/integration'); |
62 |
| - |
63 |
| - beforeEach(async function () { |
64 |
| - if (this.configuration.isLoadBalanced) { |
65 |
| - this.currentTest.skipReason = 'Cannot run in a loadBalanced environment'; |
66 |
| - this.skip(); |
67 |
| - } |
68 |
| - }); |
69 |
| - |
70 |
| - beforeEach(async function () { |
71 |
| - await testContext.setup(this.configuration); |
72 |
| - }); |
73 |
| - |
74 |
| - afterEach(async () => { |
75 |
| - await testContext.teardown(); |
76 |
| - }); |
| 27 | +}; |
77 | 28 |
|
78 |
| - generateTopologyTests(testSuites, testContext, sdamDisabledTestFilter); |
79 |
| - }); |
| 29 | +describe('SDAM Unified Tests', function () { |
| 30 | + runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified')), filter); |
80 | 31 | });
|
0 commit comments