Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { expect } from 'chai';
import * as sinon from 'sinon';

import { Connection, getFAASEnv, LEGACY_HELLO_COMMAND, type MongoClient } from '../../mongodb';
import {
Connection,
getFAASEnv,
Int32,
LEGACY_HELLO_COMMAND,
type MongoClient
} from '../../mongodb';
describe('Handshake Prose Tests', function () {
let client: MongoClient;

Expand Down Expand Up @@ -110,6 +116,49 @@ describe('Handshake Prose Tests', function () {
});
}

context('Test 9: Valid container and FaaS provider', function () {
const env = [
['AWS_EXECUTION_ENV', 'AWS_Lambda_java8'],
['AWS_REGION', 'us-east-2'],
['AWS_LAMBDA_FUNCTION_MEMORY_SIZE', '1024'],
['KUBERNETES_SERVICE_HOST', '1']
] as EnvironmentVariables;
before(() => {
for (const [key, value] of env) {
process.env[key] = value;
}
});
after(() => {
for (const [key] of env) {
delete process.env[key];
}
});

it('runs a hello successfully', async function () {
client = this.configuration.newClient({
// if the handshake is not truncated, the `hello`s fail and the client does
// not connect. Lowering the server selection timeout causes the tests
// to fail more quickly in that scenario.
serverSelectionTimeoutMS: 3000
});
await client.connect();
});

it('includes both container and FAAS provider information in the client metadata', async function () {
client = this.configuration.newClient();
await client.connect();
expect(client.topology?.s.options.extendedMetadata).to.exist;
const { env } = await client.topology.s.options.extendedMetadata;

expect(env).to.deep.equal({
region: 'us-east-2',
name: 'aws.lambda',
memory_mb: new Int32(1024),
container: { orchestrator: 'kubernetes' }
});
});
});

context(`Test 2: Test that the driver accepts an arbitrary auth mechanism`, function () {
let stubCalled = false;
beforeEach(() => {
Expand Down