E2E framework assertions

16 views
Skip to first unread message

Patrick Ohly

unread,
Feb 23, 2023, 3:49:24 AM2/23/23
to kubernetes-sig-testing
Hello!

In https://github.com/kubernetes/kubernetes/pull/115961, I am proposing
to deprecate the gomega wrappers that we have in the E2E framework. The
reasoning is (from that PR):

All wrappers except for ExpectNoError are identical to their gomega
counterparts. The only advantage that they have is that their
invocations are shorter.

That advantage does not outweigh their disadvantages:

- cannot be used in combination with gomega.Eventually/Consistently
- not a full replacement for gomega, so we just end up using both
- don't support passing a stack offset and thus cannot be used in helper
functions
- ginkgolinter (to be enabled in
https://github.com/kubernetes/kubernetes/pull/115953)
does not work for them, so sub-optimal calls like this one are not
reported:

framework.ExpectEqual(len(items), 0)
->
gomega.Expect(items).To(gomega.BeEmpty())

- developers try to make do with what's available in the framework,
leading to sub-optimal checks like this:

framework.ExpectEqual(true, strings.Contains(event.Message, expectedEventError), "Event error should indicate non-root policy caused container to not start")
->
gomega.Expect(event.Message).To(gomega.ContainSubstring(expectedEventError), "Event error should indicate non-root policy caused container to not start")

So let's remove these wrappers. As a first step they get marked as
deprecated. If you disagree, then please comment on the PR.

Next steps after that:
- enable stricter linting (https://github.com/kubernetes/kubernetes/pull/109728)
to report new code which uses them
- reverting back to plain gomega assertions (for a WIP
framework.ExpectEqual removal, see the end of
https://github.com/kubernetes/kubernetes/compare/master...pohly:test-e2e-gomega-wrapper-removal?expand=1)

Ideally those should follow quickly, to minimize the transition period.

--
Best Regards

Patrick Ohly
Reply all
Reply to author
Forward
0 new messages