Skip to content
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

Implementation of Lambda Advanced Configuration attribute #10591

Merged
merged 37 commits into from Apr 19, 2024

Conversation

Morijarti
Copy link
Contributor

Motivation

At the moment, AWS support Lambda Advanced configuration, which is caussing issue with snapshot testing since we do not support it in LS.

Changes

This PR aims to add advanced config to outputs in order to remove various ignores from tests

@Morijarti Morijarti changed the title Feat/lambda advanced config Implementation of Lambda Advanced Configuration attribute Apr 2, 2024
@Morijarti Morijarti added the semver: patch Non-breaking changes which can be included in patch releases label Apr 2, 2024
@Morijarti Morijarti self-assigned this Apr 2, 2024
Copy link

github-actions bot commented Apr 2, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 32m 0s ⏱️ - 1m 25s
2 890 tests +6  2 606 ✅ +6  284 💤 ±0  0 ❌ ±0 
2 892 runs  +6  2 606 ✅ +6  286 💤 ±0  0 ❌ ±0 

Results for commit 034461c. ± Comparison against base commit f6c21e3.

This pull request removes 1 and adds 7 tests. Note that renamed tests count towards both.
tests.aws.services.lambda_.test_lambda_api.TestLambdaSnapStart ‑ test_snapstart_update_function_configuration[java11]
tests.aws.services.lambda_.test_lambda_api.TestLambdaSnapStart ‑ test_snapstart_update_function_configuration[java21]
tests.aws.services.lambda_.test_lambda_api.TestLoggingConfig ‑ test_advanced_logging_configuration_format_switch
tests.aws.services.lambda_.test_lambda_api.TestLoggingConfig ‑ test_function_advanced_logging_configuration
tests.aws.services.lambda_.test_lambda_api.TestLoggingConfig ‑ test_function_partial_advanced_logging_configuration_update[partial_config0]
tests.aws.services.lambda_.test_lambda_api.TestLoggingConfig ‑ test_function_partial_advanced_logging_configuration_update[partial_config1]
tests.aws.services.lambda_.test_lambda_api.TestLoggingConfig ‑ test_function_partial_advanced_logging_configuration_update[partial_config2]
tests.aws.services.lambda_.test_lambda_api.TestLoggingConfig ‑ test_function_partial_advanced_logging_configuration_update[partial_config3]

♻️ This comment has been updated with latest results.

@Morijarti
Copy link
Contributor Author

Morijarti commented Apr 8, 2024

tests.aws.services.lambda_.test_lambda_api.TestLambdaLayer.test_layer_function_exceptions
Is failing as it appears that one additional resource is created on AWS side

>> match key: list_code_signing_configs
	(~) /CodeSigningConfigs/[0]/CodeSigningConfigArn 'arn:aws:lambda:<region>:111111111111:code-signing-config:<resource:2>' → 'arn:aws:lambda:<region>:111111111111:code-signing-config:<resource:1>' ... (expected → actual)
	(~) /CodeSigningConfigs/[0]/CodeSigningConfigId '<resource:2>' → '<resource:1>' ... (expected → actual)
	(~) /CodeSigningConfigs/[0]/CodeSigningPolicies/UntrustedArtifactOnDeployment 'Enforce' → 'Warn' ... (expected → actual)
	(-) /CodeSigningConfigs/[1] ( {'AllowedPublishers': {'SigningProfileVersionArns': ['arn:aws:signer:<region>:111111111111:/signing-profiles/test']}, 'CodeSigningConfigArn': 'arn:aws:lambda:<region>:111111111111:code-signing-config:<resource:1>', 'CodeSigningConfigId': '<resource:1>', 'CodeSigningPolicies': {'UntrustedArtifactOnDeployment': 'Warn'}, 'Description': 'Testing CodeSigning Config', 'LastModified': 'date'} )
	(+) /CodeSigningConfigs/[1] ( not present )

@Morijarti
Copy link
Contributor Author

Morijarti commented Apr 8, 2024

Following test fails on AWS:
test_cross_account_access

botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the GetLayerVersion operation: The security token included in the request is invalid.

@Morijarti
Copy link
Contributor Author

Morijarti commented Apr 8, 2024

Following test is failing on AWS:
TestLambdaConcurrency.test_lambda_provisioned_concurrency_scheduling

'provisioned-concurrency' != 'on-demand'

Expected :'on-demand'
Actual   :'provisioned-concurrency'

result2 = json.load(invoke_result2["Payload"])
>       assert result2 == "on-demand"

@Morijarti Morijarti marked this pull request as ready for review April 17, 2024 11:10
Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done @Morijarti with detailed test coverage 👏👏👏 LGTM 👍

I just added some minor suggestions to improve the naming, then everything is ready to merge 🚀
For further runtime updates (including ext), it is much better to tackle them in a separate PR.

localstack/services/lambda_/provider.py Outdated Show resolved Hide resolved
localstack/services/lambda_/provider.py Outdated Show resolved Hide resolved
localstack/services/lambda_/provider.py Outdated Show resolved Hide resolved
tests/aws/services/lambda_/test_lambda.py Show resolved Hide resolved
tests/aws/services/lambda_/test_lambda_api.py Outdated Show resolved Hide resolved
tests/aws/services/lambda_/test_lambda_api.py Outdated Show resolved Hide resolved
tests/aws/services/lambda_/test_lambda_api.py Show resolved Hide resolved
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
"AllowedPublishers": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dfangl FYI: AWS apparently changed the code signing behavior (see this backlog item)

@@ -13839,44 +14439,82 @@
}
}
},
"update-during-in-progress-update-exc": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snapshot diffs are often so confusing 😆

@joe4dev
Copy link
Member

joe4dev commented Apr 17, 2024

@Morijarti I triggered an ext test run against this branch. Please double-check that this one has no failing Lambda tests before merging, thank you!
PS: there's currently a failing websocket test test_apigatewaymanagementapi (see this Slack thread)

@Morijarti
Copy link
Contributor Author

@joe4dev I've updated PR with your suggestions. Thank you so much :)

@Morijarti
Copy link
Contributor Author

@Morijarti I triggered an ext test run against this branch. Please double-check that this one has no failing Lambda tests before merging, thank you! PS: there's currently a failing websocket test test_apigatewaymanagementapi (see this Slack thread)

I found few lambda related tests crashing in -ext. I'll create a companion PR for them.

}
}
},
"tests/aws/services/lambda_/test_lambda_api.py::TestLambdaFunction::test_function_partial_advanced_logging_configuration_update[partial_config0]": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Morijarti Can you remove these old snapshots after the renaming? Unfortunately, we currently don't have a convenient way to clean up such old snapshot leftovers 🧹

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

self, snapshot, create_lambda_function, lambda_su_role, aws_client
):
function_name = f"fn-{short_uid()}"
create_response = create_lambda_function(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that we don't have a test case where we initialize the logging configuration with the function creation. Would it make sense to add that here, given we are testing the default in the partial update below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.
I can add new tests for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to add it here directly. It feels we have already quite extensive API test coverage for a single parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, we weren't actually modifying logging config if passed during function creation.
It should be fixed now

@@ -869,6 +869,33 @@ def create_function(
)
# Runtime management controls are not available when providing a custom image
runtime_version_config = None
if "LoggingConfig" in request:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad we caught that one 😃

@joe4dev joe4dev merged commit 51b397f into master Apr 19, 2024
30 checks passed
@joe4dev joe4dev deleted the feat/lambda_advanced_config branch April 19, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants