Commit Graph

12 Commits

Author SHA1 Message Date
Patrick Ohly
181fc50f8e e2e framework: deprecate gomega wrappers
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 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.
This enables stricter
linting (https://github.com/kubernetes/kubernetes/pull/109728), once enabled,
to report new code which uses them.
2023-02-23 09:51:42 +01:00
Kenichi Omichi
12c0eaef25 Use ExpectNoError(err)
We missed another pattern to check error doesn't happen on e2e tests.
This covers the pattern for consistent test implementation.
2020-09-03 23:29:07 +00:00
Kenichi Omichi
f7fb21c394 Add check for blocking tests in e2e framework
e2e test framework provides useful functions for implementing e2e tests,
but the framework itself should not contain e2e tests theirself.
This adds hacking check for blocking implementing e2e tests in the
framework.
2020-06-15 18:08:19 +00:00
toyoda
7499d80fd8 Use ExpectNotEqual in test/e2e/network/ 2020-03-18 16:30:56 +09:00
Jin Hase
093fd4ab02 Add comments in several hack/verify-*.sh(s-v) 2020-01-21 19:10:46 +09:00
Kenichi Omichi
ad988085f6 Add code check for framework.ExpectEqual()
This adds code check for using framework.ExpectEqual(foo, bar) in
e2e tests for keeping the test code simple.
2019-07-31 19:03:39 +00:00
Kubernetes Prow Robot
614aab80f5
Merge pull request #78740 from oomichi/extend-check
Make the check strict to use ExpectNoError()
2019-07-30 01:59:04 -07:00
Kenichi Omichi
5628b6b50e Replace mapfile with kube::util::read-array
During the review of https://github.com/kubernetes/kubernetes/pull/78779
we've known mapfile doesn't work on macOS.
So we need to use alternative way instead and this is it.
2019-06-20 00:25:06 +00:00
Kenichi Omichi
d5bc1ae8aa Make the check strict to use ExpectNoError()
As https://github.com/kubernetes/kubernetes/pull/78478 we can use
ExpectNoError() instead of Expect(err).ToNot(HaveOccurred()) also.
This makes the test code check strict to cover the above case and
replaces the remaining in test/e2e/common/expansion.go
2019-06-18 16:55:16 +00:00
Odin Ugedal
b0a1cba71a
Run verify-test-code on all e2e tests 2019-06-14 17:51:49 +02:00
Kenichi Omichi
63e0507fd9 Check e2e test code to use ExpectError()
We can use framework.ExpectError() for checking the expected error
happens. However Expect(err).To(HaveOccurred()) can be used instead
and that makes the e2e test code unreadable.
This adds the check to use framework.ExpectError() for readable code.
2019-05-29 17:04:58 +00:00
Kenichi Omichi
496a18febc Add hack/verify-test-code.sh
This script checks coding style for test code.
It is useful to enforce developers to use framework methods for
keeping readable test code for example.
2019-05-22 14:15:25 +00:00