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": "^11.5.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?.match(
/SSL peer certificate or SSH remote key was not OK|Peer certificate cannot be authenticated/
)
);
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?.match(
/SSL peer certificate or SSH remote key was not OK|Peer certificate cannot be authenticated/
)
);
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 @@ -686,6 +686,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 @@ -695,6 +697,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 @@ -799,6 +802,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 @@ -818,6 +823,7 @@ describe('e2e', function () {
}
])`);
expect(result).to.include("{ sum: '12' }");
unsubscribe?.();
});
});

Expand Down Expand Up @@ -2654,6 +2660,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 @@ -2672,6 +2679,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 @@ -2702,7 +2718,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 @@ -2715,6 +2731,7 @@ describe('e2e', function () {
currentOpShell.assertNoErrors();

expect(currentOpCall).to.include(stringifiedRegExpString);
await currentCommand;
});
});
});
Expand Down
3 changes: 3 additions & 0 deletions packages/java-shell/src/test/js/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ describe('java-shell tests', function() {
const packageRoot = path.resolve(__dirname, '..', '..', '..') + '/';

before(async function () {
// We don't have a way to allow warnings for individual tests here
testServer.allowWarning?.(() => true);

process.env.JAVA_SHELL_MONGOSH_TEST_URI = (await testServer.connectionString()).replace(/\/$/, '');

const connectionString = await testServer.connectionString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ describe('NodeDriverServiceProvider [integration]', function () {
});

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

before(function () {
// Allow "$function is deprecated" warning in logs
unsubscribeAllowWarnings = [
testServer.allowWarning?.(8996503) ?? [],
].flat();
});

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

context(
'when passing a $function to be serialized by the driver',
function () {
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
Loading
Loading