Skip to content

Commit b0e3f99

Browse files
committed
chore: verify we only encounter expected MongoDB server warnings MONGOSH-2988
1 parent fc4c412 commit b0e3f99

File tree

12 files changed

+284
-11
lines changed

12 files changed

+284
-11
lines changed

package-lock.json

Lines changed: 18 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"husky": "^9.0.11",
118118
"mocha": "^10.2.0",
119119
"mongodb": "^6.19.0",
120-
"mongodb-runner": "^6.0.0",
120+
"mongodb-runner": "^6.2.0",
121121
"node-gyp": "^9.0.0 || ^10.2.0",
122122
"nyc": "^15.1.0",
123123
"pkg-up": "^3.1.0",

packages/cli-repl/src/cli-repl.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,6 +2268,22 @@ describe('CliRepl', function () {
22682268

22692269
context('for server >= 4.1', function () {
22702270
skipIfServerVersion(testServer, '< 4.1');
2271+
let unsubscribeAllowWarning: undefined | (() => void);
2272+
2273+
before(function () {
2274+
// Allow "$where is deprecated" and "operation was interrupted" warnings
2275+
unsubscribeAllowWarning = testServer.allowWarning?.((entry) => {
2276+
return (
2277+
entry.id === 8996500 ||
2278+
(entry.id === 23798 &&
2279+
entry.attr?.error?.codeName === 'ClientDisconnect')
2280+
);
2281+
});
2282+
});
2283+
2284+
after(function () {
2285+
unsubscribeAllowWarning?.();
2286+
});
22712287

22722288
it('terminates operations on the server side', async function () {
22732289
if (process.env.MONGOSH_TEST_FORCE_API_STRICT) {

packages/e2e-tests/test/e2e-auth.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,15 @@ describe('Auth e2e', function () {
766766
});
767767
});
768768
describe('logout', function () {
769+
let unsubscribeAllowWarning: (() => void) | undefined;
770+
beforeEach(function () {
771+
// https://jira.mongodb.org/browse/SERVER-56266
772+
// https://jira.mongodb.org/browse/MONGOSH-2695
773+
unsubscribeAllowWarning = testServer.allowWarning?.(5626600);
774+
});
775+
afterEach(function () {
776+
unsubscribeAllowWarning?.();
777+
});
769778
it('logs out after authenticating', async function () {
770779
await shell.executeLine(`use ${dbName}`);
771780
expect(await shell.executeLine('db.auth("anna", "pwd")')).to.include(

packages/e2e-tests/test/e2e-oidc.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ describe('OIDC auth e2e', function () {
154154
};
155155
});
156156

157+
afterEach(function () {
158+
testServer?.noServerWarningsCheckpoint();
159+
testServer2?.noServerWarningsCheckpoint();
160+
testServer3?.noServerWarningsCheckpoint();
161+
});
162+
157163
after(async function () {
158164
this.timeout(120_000);
159165
await Promise.all([

packages/e2e-tests/test/e2e-proxy.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ describe('e2e proxy support', function () {
428428
});
429429
await oidcTestServer.start();
430430
});
431+
431432
after(async function () {
432433
this.timeout(120_000);
433434
await Promise.all([
@@ -437,6 +438,10 @@ describe('e2e proxy support', function () {
437438
]);
438439
});
439440

441+
afterEach(function () {
442+
oidcTestServer?.noServerWarningsCheckpoint();
443+
});
444+
440445
beforeEach(function () {
441446
tokenFetches = 0;
442447
getTokenPayload = (metadata) => {

packages/e2e-tests/test/e2e.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ describe('e2e', function () {
687687
if (process.env.MONGOSH_TEST_FORCE_API_STRICT) {
688688
return this.skip(); // mapReduce is unversioned
689689
}
690+
// Allow "map reduce command is deprecated" warning in logs
691+
const unsubscribe = testServer.allowWarning?.(5725801);
690692
await shell.executeLine(`use ${dbName}`);
691693
await shell.executeLine('db.test.insertMany([{i:1},{i:2},{i:3},{i:4}]);');
692694
const result = await shell.executeLine(`db.test.mapReduce(function() {
@@ -696,6 +698,7 @@ describe('e2e', function () {
696698
}, { out: { inline: 1 } }).results`);
697699
expect(result).to.include('{ _id: 0, value: 6 }');
698700
expect(result).to.include('{ _id: 1, value: 4 }');
701+
unsubscribe?.();
699702
});
700703

701704
it('rewrites async properly for common libraries', async function () {
@@ -800,6 +803,8 @@ describe('e2e', function () {
800803
});
801804

802805
it('rewrites async properly for a complex $function', async function () {
806+
// Allow "$function is deprecated" warning in logs
807+
const unsubscribe = testServer.allowWarning?.(8996503);
803808
await shell.executeLine(`use ${dbName}`);
804809
await shell.executeLine(
805810
'db.test.insertMany([{i:[1,{v:5}]},{i:[2,{v:6}]},{i:[3,{v:7}]},{i:[4,{v:8}]}]);'
@@ -819,6 +824,7 @@ describe('e2e', function () {
819824
}
820825
])`);
821826
expect(result).to.include("{ sum: '12' }");
827+
unsubscribe?.();
822828
});
823829
});
824830

@@ -2658,6 +2664,7 @@ describe('e2e', function () {
26582664
context('with 2 shells', function () {
26592665
let helperShell: TestShell;
26602666
let currentOpShell: TestShell;
2667+
let unsubscribeAllowWarning: undefined | (() => void);
26612668

26622669
const CURRENT_OP_WAIT_TIME = 400;
26632670
const OPERATION_TIME = CURRENT_OP_WAIT_TIME * 2;
@@ -2676,6 +2683,15 @@ describe('e2e', function () {
26762683
await helperShell.executeLine('db.coll.insertOne({})');
26772684
});
26782685

2686+
before(function () {
2687+
// Allow "$where is deprecated" warnings
2688+
unsubscribeAllowWarning = testServer.allowWarning?.(8996500);
2689+
});
2690+
2691+
after(function () {
2692+
unsubscribeAllowWarning?.();
2693+
});
2694+
26792695
it('should return the current operation and clear when it is complete', async function () {
26802696
const currentCommand = helperShell.executeLine(
26812697
`db.coll.find({$where: function() { sleep(${OPERATION_TIME}) }}).projection({testProjection: 1})`

packages/shell-api/src/integration.spec.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,16 @@ describe('Shell API (integration)', function () {
743743

744744
describe('#reIndex', function () {
745745
skipIfApiStrict();
746+
let unsubscribeAllowWarning: undefined | (() => void);
747+
748+
before(function () {
749+
// Allow "The reIndex command is deprecated" warnings
750+
unsubscribeAllowWarning = testServer.allowWarning?.(6508600);
751+
});
752+
753+
after(function () {
754+
unsubscribeAllowWarning?.();
755+
});
746756

747757
beforeEach(async function () {
748758
await serviceProvider.createCollection(dbName, collectionName);
@@ -1069,6 +1079,16 @@ describe('Shell API (integration)', function () {
10691079

10701080
describe('runCommand', function () {
10711081
skipIfApiStrict();
1082+
let unsubscribeAllowWarning: undefined | (() => void);
1083+
1084+
before(function () {
1085+
// Allow "The collStats command is deprecated" warnings
1086+
unsubscribeAllowWarning = testServer.allowWarning?.(7024600);
1087+
});
1088+
1089+
after(function () {
1090+
unsubscribeAllowWarning?.();
1091+
});
10721092

10731093
beforeEach(async function () {
10741094
await serviceProvider.createCollection(dbName, collectionName);
@@ -1353,6 +1373,21 @@ describe('Shell API (integration)', function () {
13531373
// https://jira.mongodb.org/browse/SERVER-58076
13541374
skipIfServerVersion(testServer, '<= 6.0');
13551375
}
1376+
let unsubscribeAllowWarning: undefined | (() => void);
1377+
1378+
before(function () {
1379+
// Allow warning for the failing updateOne() below
1380+
unsubscribeAllowWarning = testServer.allowWarning?.(
1381+
(entry) =>
1382+
entry.id === 7267501 &&
1383+
entry.attr?.error?.codeName === 'DollarPrefixedFieldName'
1384+
);
1385+
});
1386+
1387+
after(function () {
1388+
unsubscribeAllowWarning?.();
1389+
});
1390+
13561391
it('can insert, modify and retrieve fields with $-prefixed .-containing names', async function () {
13571392
await collection.insertOne({ '$x.y': 1, _id: '_id' });
13581393
expect(await collection.findOne()).to.deep.equal({
@@ -1991,6 +2026,16 @@ describe('Shell API (integration)', function () {
19912026

19922027
describe('mapReduce', function () {
19932028
skipIfServerVersion(testServer, '< 4.4');
2029+
let unsubscribeAllowWarning: undefined | (() => void);
2030+
2031+
before(function () {
2032+
// Allow "The map reduce command is deprecated" warning
2033+
unsubscribeAllowWarning = testServer.allowWarning?.(5725801);
2034+
});
2035+
2036+
after(function () {
2037+
unsubscribeAllowWarning?.();
2038+
});
19942039

19952040
let mapFn: () => void;
19962041
let reduceFn: (a: string, b: string[]) => string;
@@ -3007,6 +3052,21 @@ describe('Shell API (integration)', function () {
30073052

30083053
describe('maxTimeMS support', function () {
30093054
skipIfServerVersion(testServer, '< 4.2');
3055+
let unsubscribeAllowWarning: undefined | (() => void);
3056+
3057+
before(function () {
3058+
// Allow "$where is deprecated" warning and timeout warnings
3059+
unsubscribeAllowWarning = testServer.allowWarning?.(
3060+
(entry) =>
3061+
entry.id === 8996500 ||
3062+
(entry.id === 23798 &&
3063+
entry.attr?.error?.codeName === 'MaxTimeMSExpired')
3064+
);
3065+
});
3066+
3067+
after(function () {
3068+
unsubscribeAllowWarning?.();
3069+
});
30103070

30113071
beforeEach(async function () {
30123072
await collection.insertMany([...Array(10).keys()].map((i) => ({ i })));

packages/shell-api/src/replica-set.spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,23 @@ describe('ReplicaSet', function () {
10281028
});
10291029

10301030
describe('remove member', function () {
1031+
let unsubscribeAllowWarnings: (() => void)[];
1032+
1033+
before(function () {
1034+
// Allow "Unable to forward progress" warnings
1035+
unsubscribeAllowWarnings = [srv0, srv1, srv2, srv3].map((s) =>
1036+
s.allowWarning?.(
1037+
(entry) =>
1038+
entry.id === 21764 &&
1039+
entry.attr?.error?.codeName === 'NodeNotFound'
1040+
)
1041+
);
1042+
});
1043+
1044+
after(function () {
1045+
for (const cb of unsubscribeAllowWarnings) cb();
1046+
});
1047+
10311048
it('removes a member of the config', async function () {
10321049
const removeWithRetry = createRetriableMethod(rs, 'remove');
10331050
const version = (await rs.conf()).version;
@@ -1061,6 +1078,18 @@ describe('ReplicaSet', function () {
10611078
});
10621079
describe('configureQueryAnalyzer()', function () {
10631080
skipIfServerVersion(srv0, '< 7.0'); // analyzeShardKey will only be added in 7.0 which is not included in stable yet
1081+
let unsubscribeAllowWarnings: (() => void)[];
1082+
1083+
before(function () {
1084+
// Allow "Attempted to disable query sampling but query sampling was not active" warnings
1085+
unsubscribeAllowWarnings = [srv0, srv1, srv2, srv3].map((s) =>
1086+
s.allowWarning?.(7724700)
1087+
);
1088+
});
1089+
1090+
after(function () {
1091+
for (const cb of unsubscribeAllowWarnings) cb();
1092+
});
10641093

10651094
const docs: any[] = [];
10661095
for (let i = 0; i < 1000; i++) {
@@ -1105,6 +1134,24 @@ describe('ReplicaSet', function () {
11051134
);
11061135

11071136
let serviceProvider: NodeDriverServiceProvider;
1137+
let unsubscribeAllowWarnings: (() => void)[];
1138+
1139+
before(function () {
1140+
// Allow "replSetReconfig" errors
1141+
unsubscribeAllowWarnings = [srv0, srv1, srv2].map((s) =>
1142+
s.allowWarning?.((entry) => {
1143+
return (
1144+
entry.id === 21420 &&
1145+
entry.attr?.error?.codeName ===
1146+
'NewReplicaSetConfigurationIncompatible'
1147+
);
1148+
})
1149+
);
1150+
});
1151+
1152+
after(function () {
1153+
for (const cb of unsubscribeAllowWarnings) cb();
1154+
});
11081155

11091156
beforeEach(async function () {
11101157
serviceProvider = await NodeDriverServiceProvider.connect(

packages/shell-api/src/session.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,17 @@ describe('Session', function () {
446446
});
447447
describe('after resetting connection will error with expired session', function () {
448448
skipIfApiStrict();
449+
let unsubscribeAllowWarning: undefined | (() => void);
450+
451+
before(function () {
452+
// Allow "The logout command has been deprecated" warnings
453+
unsubscribeAllowWarning = srv0.allowWarning?.(5626600);
454+
});
455+
456+
after(function () {
457+
unsubscribeAllowWarning?.();
458+
});
459+
449460
it('reset connection options', async function () {
450461
session = mongo.startSession();
451462
await mongo.setReadConcern('majority');

0 commit comments

Comments
 (0)