Skip to content

Commit d9fd2d9

Browse files
committed
Adding e2e tests for ScalingConfig
1 parent 7f8b7ff commit d9fd2d9

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ack_generate_info:
2-
build_date: "2023-01-29T21:40:15Z"
2+
build_date: "2023-02-01T00:38:06Z"
33
build_hash: 12246c7da82841b351ec7a9e1f139f9338f2784b
44
go_version: go1.19
55
version: v0.20.1-14-g12246c7

test/e2e/tests/test_event_source_mapping.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_smoke_sqs_queue_stream(self, lambda_client, lambda_function):
9090
replacements["EVENT_SOURCE_MAPPING_NAME"] = resource_name
9191
replacements["BATCH_SIZE"] = "10"
9292
replacements["FUNCTION_NAME"] = lambda_function_name
93+
replacements["RESERVED_CONCURRENT_EXECUTIONS"] = "10"
9394
replacements["EVENT_SOURCE_ARN"] = resources.ESMQueue.arn
9495
replacements["MAXIMUM_BATCHING_WINDOW_IN_SECONDS"] = "1"
9596

@@ -128,6 +129,7 @@ def test_smoke_sqs_queue_stream(self, lambda_client, lambda_function):
128129
},
129130
]
130131
}
132+
cr["spec"]["scalingConfig"] = {"maximumConcurrency": 4}
131133

132134
# Patch k8s resource
133135
k8s.patch_custom_resource(ref, cr)
@@ -142,6 +144,7 @@ def test_smoke_sqs_queue_stream(self, lambda_client, lambda_function):
142144
"Pattern": "{\"controller-version\":[\"v1\"]}"
143145
},
144146
]
147+
assert esm["ScalingConfig"]["MaximumConcurrency"] == 4
145148

146149
# Delete the filterCriteria field
147150
cr = k8s.wait_resource_consumed_by_controller(ref)
@@ -319,4 +322,69 @@ def test_smoke_dynamodb_table_stream(self, lambda_client, lambda_function):
319322
time.sleep(DELETE_WAIT_AFTER_SECONDS)
320323

321324
# 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

Comments
 (0)