Skip to content

Commit

Permalink
skip correct tests and update runner
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James committed Apr 19, 2024
1 parent 7ffa659 commit c48c188
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ describe('SDAM Unified Tests (Spec)', function () {
const specTests = loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'));
runUnifiedSuite(specTests, test => {
const skippedDescriptions = [
'connect with serverMonitoringMode=auth >=4.4',
'connect with serverMonitoringMode=auto >=4.4',
'connect with serverMonitoringMode=stream >=4.4'
];
return skippedDescriptions.some(description => test.description.includes(description))
? 'See NODE-XXXX'
? 'See NODE-6045'
: false;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,16 @@
"topologyOpeningEvent": {}
},
{
"topologyDescriptionChangedEvent": {
"previousDescription": {
"type": "Unknown"
},
"newDescription": {
"type": "ReplicaSetNoPrimary"
}
}
"topologyDescriptionChangedEvent": {}
},
{
"topologyDescriptionChangedEvent": {
"previousDescription": {
"type": "ReplicaSetNoPrimary"
},
"newDescription": {
"type": "ReplicaSetWithPrimary"
}
}
"topologyDescriptionChangedEvent": {}
},
{
"topologyDescriptionChangedEvent": {
"previousDescription": {
"type": "ReplicaSetWithPrimary"
},
"newDescription": {
"type": "ReplicaSetWithPrimary"
}
}
"topologyDescriptionChangedEvent": {}
},
{
"topologyDescriptionChangedEvent": {
"previousDescription": {
"type": "ReplicaSetWithPrimary"
},
"newDescription": {
"type": "ReplicaSetWithPrimary"
}
}
"topologyDescriptionChangedEvent": {}
},
{
"topologyDescriptionChangedEvent": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,10 @@ tests:
ignoreExtraEvents: false
events:
- topologyOpeningEvent: {}
- topologyDescriptionChangedEvent: # unknown -> replset no primary
previousDescription:
type: "Unknown"
newDescription:
type: "ReplicaSetNoPrimary"
- topologyDescriptionChangedEvent: # server connected
previousDescription:
type: "ReplicaSetNoPrimary"
newDescription:
type: "ReplicaSetWithPrimary"
- topologyDescriptionChangedEvent: # server connected
previousDescription:
type: "ReplicaSetWithPrimary"
newDescription:
type: "ReplicaSetWithPrimary"
- topologyDescriptionChangedEvent: # server connected
previousDescription:
type: "ReplicaSetWithPrimary"
newDescription:
type: "ReplicaSetWithPrimary"
- topologyDescriptionChangedEvent: {} # unknown -> replset no primary
- topologyDescriptionChangedEvent: {} # server connected
- topologyDescriptionChangedEvent: {} # server connected
- topologyDescriptionChangedEvent: {} # server connected
- topologyDescriptionChangedEvent: # replicaset -> unknown
previousDescription:
type: "ReplicaSetWithPrimary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"observeEvents": [
"topologyDescriptionChangedEvent",
"topologyOpeningEvent",
"topologyClosedEvent",
"serverOpeningEvent",
"serverClosedEvent"
"topologyClosedEvent"
]
}
}
Expand Down Expand Up @@ -68,9 +66,6 @@
}
}
},
{
"serverOpeningEvent": {}
},
{
"topologyDescriptionChangedEvent": {
"previousDescription": {
Expand All @@ -81,9 +76,6 @@
}
}
},
{
"serverClosedEvent": {}
},
{
"topologyDescriptionChangedEvent": {
"previousDescription": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ tests:
- topologyDescriptionChangedEvent
- topologyOpeningEvent
- topologyClosedEvent
- serverOpeningEvent
- serverClosedEvent
# ensure the topology has been fully discovered before closing the client.
# expected events are initial server discovery and server connect event.
- name: waitForEvent
Expand All @@ -44,13 +42,11 @@ tests:
type: "Unknown"
newDescription:
type: "Unknown"
- serverOpeningEvent: {}
- topologyDescriptionChangedEvent: # unknown w disconnected server -> standalone
previousDescription:
type: "Unknown"
newDescription:
type: "Single"
- serverClosedEvent: {}
- topologyDescriptionChangedEvent: # standalone -> unknown
previousDescription:
type: "Single"
Expand Down
24 changes: 15 additions & 9 deletions test/tools/unified-spec-runner/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from '../../mongodb';
import { ejson } from '../utils';
import { type CmapEvent, type CommandEvent, type EntitiesMap, type SdamEvent } from './entities';
import { trace } from './runner';
import {
type ExpectedCmapEvent,
type ExpectedCommandEvent,
Expand Down Expand Up @@ -606,17 +607,22 @@ function compareEvents(
} else if (expectedEvent.topologyDescriptionChangedEvent) {
expect(actualEvent).to.be.instanceOf(TopologyDescriptionChangedEvent);
const expectedSdamEvent = expectedEvent.topologyDescriptionChangedEvent;
for (const property of Object.keys(expectedSdamEvent)) {
// Only check the previousDescription and newDescription fields
for (const property of ['previousDescription', 'newDescription']) {
if (expectedSdamEvent[property] === undefined) continue;
if (typeof expectedSdamEvent[property] === 'object') {
for (const key of Object.keys(expectedSdamEvent[property])) {
expect(actualEvent[property][key]).to.equal(expectedSdamEvent[property][key]);
}
expect(actualEvent[property]).to.have.property('type');
expect(actualEvent[property].type).to.equal(expectedSdamEvent[property].type);
} else {
expect(actualEvent[property]).to.equal(expectedSdamEvent[property]);
expect.fail(
`Incorrect format of ${property} field.Expected an object with key 'type' with string value, got ${inspect(
expectedSdamEvent[property]
)} `
);
}
}
} else {
expect.fail(`Encountered unexpected event - ${inspect(actualEvent)}`);
expect.fail(`Encountered unexpected event - ${inspect(actualEvent)} `);
}
}
}
Expand Down Expand Up @@ -719,7 +725,7 @@ export function expectErrorCheck(
expected: ExpectedError,
entities: EntitiesMap
): void {
const expectMessage = `\n\nOriginal Error Stack:\n${error.stack}\n\n`;
const expectMessage = `\n\nOriginal Error Stack: \n${error.stack} \n\n`;

if (!isMongoCryptError(error)) {
expect(error, expectMessage).to.be.instanceOf(MongoError);
Expand Down Expand Up @@ -750,7 +756,7 @@ export function expectErrorCheck(
for (const errorLabel of expected.errorLabelsContain) {
expect(
mongoError.hasErrorLabel(errorLabel),
`Error was supposed to have label ${errorLabel}, has [${mongoError.errorLabels}] -- ${expectMessage}`
`Error was supposed to have label ${errorLabel}, has[${mongoError.errorLabels}]--${expectMessage} `
).to.be.true;
}
}
Expand All @@ -760,7 +766,7 @@ export function expectErrorCheck(
for (const errorLabel of expected.errorLabelsOmit) {
expect(
mongoError.hasErrorLabel(errorLabel),
`Error was not supposed to have label ${errorLabel}, has [${mongoError.errorLabels}] -- ${expectMessage}`
`Error was not supposed to have label ${errorLabel}, has[${mongoError.errorLabels}]--${expectMessage} `
).to.be.false;
}
}
Expand Down

0 comments on commit c48c188

Please sign in to comment.