-
Notifications
You must be signed in to change notification settings - Fork 20
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
Refactor all e2e tests to use fixture #49
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: A-Hilaly The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
a7dd9ff
to
0fe7c71
Compare
Refactoring e2e tests to use pytest.fixture for the resource under test. Otherwise, assertion failures within the test may not lead to successful resource cleanup.
@dataclass | ||
class ResourceWaitTimes: | ||
Create: int | ||
Update: int | ||
Delete: int |
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.
Could be defined in the test-infra
package. Also, we should probably provide sane defaults (say 5 seconds for each?)
class ServiceWaitTimes: | ||
Function: ResourceWaitTimes | ||
Alias: ResourceWaitTimes | ||
CodeSigningConfig: ResourceWaitTimes | ||
EventSourceMapping: ResourceWaitTimes | ||
FunctionURLConfig: ResourceWaitTimes | ||
|
||
Wait = ServiceWaitTimes( | ||
Function = ResourceWaitTimes(30, 30, 30), | ||
Alias = ResourceWaitTimes(10, 10, 10), | ||
CodeSigningConfig = ResourceWaitTimes(10, 10, 10), | ||
EventSourceMapping = ResourceWaitTimes(20, 20, 20), | ||
FunctionURLConfig = ResourceWaitTimes(30, 10, 10), | ||
) |
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 think I'd prefer to see each of these defined in their respective test files. They can be cross-imported if we need to access them in other tests.
@@ -32,6 +72,12 @@ def pytest_configure(config): | |||
config.addinivalue_line( | |||
"markers", "slow: mark test as slow to run" | |||
) | |||
config.addinivalue_line( | |||
"markers", "function_overrides: function parameters to override when creating fixture" |
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.
PyTest markers are used to label a test - not to provide a parameter to tests. For instance, we have a marker for "slow" tests, in case you want to skip them. I would prefer if we just hardcode the test values, or use another mechanism for parameterising these
@@ -44,8 +90,259 @@ def pytest_collection_modifyitems(config, items): | |||
# Provide a k8s client to interact with the integration test cluster | |||
@pytest.fixture(scope='class') | |||
def k8s_client(): | |||
return k8s._get_k8s_api_client() | |||
return k8sclient._get_k8s_api_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.
Just for the sake of consistency with the other tests, would you mind changing this back to k8s
. In conjunction with my comments below, this shouldn't conflict.
return boto3.client('lambda', region_name=get_region()) | ||
|
||
@pytest.fixture |
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.
Pytest fixtures should be defined in whichever scope they're used. I defined lambda_client
and k8s_client
in this file because they can be used by every/any test. These fixtures below are specific to individual tests (function, code signing, etc.). I'd prefer if we moved these to the test_*.py
files. If we need to re-use the fixture as part of another test, it would be better to just import them across files.
REPLACEMENT_VALUES = { | ||
|
||
"AWS_REGION": get_region() |
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.
This is globally defined, as part of acktest
- no need to redefine it here. https://github.com/aws-controllers-k8s/test-infra/blob/main/src/acktest/resources.py#L32
@pytest.mark.function_overrides({ | ||
'package_type': 'Zip', | ||
'role_type': 'esm', | ||
}) | ||
@pytest.mark.esm_overrides({'source': 'ddbtable'}) |
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.
What's the purpose of these markers? Do they interact with the fixtures?
Issues go stale after 90d of inactivity. |
/lifecycle frozen |
@a-hilaly: The In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/remove-lifecycle stale |
Issues go stale after 180d of inactivity. |
Stale issues rot after 60d of inactivity. |
Issues go stale after 180d of inactivity. |
@a-hilaly: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Stale issues rot after 60d of inactivity. |
Refactoring e2e tests to use pytest.fixture for the resource under test.
Otherwise, assertion failures within the test may not lead to successful
resource cleanup.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.