-
Notifications
You must be signed in to change notification settings - Fork 85
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
Update list to filter resources using label selectors #488
Conversation
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 looks awesome! Would you mind adding some tests?
af1c81d
to
d50a0c1
Compare
@porridge Sure thing! I just updated the test cases to allow for several 'actual' resources to be created and added a case to test the label matching. |
Signed-off-by: jtucci <[email protected]>
Signed-off-by: jtucci <[email protected]>
7c084aa
to
45c9e39
Compare
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.
The error returning fix LGTM overall, but I have one worry, see inline.
Also, please take a look at the TestCheckResourceIntegration/match_object_by_labels,_field_mismatch
that started failing.
Any ideas about this one, @jtucci ? |
I just pushed the fix, the integration tests are passing locally for me now. |
Signed-off-by: jtucci <[email protected]>
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.
❤️
See PR #488. Signed-off-by: Marcin Owsiany <[email protected]>
See PR #488. Signed-off-by: Marcin Owsiany <[email protected]>
What this PR does / why we need it:
Currently, If no name is specified in an assert resource, the CheckResource and CheckResourceAbsent will find all resources of with the same gvk and assert against one of the resources returned in the list. This PR is a proposal to enhance how resources are matched by filtering the resources by any included labels in the case where no name is specified.
Example Use Case / Scenario
We are using KUTTL for e2e testing for the crossplane compositions we are developing. The resources we are asserting against (managed resources) are created in a similar way to pods being created by a replica set, in that the metadata.name will contain a random uuid. In the case where there are several resources of the same gvk, we are unable to guarantee that the correct resource is asserted against which causes unexpected failures within the tests. The only other workaround is running script commands such as:
This is very tedious (we have to do this for every field in the resource(s)). It also makes understanding any test failures difficult since no diff is shown, just that a command failed.
This enhancement would give us the ability to instead assert against the yaml definition of the resource like any other test would because we can specify unique labels to identify the resources. For example, the following two resources with no name and the same gvk would be asserted against the correct resource with the matching labels
Fixes #480