kubernetes: Use framework.ExpectNoError() for e2e tests
What happened:
After fixing golint failures under test/e2e (now still in progress), we need to put gomega for each Expect() and HaveOccurred().
Then very common error checking code has become like:
gomega.Expect(err).NotTo(gomega.HaveOccurred())
We can replace this code with framework.ExpectNoError(err) which is more readable and easy to be understood what the code does.
Now we have following e2e test directories which can be replaced: ( - [x] shows done)
- test/e2e (@oomichi https://github.com/kubernetes/kubernetes/pull/77693)
- test/e2e/apimachinery (@draveness https://github.com/kubernetes/kubernetes/pull/77708)
- test/e2e/apps (https://github.com/kubernetes/kubernetes/pull/77894)
- test/e2e/auth (@oomichi)
- test/e2e/autoscaling (@s-ito-ts)
- test/e2e/common (@oomichi https://github.com/kubernetes/kubernetes/pull/78042)
- test/e2e/framework/providers/gce
- test/e2e/lifecycle (@atoato88 https://github.com/kubernetes/kubernetes/pull/77649)
- test/e2e/lifecycle/bootstrap (@atoato88 https://github.com/kubernetes/kubernetes/pull/77754)
- test/e2e/network (@k-toyoda-pi https://github.com/kubernetes/kubernetes/pull/77901 https://github.com/kubernetes/kubernetes/pull/77909)
- test/e2e/node (@s-ito-ts https://github.com/kubernetes/kubernetes/pull/77902)
- test/e2e/instrumentation (@draveness)
- test/e2e/kubectl (@draveness)
- test/e2e/scalability (@oomichi https://github.com/kubernetes/kubernetes/pull/77890)
- test/e2e/scheduling (@oomichi https://github.com/kubernetes/kubernetes/pull/77890)
- test/e2e/servicecatalog
- e2e/storage/vsphere (https://github.com/kubernetes/kubernetes/pull/78021)
- test/e2e/ui (@draveness)
- test/e2e/upgrades/apps (@draveness https://github.com/kubernetes/kubernetes/pull/77627)
- test/e2e/upgrades (@oomichi https://github.com/kubernetes/kubernetes/pull/77955)
- test/e2e/upgrades/storage (@draveness)
- test/e2e/windows (@draveness)
After finishing all the above, we need to add the checking script to the CI system for blocking PRs which contain this issue:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 36 (36 by maintainers)
I want to take the files below.
And I use the following cmd to do the refactor, which may be helpful.
I think that we can replace
gomega.Expect(err).NotTo(gomega.HaveOccurred()), too. Files in the following directories have it. Could you add these directories to list?@k-toyoda-pi
This is a really nice point, I also think they are the same. However, it is better to concentrate on ‘NotTo’ case only at this time because that is majority and many people are still adding it. We need to put the CI script for blocking these additions with https://github.com/kubernetes/kubernetes/pull/77612 After that, we will be able to take care of ‘ToNot’ case with another issue.
I’ll work on this after the above PRs get merged.
Yeah, I noticed that and I’ll fix all the remaining case after the PRs above get merged 😃
Following items are target of this issue too. This is a case that is consisted of multiple lines.
These were gotten by
grep -n -e "NotTo(.*HaveOccurred"and filtered in manual way. I’ve confirmed that these are target by checking each item.@draveness
$ ag -l "gomega\.Expect\(err\)\.NotTo\(gomega.HaveOccurred\(\)\)"which you are using cannot cover the following case which contains error message:gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to get pod %q", pod.Name)So still we have a lot of targets at this time 😦I can work to the following item.
Thanks, I can work to the following item.
I can work to following items.