Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"husky": "^9.0.11",
"mocha": "^10.2.0",
"mongodb": "^6.19.0",
"mongodb-runner": "^6.0.0",
"mongodb-runner": "^6.2.0",
"node-gyp": "^9.0.0 || ^10.2.0",
"nyc": "^15.1.0",
"pkg-up": "^3.1.0",
Expand Down
16 changes: 16 additions & 0 deletions packages/cli-repl/src/cli-repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,22 @@ describe('CliRepl', function () {

context('for server >= 4.1', function () {
skipIfServerVersion(testServer, '< 4.1');
let unsubscribeAllowWarning: undefined | (() => void);

before(function () {
// Allow "$where is deprecated" and "operation was interrupted" warnings
unsubscribeAllowWarning = testServer.allowWarning?.((entry) => {
return (
entry.id === 8996500 ||
(entry.id === 23798 &&
entry.attr?.error?.codeName === 'ClientDisconnect')
);
});
});

after(function () {
unsubscribeAllowWarning?.();
});

it('terminates operations on the server side', async function () {
if (process.env.MONGOSH_TEST_FORCE_API_STRICT) {
Expand Down
9 changes: 9 additions & 0 deletions packages/e2e-tests/test/e2e-auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,15 @@ describe('Auth e2e', function () {
});
});
describe('logout', function () {
let unsubscribeAllowWarning: (() => void) | undefined;
beforeEach(function () {
// https://jira.mongodb.org/browse/SERVER-56266
// https://jira.mongodb.org/browse/MONGOSH-2695
unsubscribeAllowWarning = testServer.allowWarning?.(5626600);
});
afterEach(function () {
unsubscribeAllowWarning?.();
});
it('logs out after authenticating', async function () {
await shell.executeLine(`use ${dbName}`);
expect(await shell.executeLine('db.auth("anna", "pwd")')).to.include(
Expand Down
15 changes: 15 additions & 0 deletions packages/e2e-tests/test/e2e-oidc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ describe('OIDC auth e2e', function () {
...commonOidcServerArgs,
],
});
// The server will (rightfully) complain about the mock IdP's TLS certificate
// not being trusted - we can ignore that for the purposes of this test.
testServer2.allowWarning(
(entry) =>
entry.id === 7938401 &&
entry.attr?.error?.includes(
'SSL peer certificate or SSH remote key was not OK'
)
);
testServer3 = new MongoRunnerSetup('e2e-oidc-test-idtoken', {
args: [
'--setParameter',
Expand Down Expand Up @@ -154,6 +163,12 @@ describe('OIDC auth e2e', function () {
};
});

afterEach(function () {
testServer?.noServerWarningsCheckpoint();
testServer2?.noServerWarningsCheckpoint();
testServer3?.noServerWarningsCheckpoint();
});

after(async function () {
this.timeout(120_000);
await Promise.all([
Expand Down
14 changes: 14 additions & 0 deletions packages/e2e-tests/test/e2e-proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,18 @@ describe('e2e proxy support', function () {
...commonOidcServerArgs,
],
});
// The server will (rightfully) complain about the mock IdP's TLS certificate
// not being trusted - we can ignore that for the purposes of this test.
oidcTestServer.allowWarning(
(entry) =>
entry.id === 7938401 &&
entry.attr?.error?.includes(
'SSL peer certificate or SSH remote key was not OK'
)
);
await oidcTestServer.start();
});

after(async function () {
this.timeout(120_000);
await Promise.all([
Expand All @@ -437,6 +447,10 @@ describe('e2e proxy support', function () {
]);
});

afterEach(function () {
oidcTestServer?.noServerWarningsCheckpoint();
});

beforeEach(function () {
tokenFetches = 0;
getTokenPayload = (metadata) => {
Expand Down
19 changes: 18 additions & 1 deletion packages/e2e-tests/test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,8 @@ describe('e2e', function () {
if (process.env.MONGOSH_TEST_FORCE_API_STRICT) {
return this.skip(); // mapReduce is unversioned
}
// Allow "map reduce command is deprecated" warning in logs
const unsubscribe = testServer.allowWarning?.(5725801);
await shell.executeLine(`use ${dbName}`);
await shell.executeLine('db.test.insertMany([{i:1},{i:2},{i:3},{i:4}]);');
const result = await shell.executeLine(`db.test.mapReduce(function() {
Expand All @@ -696,6 +698,7 @@ describe('e2e', function () {
}, { out: { inline: 1 } }).results`);
expect(result).to.include('{ _id: 0, value: 6 }');
expect(result).to.include('{ _id: 1, value: 4 }');
unsubscribe?.();
});

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

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

Expand Down Expand Up @@ -2658,6 +2664,7 @@ describe('e2e', function () {
context('with 2 shells', function () {
let helperShell: TestShell;
let currentOpShell: TestShell;
let unsubscribeAllowWarning: undefined | (() => void);

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

before(function () {
// Allow "$where is deprecated" warnings
unsubscribeAllowWarning = testServer.allowWarning?.(8996500);
});

after(function () {
unsubscribeAllowWarning?.();
});

it('should return the current operation and clear when it is complete', async function () {
const currentCommand = helperShell.executeLine(
`db.coll.find({$where: function() { sleep(${OPERATION_TIME}) }}).projection({testProjection: 1})`
Expand Down Expand Up @@ -2706,7 +2722,7 @@ describe('e2e', function () {
-1
);

void helperShell.executeLine(
const currentCommand = helperShell.executeLine(
`db.coll.find({$where: function() { sleep(${OPERATION_TIME}) }}).projection({re: BSONRegExp('${stringifiedRegExpString}')})`
);
helperShell.assertNoErrors();
Expand All @@ -2719,6 +2735,7 @@ describe('e2e', function () {
currentOpShell.assertNoErrors();

expect(currentOpCall).to.include(stringifiedRegExpString);
await currentCommand;
});
});
});
Expand Down
60 changes: 60 additions & 0 deletions packages/shell-api/src/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,16 @@ describe('Shell API (integration)', function () {

describe('#reIndex', function () {
skipIfApiStrict();
let unsubscribeAllowWarning: undefined | (() => void);

before(function () {
// Allow "The reIndex command is deprecated" warnings
unsubscribeAllowWarning = testServer.allowWarning?.(6508600);
});

after(function () {
unsubscribeAllowWarning?.();
});

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

describe('runCommand', function () {
skipIfApiStrict();
let unsubscribeAllowWarning: undefined | (() => void);

before(function () {
// Allow "The collStats command is deprecated" warnings
unsubscribeAllowWarning = testServer.allowWarning?.(7024600);
});

after(function () {
unsubscribeAllowWarning?.();
});

beforeEach(async function () {
await serviceProvider.createCollection(dbName, collectionName);
Expand Down Expand Up @@ -1353,6 +1373,21 @@ describe('Shell API (integration)', function () {
// https://jira.mongodb.org/browse/SERVER-58076
skipIfServerVersion(testServer, '<= 6.0');
}
let unsubscribeAllowWarning: undefined | (() => void);

before(function () {
// Allow warning for the failing updateOne() below
unsubscribeAllowWarning = testServer.allowWarning?.(
(entry) =>
entry.id === 7267501 &&
entry.attr?.error?.codeName === 'DollarPrefixedFieldName'
);
});

after(function () {
unsubscribeAllowWarning?.();
});

it('can insert, modify and retrieve fields with $-prefixed .-containing names', async function () {
await collection.insertOne({ '$x.y': 1, _id: '_id' });
expect(await collection.findOne()).to.deep.equal({
Expand Down Expand Up @@ -1991,6 +2026,16 @@ describe('Shell API (integration)', function () {

describe('mapReduce', function () {
skipIfServerVersion(testServer, '< 4.4');
let unsubscribeAllowWarning: undefined | (() => void);

before(function () {
// Allow "The map reduce command is deprecated" warning
unsubscribeAllowWarning = testServer.allowWarning?.(5725801);
});

after(function () {
unsubscribeAllowWarning?.();
});

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

describe('maxTimeMS support', function () {
skipIfServerVersion(testServer, '< 4.2');
let unsubscribeAllowWarning: undefined | (() => void);

before(function () {
// Allow "$where is deprecated" warning and timeout warnings
unsubscribeAllowWarning = testServer.allowWarning?.(
(entry) =>
entry.id === 8996500 ||
(entry.id === 23798 &&
entry.attr?.error?.codeName === 'MaxTimeMSExpired')
);
});

after(function () {
unsubscribeAllowWarning?.();
});

beforeEach(async function () {
await collection.insertMany([...Array(10).keys()].map((i) => ({ i })));
Expand Down
47 changes: 47 additions & 0 deletions packages/shell-api/src/replica-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,23 @@ describe('ReplicaSet', function () {
});

describe('remove member', function () {
let unsubscribeAllowWarnings: (() => void)[];

before(function () {
// Allow "Unable to forward progress" warnings
unsubscribeAllowWarnings = [srv0, srv1, srv2, srv3].map((s) =>
s.allowWarning?.(
(entry) =>
entry.id === 21764 &&
entry.attr?.error?.codeName === 'NodeNotFound'
)
);
});

after(function () {
for (const cb of unsubscribeAllowWarnings) cb();
});

it('removes a member of the config', async function () {
const removeWithRetry = createRetriableMethod(rs, 'remove');
const version = (await rs.conf()).version;
Expand Down Expand Up @@ -1061,6 +1078,18 @@ describe('ReplicaSet', function () {
});
describe('configureQueryAnalyzer()', function () {
skipIfServerVersion(srv0, '< 7.0'); // analyzeShardKey will only be added in 7.0 which is not included in stable yet
let unsubscribeAllowWarnings: (() => void)[];

before(function () {
// Allow "Attempted to disable query sampling but query sampling was not active" warnings
unsubscribeAllowWarnings = [srv0, srv1, srv2, srv3].map((s) =>
s.allowWarning?.(7724700)
);
});

after(function () {
for (const cb of unsubscribeAllowWarnings) cb();
});

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

let serviceProvider: NodeDriverServiceProvider;
let unsubscribeAllowWarnings: (() => void)[];

before(function () {
// Allow "replSetReconfig" errors
unsubscribeAllowWarnings = [srv0, srv1, srv2].map((s) =>
s.allowWarning?.((entry) => {
return (
entry.id === 21420 &&
entry.attr?.error?.codeName ===
'NewReplicaSetConfigurationIncompatible'
);
})
);
});

after(function () {
for (const cb of unsubscribeAllowWarnings) cb();
});

beforeEach(async function () {
serviceProvider = await NodeDriverServiceProvider.connect(
Expand Down
Loading