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

feat: adding separate bucket based on python version for integration tests. #1828

Merged
merged 3 commits into from Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions appveyor.yml
Expand Up @@ -15,6 +15,7 @@ environment:
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_37_PIP: 1
INSTALL_PY_38_PIP: 1
AWS_S3: 'AWS_S3_36'

- PYTHON_HOME: "C:\\Python37-x64"
PYTHON_VERSION: '3.7.4'
Expand All @@ -23,6 +24,7 @@ environment:
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_36_PIP: 1
INSTALL_PY_38_PIP: 1
AWS_S3: 'AWS_S3_37'

- PYTHON_HOME: "C:\\Python38-x64"
PYTHON_VERSION: '3.8.0'
Expand All @@ -31,6 +33,7 @@ environment:
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_36_PIP: 1
INSTALL_PY_37_PIP: 1
AWS_S3: 'AWS_S3_38'

for:
-
Expand Down
20 changes: 19 additions & 1 deletion tests/integration/package/package_integ_base.py
Expand Up @@ -14,7 +14,25 @@ class PackageIntegBase(TestCase):
@classmethod
def setUpClass(cls):
cls.region_name = os.environ.get("AWS_DEFAULT_REGION")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be below doc strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually doc string is only for the line where we are reading AWS_S3 and not for the whole method. That is why I didn't move this below docstring. Thoughts?

cls.pre_created_bucket = os.environ.get("AWS_S3", False)
"""
Our integration tests use S3 bucket to run several tests. Given that S3 objects are eventually consistent
and we are using same bucket for lot of integration tests, we want to have multiple buckets to reduce
transient failures. In order to achieve this we created 3 buckets one for each python version we support (3.6,
3.7 and 3.8). Tests running for respective python version will use respective bucket.

AWS_S3 will point to a new environment variable AWS_S3_36 or AWS_S3_37 or AWS_S3_38. This is controlled by
Appveyor. These environment variables will hold bucket name to run integration tests. Eg:

For Python36:
AWS_S3=AWS_S3_36
AWS_S3_36=aws-sam-cli-canary-region-awssamclitestbucket-forpython36
Copy link
Contributor

Choose a reason for hiding this comment

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

Do no document bucket names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a real bucket name. Something I made up based on how real name looks like.


For backwards compatibility we are falling back to reading AWS_S3 so that current tests keep working.
"""
cls.pre_created_bucket = os.environ.get(
os.environ.get("AWS_S3", False), # Reading env var key for specific bucket.
os.environ.get("AWS_S3"), # Fallback to old logic if separate env key not present.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not the same fallback. The previous fallback had a value of False.

)
cls.bucket_name = cls.pre_created_bucket if cls.pre_created_bucket else str(uuid.uuid4())
cls.test_data_path = Path(__file__).resolve().parents[1].joinpath("testdata", "package")

Expand Down
6 changes: 5 additions & 1 deletion tests/integration/publish/publish_app_integ_base.py
Expand Up @@ -16,7 +16,11 @@ class PublishAppIntegBase(TestCase):
@classmethod
def setUpClass(cls):
cls.region_name = os.environ.get("AWS_DEFAULT_REGION")
cls.pre_created_bucket = os.environ.get("AWS_S3", False)
"""Please read comments in package_integ_base.py for more details around this."""
cls.pre_created_bucket = os.environ.get(
os.environ.get("AWS_S3", False), # Reading env var key for specific bucket.
os.environ.get("AWS_S3"), # Fallback to old logic if separate env key not present.
)
cls.bucket_name = cls.pre_created_bucket if cls.pre_created_bucket else str(uuid.uuid4())
cls.bucket_name_placeholder = "<bucket-name>"
cls.application_name_placeholder = "<application-name>"
Expand Down
6 changes: 5 additions & 1 deletion tests/regression/package/regression_package_base.py
Expand Up @@ -17,7 +17,11 @@ class PackageRegressionBase(TestCase):
@classmethod
def setUpClass(cls):
cls.region_name = os.environ.get("AWS_DEFAULT_REGION")
cls.pre_created_bucket = os.environ.get("AWS_S3", False)
"""Please read comments in package_integ_base.py for more details around this."""
cls.pre_created_bucket = os.environ.get(
os.environ.get("AWS_S3", False), # Reading env var key for specific bucket.
os.environ.get("AWS_S3"), # Fallback to old logic if separate env key not present.
)
cls.bucket_name = cls.pre_created_bucket if cls.pre_created_bucket else str(uuid.uuid4())
cls.test_data_path = Path(__file__).resolve().parents[2].joinpath("integration", "testdata", "package")

Expand Down