@@ -44,7 +44,7 @@ def lambda_function():
44
44
replacements ["BUCKET_NAME" ] = resources .FunctionsBucket .name
45
45
replacements ["LAMBDA_ROLE" ] = resources .ESMRole .arn
46
46
replacements ["LAMBDA_FILE_NAME" ] = LAMBDA_FUNCTION_FILE_ZIP
47
- replacements ["RESERVED_CONCURRENT_EXECUTIONS" ] = "0 "
47
+ replacements ["RESERVED_CONCURRENT_EXECUTIONS" ] = "10 "
48
48
replacements ["CODE_SIGNING_CONFIG_ARN" ] = ""
49
49
replacements ["AWS_REGION" ] = get_region ()
50
50
@@ -319,4 +319,69 @@ def test_smoke_dynamodb_table_stream(self, lambda_client, lambda_function):
319
319
time .sleep (DELETE_WAIT_AFTER_SECONDS )
320
320
321
321
# Check ESM doesn't exist
322
- assert not lambda_validator .event_source_mapping_exists (esm_uuid )
322
+ assert not lambda_validator .event_source_mapping_exists (esm_uuid )
323
+
324
+ def test_scaling_config (self , lambda_client , lambda_function ):
325
+
326
+ (_ , function_resource ) = lambda_function
327
+ lambda_function_name = function_resource ["spec" ]["name" ]
328
+
329
+ resource_name = random_suffix_name ("lambda-esm" , 24 )
330
+ resources = get_bootstrap_resources ()
331
+
332
+ replacements = REPLACEMENT_VALUES .copy ()
333
+ replacements ["AWS_REGION" ] = get_region ()
334
+ replacements ["EVENT_SOURCE_MAPPING_NAME" ] = resource_name
335
+ replacements ["BATCH_SIZE" ] = "10"
336
+ replacements ["RESERVED_CONCURRENT_EXECUTIONS" ] = "10"
337
+ replacements ["FUNCTION_NAME" ] = lambda_function_name
338
+ replacements ["EVENT_SOURCE_ARN" ] = resources .ESMQueue .arn
339
+ replacements ["MAXIMUM_BATCHING_WINDOW_IN_SECONDS" ] = "1"
340
+
341
+ # Load ESM CR
342
+ resource_data = load_lambda_resource (
343
+ "event_source_mapping_sqs" ,
344
+ additional_replacements = replacements ,
345
+ )
346
+ logging .debug (resource_data )
347
+
348
+ # Create k8s resource
349
+ ref = k8s .CustomResourceReference (
350
+ CRD_GROUP , CRD_VERSION , RESOURCE_PLURAL ,
351
+ resource_name , namespace = "default" ,
352
+ )
353
+ k8s .create_custom_resource (ref , resource_data )
354
+ cr = k8s .wait_resource_consumed_by_controller (ref )
355
+
356
+ assert cr is not None
357
+ assert k8s .get_resource_exists (ref )
358
+
359
+ time .sleep (CREATE_WAIT_AFTER_SECONDS )
360
+
361
+ esm_uuid = cr ['status' ]['uuid' ]
362
+
363
+ lambda_validator = LambdaValidator (lambda_client )
364
+ # Check ESM exists
365
+ assert lambda_validator .event_source_mapping_exists (esm_uuid )
366
+
367
+ # Update cr
368
+ cr ["spec" ]["scalingConfig" ] = {"maximumConcurrency" : 4 }
369
+
370
+ # Patch k8s resource
371
+ k8s .patch_custom_resource (ref , cr )
372
+ time .sleep (UPDATE_WAIT_AFTER_SECONDS )
373
+
374
+ # Check ESM batch size
375
+ esm = lambda_validator .get_event_source_mapping (esm_uuid )
376
+ assert esm is not None
377
+ assert esm ["ScalingConfig" ]["MaximumConcurrency" ] == 4
378
+
379
+ # Delete k8s resource
380
+ _ , deleted = k8s .delete_custom_resource (ref )
381
+ assert deleted
382
+
383
+ time .sleep (DELETE_WAIT_AFTER_SECONDS )
384
+
385
+ # Check ESM doesn't exist
386
+ assert not lambda_validator .event_source_mapping_exists (esm_uuid )
387
+
0 commit comments