-
Notifications
You must be signed in to change notification settings - Fork 553
test/e2e: Refactor the Operator e2e tests to clean up testing resources #2518
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
test/e2e: Refactor the Operator e2e tests to clean up testing resources #2518
Conversation
test/e2e/operator_test.go
Outdated
Eventually(func() error { | ||
return client.Create(clientCtx, o) | ||
}).Should(Succeed()) | ||
Context("when an Operator resource can select its components by label", func() { |
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.
Note: moved this from an It
to a Context
so we gain access to BeforeEach/AfterEach/etc. blocks. Before, this It spec would leak testing Operator resources when it failed the test case (but cleaned up properly when it passed).
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.
A question and a nit:
Question: Why not start with a When
?
nit: We should probably clean up the long list in the comment too. I believe they were written when old tests were being ported over to ginkgo, but time constraint forced to putting these in It
blocks and keep those comments for safe measures.
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.
@anik120 +1 for both points.
How easily accessible is the same information in those comments if we were to remove them? Only thing I'd want to make sure of is that we're not losing context in removing them.
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.
Yep agreed - I removed the list of existing comments from this PR and changed the Context -> When container. I'd like to hold off on refactoring that "should surface referenced components in its status" test case as it's not been marked as a flaky when Per had added support for identifying and running flaky tests in their own workflow in #2624.
Expect(err).ToNot(HaveOccurred()) | ||
defer w.Stop() | ||
It("should not contain copied csv status references", func() { | ||
Consistently(o).ShouldNot(ContainCopiedCSVReferences()) |
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 moved this check to it's own It spec as before we were checking whether the operator object had any CSV references before creating that resource, leading to what appeared to be a wasted check.
test/e2e/operator_test.go
Outdated
} | ||
return err | ||
}).Should(Succeed()) | ||
}) | ||
}) | ||
|
||
Context("when a subscription to a package exists", func() { |
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.
Note: we were previously leaking the kiali installation, it's CRDs, and the corresponding Operator resource that was generated despite these test cases passing or failing.
}) | ||
}).Should(Succeed()) | ||
|
||
By("Deleting the test Operator resource") |
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.
It's highly likely that the generated Operator resource will be left behind, despite this check being in place, as there's some caching issues in the current operator controller. I added a top-level DeleteCollection call in the AfterEach block to help alleviate the frequency this happens.
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.
looks great Tim, have a few very small nits other lgtm
test/e2e/operator_test.go
Outdated
Eventually(func() error { | ||
return client.Create(clientCtx, o) | ||
}).Should(Succeed()) | ||
Context("when an Operator resource can select its components by label", func() { |
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.
A question and a nit:
Question: Why not start with a When
?
nit: We should probably clean up the long list in the comment too. I believe they were written when old tests were being ported over to ginkgo, but time constraint forced to putting these in It
blocks and keep those comments for safe measures.
Expect(err).To(BeNil()) | ||
defer w.Stop() |
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.
Expect(err).To(BeNil()) | |
defer w.Stop() | |
defer w.Stop() | |
Expect(err).To(BeNil()) |
Expect(err).To(BeNil()) | |
defer w.Stop() | |
Expect(err).To(BeNil()) | |
defer w.Stop() |
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 updated the Context -> When given the comment structure was already there. Do you have any preference when to use a Context vs. When containers? I wasn't able to find any best practices around structuring ginkgo e2e tests so there might be something I'm missing.
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.
/lgtm
Small question, but overall the approach looks great. I like the defer pattern you have for cleaning up the resources.
nsB.SetName(genName("ns-b-")) | ||
return false | ||
})) | ||
defer w.Stop() |
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.
Is this second defer w.Stop()
necassary?
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 don't think so - I mainly just indented the existing test cases vs. making any heavy modifications.
c813df3
to
2e808cf
Compare
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: timflannagan 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 |
46ff42f
to
4bb317b
Compare
4bb317b
to
c3bb990
Compare
Update test/e2e/operator_test.go and attempt to refactor the current e2e specs to reduce the number of testing artifacts that are left behind when individual tests pass/fail. Signed-off-by: timflannagan <[email protected]>
c3bb990
to
1a21657
Compare
@timflannagan: PR needs rebase. 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. |
Update test/e2e/operator_test.go and attempt to refactor the current e2e
specs to reduce the number of testing artifacts that are left behind
when individual tests pass/fail.
Signed-off-by: timflannagan [email protected]
Description of the change:
Motivation for the change:
Reviewer Checklist
/doc