@@ -90,6 +90,7 @@ def test_smoke_sqs_queue_stream(self, lambda_client, lambda_function):
90
90
replacements ["EVENT_SOURCE_MAPPING_NAME" ] = resource_name
91
91
replacements ["BATCH_SIZE" ] = "10"
92
92
replacements ["FUNCTION_NAME" ] = lambda_function_name
93
+ replacements ["RESERVED_CONCURRENT_EXECUTIONS" ] = "10"
93
94
replacements ["EVENT_SOURCE_ARN" ] = resources .ESMQueue .arn
94
95
replacements ["MAXIMUM_BATCHING_WINDOW_IN_SECONDS" ] = "1"
95
96
@@ -128,6 +129,7 @@ def test_smoke_sqs_queue_stream(self, lambda_client, lambda_function):
128
129
},
129
130
]
130
131
}
132
+ cr ["spec" ]["scalingConfig" ] = {"maximumConcurrency" : 4 }
131
133
132
134
# Patch k8s resource
133
135
k8s .patch_custom_resource (ref , cr )
@@ -142,6 +144,7 @@ def test_smoke_sqs_queue_stream(self, lambda_client, lambda_function):
142
144
"Pattern" : "{\" controller-version\" :[\" v1\" ]}"
143
145
},
144
146
]
147
+ assert esm ["ScalingConfig" ]["MaximumConcurrency" ] == 4
145
148
146
149
# Delete the filterCriteria field
147
150
cr = k8s .wait_resource_consumed_by_controller (ref )
@@ -319,4 +322,69 @@ def test_smoke_dynamodb_table_stream(self, lambda_client, lambda_function):
319
322
time .sleep (DELETE_WAIT_AFTER_SECONDS )
320
323
321
324
# Check ESM doesn't exist
322
- assert not lambda_validator .event_source_mapping_exists (esm_uuid )
325
+ assert not lambda_validator .event_source_mapping_exists (esm_uuid )
326
+
327
+ def test_scaling_config (self , lambda_client , lambda_function ):
328
+
329
+ (_ , function_resource ) = lambda_function
330
+ lambda_function_name = function_resource ["spec" ]["name" ]
331
+
332
+ resource_name = random_suffix_name ("lambda-esm" , 24 )
333
+ resources = get_bootstrap_resources ()
334
+
335
+ replacements = REPLACEMENT_VALUES .copy ()
336
+ replacements ["AWS_REGION" ] = get_region ()
337
+ replacements ["EVENT_SOURCE_MAPPING_NAME" ] = resource_name
338
+ replacements ["BATCH_SIZE" ] = "10"
339
+ replacements ["RESERVED_CONCURRENT_EXECUTIONS" ] = "10"
340
+ replacements ["FUNCTION_NAME" ] = lambda_function_name
341
+ replacements ["EVENT_SOURCE_ARN" ] = resources .ESMQueue .arn
342
+ replacements ["MAXIMUM_BATCHING_WINDOW_IN_SECONDS" ] = "1"
343
+
344
+ # Load ESM CR
345
+ resource_data = load_lambda_resource (
346
+ "event_source_mapping_sqs" ,
347
+ additional_replacements = replacements ,
348
+ )
349
+ logging .debug (resource_data )
350
+
351
+ # Create k8s resource
352
+ ref = k8s .CustomResourceReference (
353
+ CRD_GROUP , CRD_VERSION , RESOURCE_PLURAL ,
354
+ resource_name , namespace = "default" ,
355
+ )
356
+ k8s .create_custom_resource (ref , resource_data )
357
+ cr = k8s .wait_resource_consumed_by_controller (ref )
358
+
359
+ assert cr is not None
360
+ assert k8s .get_resource_exists (ref )
361
+
362
+ time .sleep (CREATE_WAIT_AFTER_SECONDS )
363
+
364
+ esm_uuid = cr ['status' ]['uuid' ]
365
+
366
+ lambda_validator = LambdaValidator (lambda_client )
367
+ # Check ESM exists
368
+ assert lambda_validator .event_source_mapping_exists (esm_uuid )
369
+
370
+ # Update cr
371
+ cr ["spec" ]["scalingConfig" ] = {"maximumConcurrency" : 4 }
372
+
373
+ # Patch k8s resource
374
+ k8s .patch_custom_resource (ref , cr )
375
+ time .sleep (UPDATE_WAIT_AFTER_SECONDS )
376
+
377
+ # Check ESM batch size
378
+ esm = lambda_validator .get_event_source_mapping (esm_uuid )
379
+ assert esm is not None
380
+ assert esm ["ScalingConfig" ]["MaximumConcurrency" ] == 4
381
+
382
+ # Delete k8s resource
383
+ _ , deleted = k8s .delete_custom_resource (ref )
384
+ assert deleted
385
+
386
+ time .sleep (DELETE_WAIT_AFTER_SECONDS )
387
+
388
+ # Check ESM doesn't exist
389
+ assert not lambda_validator .event_source_mapping_exists (esm_uuid )
390
+
0 commit comments