Fix bootstrap tests failing in non-default region#10152
Fix bootstrap tests failing in non-default region#10152viren-nadkarni merged 6 commits intomasterfrom
Conversation
S3 Image Test Results (AMD64 / ARM64) 2 files 2 suites 3m 8s ⏱️ Results for commit 707ebf9. ♻️ This comment has been updated with latest results. |
TO BE REVERTED BEFORE MERGE
LocalStack Community integration with Pro 2 files 2 suites 1h 22m 38s ⏱️ Results for commit b3686f1. ♻️ This comment has been updated with latest results. |
818483b to
b34b0c4
Compare
b34b0c4 to
3b4bab4
Compare
| infra.add_custom_setup( | ||
| lambda: load_python_lambda_to_s3( | ||
| s3_client=aws_client.s3, | ||
| bucket_name=infra.get_asset_bucket(), |
There was a problem hiding this comment.
localstack/localstack/testing/scenario/provisioning.py
Lines 102 to 105 in b3686f1
I'm not certain about the intended purpose of get_asset_bucket() helper so I've not changed its behaviour.
There was a problem hiding this comment.
I think this makes sense in this case, but we probably want to allow infrastructure_setup to take account/region. Then this helper would be OK I think? cc @dominikschubert
See
localstack/tests/bootstrap/conftest.py
Lines 22 to 37 in 896ba4b
We build a new client factory here without accepting region/account configuration.
There was a problem hiding this comment.
I'll make a note of it, since I'll soon try to rework the provisioner a bit for asset support as well 👍 For now the solution seems fine, the bucket naming was mostly done for compatibility with live-AWS which isn't really relevant for bootstrap tests here
simonrw
left a comment
There was a problem hiding this comment.
Thanks for tackling this issue. I agree this should be fixed, but I am unsure if the change you have made is correct. I have approved since it works, but this might need to be upstreamed into the CDK setup code to cover more cases. What do you think @dominikschubert?
| infra.add_custom_setup( | ||
| lambda: load_python_lambda_to_s3( | ||
| s3_client=aws_client.s3, | ||
| bucket_name=infra.get_asset_bucket(), |
There was a problem hiding this comment.
I think this makes sense in this case, but we probably want to allow infrastructure_setup to take account/region. Then this helper would be OK I think? cc @dominikschubert
See
localstack/tests/bootstrap/conftest.py
Lines 22 to 37 in 896ba4b
We build a new client factory here without accepting region/account configuration.
| infra.add_custom_setup( | ||
| lambda: load_python_lambda_to_s3( | ||
| s3_client=aws_client.s3, | ||
| bucket_name=infra.get_asset_bucket(), |
There was a problem hiding this comment.
I'll make a note of it, since I'll soon try to rework the provisioner a bit for asset support as well 👍 For now the solution seems fine, the bucket naming was mostly done for compatibility with live-AWS which isn't really relevant for bootstrap tests here
Summary
This PR fixes the following bootstrap test when run in non-default account ID/region:
tests.bootstrap.test_cosmetic_configuration.TestLocalStackHost.test_scenarioChanges
The S3 bucket had the account ID and region hardcoded in the name within the CDK template. When the tests were run in a different account ID or region, the bucket name would be different causing the test to fail.
Tests
See
ci/circleci: bootstrap-testsjob for commit 707ebf9 🟢 - this run used non-default test credentials to demonstrate that the tests pass