Skip to content

Commit d047268

Browse files
committed
skip correct tests and update runner
1 parent 7108636 commit d047268

File tree

6 files changed

+26
-76
lines changed

6 files changed

+26
-76
lines changed

Diff for: test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ describe('SDAM Unified Tests (Spec)', function () {
77
const specTests = loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'));
88
runUnifiedSuite(specTests, test => {
99
const skippedDescriptions = [
10-
'connect with serverMonitoringMode=auth >=4.4',
10+
'connect with serverMonitoringMode=auto >=4.4',
1111
'connect with serverMonitoringMode=stream >=4.4'
1212
];
1313
return skippedDescriptions.some(description => test.description.includes(description))
14-
? 'See NODE-XXXX'
14+
? 'See NODE-6045'
1515
: false;
1616
});
1717
});

Diff for: test/spec/server-discovery-and-monitoring/unified/replicaset-emit-topology-changed-before-close.json

+4-32
Original file line numberDiff line numberDiff line change
@@ -57,44 +57,16 @@
5757
"topologyOpeningEvent": {}
5858
},
5959
{
60-
"topologyDescriptionChangedEvent": {
61-
"previousDescription": {
62-
"type": "Unknown"
63-
},
64-
"newDescription": {
65-
"type": "ReplicaSetNoPrimary"
66-
}
67-
}
60+
"topologyDescriptionChangedEvent": {}
6861
},
6962
{
70-
"topologyDescriptionChangedEvent": {
71-
"previousDescription": {
72-
"type": "ReplicaSetNoPrimary"
73-
},
74-
"newDescription": {
75-
"type": "ReplicaSetWithPrimary"
76-
}
77-
}
63+
"topologyDescriptionChangedEvent": {}
7864
},
7965
{
80-
"topologyDescriptionChangedEvent": {
81-
"previousDescription": {
82-
"type": "ReplicaSetWithPrimary"
83-
},
84-
"newDescription": {
85-
"type": "ReplicaSetWithPrimary"
86-
}
87-
}
66+
"topologyDescriptionChangedEvent": {}
8867
},
8968
{
90-
"topologyDescriptionChangedEvent": {
91-
"previousDescription": {
92-
"type": "ReplicaSetWithPrimary"
93-
},
94-
"newDescription": {
95-
"type": "ReplicaSetWithPrimary"
96-
}
97-
}
69+
"topologyDescriptionChangedEvent": {}
9870
},
9971
{
10072
"topologyDescriptionChangedEvent": {

Diff for: test/spec/server-discovery-and-monitoring/unified/replicaset-emit-topology-changed-before-close.yml

+4-20
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,10 @@ tests:
3737
ignoreExtraEvents: false
3838
events:
3939
- topologyOpeningEvent: {}
40-
- topologyDescriptionChangedEvent: # unknown -> replset no primary
41-
previousDescription:
42-
type: "Unknown"
43-
newDescription:
44-
type: "ReplicaSetNoPrimary"
45-
- topologyDescriptionChangedEvent: # server connected
46-
previousDescription:
47-
type: "ReplicaSetNoPrimary"
48-
newDescription:
49-
type: "ReplicaSetWithPrimary"
50-
- topologyDescriptionChangedEvent: # server connected
51-
previousDescription:
52-
type: "ReplicaSetWithPrimary"
53-
newDescription:
54-
type: "ReplicaSetWithPrimary"
55-
- topologyDescriptionChangedEvent: # server connected
56-
previousDescription:
57-
type: "ReplicaSetWithPrimary"
58-
newDescription:
59-
type: "ReplicaSetWithPrimary"
40+
- topologyDescriptionChangedEvent: {} # unknown -> replset no primary
41+
- topologyDescriptionChangedEvent: {} # server connected
42+
- topologyDescriptionChangedEvent: {} # server connected
43+
- topologyDescriptionChangedEvent: {} # server connected
6044
- topologyDescriptionChangedEvent: # replicaset -> unknown
6145
previousDescription:
6246
type: "ReplicaSetWithPrimary"

Diff for: test/spec/server-discovery-and-monitoring/unified/standalone-emit-topology-changed-before-close.json

+1-9
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
"observeEvents": [
2525
"topologyDescriptionChangedEvent",
2626
"topologyOpeningEvent",
27-
"topologyClosedEvent",
28-
"serverOpeningEvent",
29-
"serverClosedEvent"
27+
"topologyClosedEvent"
3028
]
3129
}
3230
}
@@ -68,9 +66,6 @@
6866
}
6967
}
7068
},
71-
{
72-
"serverOpeningEvent": {}
73-
},
7469
{
7570
"topologyDescriptionChangedEvent": {
7671
"previousDescription": {
@@ -81,9 +76,6 @@
8176
}
8277
}
8378
},
84-
{
85-
"serverClosedEvent": {}
86-
},
8779
{
8880
"topologyDescriptionChangedEvent": {
8981
"previousDescription": {

Diff for: test/spec/server-discovery-and-monitoring/unified/standalone-emit-topology-changed-before-close.yml

-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ tests:
2020
- topologyDescriptionChangedEvent
2121
- topologyOpeningEvent
2222
- topologyClosedEvent
23-
- serverOpeningEvent
24-
- serverClosedEvent
2523
# ensure the topology has been fully discovered before closing the client.
2624
# expected events are initial server discovery and server connect event.
2725
- name: waitForEvent
@@ -44,13 +42,11 @@ tests:
4442
type: "Unknown"
4543
newDescription:
4644
type: "Unknown"
47-
- serverOpeningEvent: {}
4845
- topologyDescriptionChangedEvent: # unknown w disconnected server -> standalone
4946
previousDescription:
5047
type: "Unknown"
5148
newDescription:
5249
type: "Single"
53-
- serverClosedEvent: {}
5450
- topologyDescriptionChangedEvent: # standalone -> unknown
5551
previousDescription:
5652
type: "Single"

Diff for: test/tools/unified-spec-runner/match.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
} from '../../mongodb';
3939
import { ejson } from '../utils';
4040
import { type CmapEvent, type CommandEvent, type EntitiesMap, type SdamEvent } from './entities';
41+
import { trace } from './runner';
4142
import {
4243
type ExpectedCmapEvent,
4344
type ExpectedCommandEvent,
@@ -606,17 +607,22 @@ function compareEvents(
606607
} else if (expectedEvent.topologyDescriptionChangedEvent) {
607608
expect(actualEvent).to.be.instanceOf(TopologyDescriptionChangedEvent);
608609
const expectedSdamEvent = expectedEvent.topologyDescriptionChangedEvent;
609-
for (const property of Object.keys(expectedSdamEvent)) {
610+
// Only check the previousDescription and newDescription fields
611+
for (const property of ['previousDescription', 'newDescription']) {
612+
if (expectedSdamEvent[property] === undefined) continue;
610613
if (typeof expectedSdamEvent[property] === 'object') {
611-
for (const key of Object.keys(expectedSdamEvent[property])) {
612-
expect(actualEvent[property][key]).to.equal(expectedSdamEvent[property][key]);
613-
}
614+
expect(actualEvent[property]).to.have.property('type');
615+
expect(actualEvent[property].type).to.equal(expectedSdamEvent[property].type);
614616
} else {
615-
expect(actualEvent[property]).to.equal(expectedSdamEvent[property]);
617+
expect.fail(
618+
`Incorrect format of ${property} field.Expected an object with key 'type' with string value, got ${inspect(
619+
expectedSdamEvent[property]
620+
)} `
621+
);
616622
}
617623
}
618624
} else {
619-
expect.fail(`Encountered unexpected event - ${inspect(actualEvent)}`);
625+
expect.fail(`Encountered unexpected event - ${inspect(actualEvent)} `);
620626
}
621627
}
622628
}
@@ -719,7 +725,7 @@ export function expectErrorCheck(
719725
expected: ExpectedError,
720726
entities: EntitiesMap
721727
): void {
722-
const expectMessage = `\n\nOriginal Error Stack:\n${error.stack}\n\n`;
728+
const expectMessage = `\n\nOriginal Error Stack: \n${error.stack} \n\n`;
723729

724730
if (!isMongoCryptError(error)) {
725731
expect(error, expectMessage).to.be.instanceOf(MongoError);
@@ -750,7 +756,7 @@ export function expectErrorCheck(
750756
for (const errorLabel of expected.errorLabelsContain) {
751757
expect(
752758
mongoError.hasErrorLabel(errorLabel),
753-
`Error was supposed to have label ${errorLabel}, has [${mongoError.errorLabels}] -- ${expectMessage}`
759+
`Error was supposed to have label ${errorLabel}, has[${mongoError.errorLabels}]--${expectMessage} `
754760
).to.be.true;
755761
}
756762
}
@@ -760,7 +766,7 @@ export function expectErrorCheck(
760766
for (const errorLabel of expected.errorLabelsOmit) {
761767
expect(
762768
mongoError.hasErrorLabel(errorLabel),
763-
`Error was not supposed to have label ${errorLabel}, has [${mongoError.errorLabels}] -- ${expectMessage}`
769+
`Error was not supposed to have label ${errorLabel}, has[${mongoError.errorLabels}]--${expectMessage} `
764770
).to.be.false;
765771
}
766772
}

0 commit comments

Comments
 (0)