-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix provisioned concurrency set on Lambda alias #12592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2539,6 +2539,59 @@ def test_provisioned_concurrency(self, create_lambda_function, snapshot, aws_cli | |
result2 = json.load(invoke_result2["Payload"]) | ||
assert result2 == "on-demand" | ||
|
||
@markers.aws.validated | ||
def test_provisioned_concurrency_on_alias(self, create_lambda_function, snapshot, aws_client): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Should we be confirming within the test that no additional containers are brought up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There will be an additional container brought up for the last invocation, but in general, confirming that we hit the right invocation type environment should be sufficient, otherwise we cannot validate it against AWS as well. |
||
""" | ||
Tests provisioned concurrency created and invoked using an alias | ||
""" | ||
# TODO add test that you cannot set provisioned concurrency on both alias and version it points to | ||
# TODO can you set provisioned concurrency on multiple aliases pointing to the same function version? | ||
min_concurrent_executions = 10 + 5 | ||
check_concurrency_quota(aws_client, min_concurrent_executions) | ||
|
||
func_name = f"test_lambda_{short_uid()}" | ||
alias_name = "live" | ||
|
||
create_lambda_function( | ||
func_name=func_name, | ||
handler_file=TEST_LAMBDA_INVOCATION_TYPE, | ||
runtime=Runtime.python3_12, | ||
client=aws_client.lambda_, | ||
) | ||
|
||
v1 = aws_client.lambda_.publish_version(FunctionName=func_name) | ||
aws_client.lambda_.create_alias( | ||
FunctionName=func_name, Name=alias_name, FunctionVersion=v1["Version"] | ||
) | ||
|
||
put_provisioned = aws_client.lambda_.put_provisioned_concurrency_config( | ||
FunctionName=func_name, Qualifier=alias_name, ProvisionedConcurrentExecutions=5 | ||
) | ||
snapshot.match("put_provisioned_5", put_provisioned) | ||
|
||
get_provisioned_prewait = aws_client.lambda_.get_provisioned_concurrency_config( | ||
FunctionName=func_name, Qualifier=alias_name | ||
) | ||
|
||
snapshot.match("get_provisioned_prewait", get_provisioned_prewait) | ||
assert wait_until(concurrency_update_done(aws_client.lambda_, func_name, alias_name)) | ||
get_provisioned_postwait = aws_client.lambda_.get_provisioned_concurrency_config( | ||
FunctionName=func_name, Qualifier=alias_name | ||
) | ||
snapshot.match("get_provisioned_postwait", get_provisioned_postwait) | ||
|
||
invoke_result1 = aws_client.lambda_.invoke(FunctionName=func_name, Qualifier=alias_name) | ||
result1 = json.load(invoke_result1["Payload"]) | ||
assert result1 == "provisioned-concurrency" | ||
|
||
invoke_result1 = aws_client.lambda_.invoke(FunctionName=func_name, Qualifier=v1["Version"]) | ||
result1 = json.load(invoke_result1["Payload"]) | ||
assert result1 == "provisioned-concurrency" | ||
|
||
invoke_result2 = aws_client.lambda_.invoke(FunctionName=func_name, Qualifier="$LATEST") | ||
result2 = json.load(invoke_result2["Payload"]) | ||
assert result2 == "on-demand" | ||
|
||
@markers.aws.validated | ||
def test_lambda_provisioned_concurrency_scheduling( | ||
self, snapshot, create_lambda_function, aws_client | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs: Would a docstring help to clarify our findings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments on it!