47
47
import static org .junit .jupiter .api .Assertions .assertThrows ;
48
48
49
49
/**
50
- * See <a href="https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.rst #test-plan">spec</a>
50
+ * See <a href="https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md #test-plan">spec</a>
51
51
*
52
52
* <p>
53
53
* NOTE: This class also contains tests that aren't categorized as Prose tests.
@@ -175,16 +175,32 @@ public void test08NotLambda() {
175
175
});
176
176
}
177
177
178
+ @ Test
179
+ public void test09ValidContainerAndFaasProvider () {
180
+ withWrapper ()
181
+ .withEnvironmentVariable ("AWS_EXECUTION_ENV" , "AWS_Lambda_java8" )
182
+ .withEnvironmentVariable ("AWS_REGION" , "us-east-2" )
183
+ .withEnvironmentVariable ("AWS_LAMBDA_FUNCTION_MEMORY_SIZE" , "1024" )
184
+ .withEnvironmentVariable ("KUBERNETES_SERVICE_HOST" , "1" )
185
+ .run (() -> {
186
+ BsonDocument expected = createExpectedClientMetadataDocument (APP_NAME );
187
+ expected .put ("env" , BsonDocument .parse ("{'name': 'aws.lambda', 'memory_mb': 1024, 'region': 'us-east-2', 'container': {'orchestrator': 'kubernetes'}}" ));
188
+ BsonDocument actual = createActualClientMetadataDocument ();
189
+ assertEquals (expected , actual );
190
+
191
+ performHello ();
192
+ });
193
+ }
194
+
178
195
// Additional tests, not specified as prose tests:
179
196
180
197
@ Test
181
198
void testKubernetesMetadataIncluded () {
182
199
withWrapper ()
183
- .withEnvironmentVariable ("AWS_EXECUTION_ENV" , "AWS_Lambda_java8" )
184
200
.withEnvironmentVariable ("KUBERNETES_SERVICE_HOST" , "kubernetes.default.svc.cluster.local" )
185
201
.run (() -> {
186
202
BsonDocument expected = createExpectedClientMetadataDocument (APP_NAME );
187
- expected .put ("env" , BsonDocument .parse ("{'name': 'aws.lambda', ' container': {'orchestrator': 'kubernetes'}}" ));
203
+ expected .put ("env" , BsonDocument .parse ("{'container': {'orchestrator': 'kubernetes'}}" ));
188
204
BsonDocument actual = createActualClientMetadataDocument ();
189
205
assertEquals (expected , actual );
190
206
@@ -199,10 +215,9 @@ void testDockerMetadataIncluded() {
199
215
pathsMockedStatic .when (() -> Files .exists (path )).thenReturn (true );
200
216
201
217
withWrapper ()
202
- .withEnvironmentVariable ("AWS_EXECUTION_ENV" , "AWS_Lambda_java8" )
203
218
.run (() -> {
204
219
BsonDocument expected = createExpectedClientMetadataDocument (APP_NAME );
205
- expected .put ("env" , BsonDocument .parse ("{'name': 'aws.lambda', ' container': {'runtime': 'docker'}}" ));
220
+ expected .put ("env" , BsonDocument .parse ("{'container': {'runtime': 'docker'}}" ));
206
221
BsonDocument actual = createActualClientMetadataDocument ();
207
222
assertEquals (expected , actual );
208
223
@@ -218,12 +233,10 @@ void testDockerAndKubernetesMetadataIncluded() {
218
233
pathsMockedStatic .when (() -> Files .exists (path )).thenReturn (true );
219
234
220
235
withWrapper ()
221
- .withEnvironmentVariable ("AWS_EXECUTION_ENV" , "AWS_Lambda_java8" )
222
236
.withEnvironmentVariable ("KUBERNETES_SERVICE_HOST" , "kubernetes.default.svc.cluster.local" )
223
237
.run (() -> {
224
238
BsonDocument expected = createExpectedClientMetadataDocument (APP_NAME );
225
- expected .put ("env" , BsonDocument .parse ("{'name': 'aws.lambda', 'container': {'runtime': 'docker', "
226
- + "'orchestrator': 'kubernetes'}}" ));
239
+ expected .put ("env" , BsonDocument .parse ("{'container': {'runtime': 'docker', 'orchestrator': 'kubernetes'}}" ));
227
240
BsonDocument actual = createActualClientMetadataDocument ();
228
241
assertEquals (expected , actual );
229
242
0 commit comments