|
1 | 1 | import { expect } from 'chai';
|
2 | 2 | import * as sinon from 'sinon';
|
3 | 3 |
|
4 |
| -import { Connection, getFAASEnv, LEGACY_HELLO_COMMAND, type MongoClient } from '../../mongodb'; |
| 4 | +import { |
| 5 | + Connection, |
| 6 | + getFAASEnv, |
| 7 | + Int32, |
| 8 | + LEGACY_HELLO_COMMAND, |
| 9 | + type MongoClient |
| 10 | +} from '../../mongodb'; |
5 | 11 | describe('Handshake Prose Tests', function () {
|
6 | 12 | let client: MongoClient;
|
7 | 13 |
|
@@ -110,6 +116,49 @@ describe('Handshake Prose Tests', function () {
|
110 | 116 | });
|
111 | 117 | }
|
112 | 118 |
|
| 119 | + context('Test 9: Valid container and FaaS provider', function () { |
| 120 | + const env = [ |
| 121 | + ['AWS_EXECUTION_ENV', 'AWS_Lambda_java8'], |
| 122 | + ['AWS_REGION', 'us-east-2'], |
| 123 | + ['AWS_LAMBDA_FUNCTION_MEMORY_SIZE', '1024'], |
| 124 | + ['KUBERNETES_SERVICE_HOST', '1'] |
| 125 | + ] as EnvironmentVariables; |
| 126 | + before(() => { |
| 127 | + for (const [key, value] of env) { |
| 128 | + process.env[key] = value; |
| 129 | + } |
| 130 | + }); |
| 131 | + after(() => { |
| 132 | + for (const [key] of env) { |
| 133 | + delete process.env[key]; |
| 134 | + } |
| 135 | + }); |
| 136 | + |
| 137 | + it('runs a hello successfully', async function () { |
| 138 | + client = this.configuration.newClient({ |
| 139 | + // if the handshake is not truncated, the `hello`s fail and the client does |
| 140 | + // not connect. Lowering the server selection timeout causes the tests |
| 141 | + // to fail more quickly in that scenario. |
| 142 | + serverSelectionTimeoutMS: 3000 |
| 143 | + }); |
| 144 | + await client.connect(); |
| 145 | + }); |
| 146 | + |
| 147 | + it('includes both container and FAAS provider information in the client metadata', async function () { |
| 148 | + client = this.configuration.newClient(); |
| 149 | + await client.connect(); |
| 150 | + expect(client.topology?.s.options.extendedMetadata).to.exist; |
| 151 | + const { env } = await client.topology.s.options.extendedMetadata; |
| 152 | + |
| 153 | + expect(env).to.deep.equal({ |
| 154 | + region: 'us-east-2', |
| 155 | + name: 'aws.lambda', |
| 156 | + memory_mb: new Int32(1024), |
| 157 | + container: { orchestrator: 'kubernetes' } |
| 158 | + }); |
| 159 | + }); |
| 160 | + }); |
| 161 | + |
113 | 162 | context(`Test 2: Test that the driver accepts an arbitrary auth mechanism`, function () {
|
114 | 163 | let stubCalled = false;
|
115 | 164 | beforeEach(() => {
|
|
0 commit comments