Skip to content
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

Use framework.ExpectNoError() for e2e tests #77103

Closed
22 of 23 tasks
oomichi opened this issue Apr 26, 2019 · 36 comments · Fixed by #77612 or #78779
Closed
22 of 23 tasks

Use framework.ExpectNoError() for e2e tests #77103

oomichi opened this issue Apr 26, 2019 · 36 comments · Fixed by #77612 or #78779
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. sig/testing Categorizes an issue or PR as relevant to SIG Testing.

Comments

@oomichi
Copy link
Member

oomichi commented Apr 26, 2019

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)

After finishing all the above, we need to add the checking script to the CI system for blocking PRs which contain this issue:

@oomichi oomichi added the kind/bug Categorizes issue or PR as related to a bug. label Apr 26, 2019
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Apr 26, 2019
@oomichi
Copy link
Member Author

oomichi commented Apr 26, 2019

/sig testing

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 26, 2019
@atoato88
Copy link
Contributor

I can work to following items.

  • test/e2e/lifecycle
  • test/e2e/lifecycle/bootstrap

@k-toyoda-pi
Copy link
Contributor

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?

  • test/e2e/apimachinery
  • test/e2e/apps
  • test/e2e/instrumentation
  • test/e2e/kubectl
  • test/e2e/servicecatalog
  • test/e2e/ui
  • test/e2e/upgrades/apps
  • test/e2e/upgrades
  • test/e2e/upgrades/storage
  • test/e2e/windows

@oomichi
Copy link
Member Author

oomichi commented Apr 26, 2019

@k-toyoda-pi Thanks, I updated the list based on your comment :-)

@k-toyoda-pi
Copy link
Contributor

k-toyoda-pi commented Apr 26, 2019

Thanks, I can work to the following item.

  • test/e2e/apps

@s-ito-ts
Copy link
Contributor

I can work to the following item.

  • test/e2e/autoscaling

@liggitt liggitt added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed kind/bug Categorizes issue or PR as related to a bug. labels Apr 27, 2019
@draveness
Copy link
Contributor

draveness commented Apr 27, 2019

I want to take the files below.

test/e2e/apimachinery
test/e2e/network
test/e2e/node
test/e2e/instrumentation
test/e2e/kubectl
test/e2e/scalability
test/e2e/scheduling
test/e2e/servicecatalog
test/e2e/ui
test/e2e/upgrades/apps
test/e2e/upgrades
test/e2e/upgrades/storage
test/e2e/windows

And I use the following cmd to do the refactor, which may be helpful.

ag -l "gomega\.Expect\(err\)\.NotTo\(gomega.HaveOccurred\(\)\)" test/e2e/network/**/*.go test/e2e/node/**/*.go test/e2e/instrumentation/**/*.go ... | xargs sed -i '' -e 's/gomega\.Expect(err)\.NotTo(gomega.HaveOccurred())/framework\.ExpectNoError(err)/g'

@oomichi
Copy link
Member Author

oomichi commented May 8, 2019

I am creating a hacking script which detects what code we need to update for this issue as #77612
Still we have almost 400 lines what we need to update at this time.

@draveness
Copy link
Contributor

draveness commented May 9, 2019

Here is the remaining files with gomega.Expect(err)...

$ ag -l "gomega\.Expect\(err\)\.NotTo\(gomega.HaveOccurred\(\)\)" .
test/e2e/lifecycle/kubelet_security.go
test/e2e/lifecycle/reboot.go
test/e2e/lifecycle/restart.go
test/e2e/lifecycle/resize_nodes.go
test/e2e/common/pods.go
test/e2e/upgrades/storage/persistent_volumes.go
test/e2e/upgrades/storage/volume_mode.go
test/e2e/upgrades/apps/statefulset.go
test/e2e/upgrades/apps/job.go
test/e2e/apps/deployment.go
test/e2e/apps/daemon_set.go

I'd like to take files except for test/e2e/apps and test/e2e/lifecycle since they are already taken.

test/e2e/common/pods.go
test/e2e/upgrades/storage/persistent_volumes.go
test/e2e/upgrades/storage/volume_mode.go
test/e2e/upgrades/apps/statefulset.go
test/e2e/upgrades/apps/job.go

@draveness
Copy link
Contributor

draveness commented May 9, 2019

It seems like this issue will be solved after #77627 #77649 #77579 merged. :)

@oomichi
Copy link
Member Author

oomichi commented May 9, 2019

@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 :-(

@oomichi
Copy link
Member Author

oomichi commented May 9, 2019

Thank you everyone who are fighting for this issue.
After the pull-kubernetes-verify job of #77612 pass, we can close this issue.

@oomichi
Copy link
Member Author

oomichi commented May 9, 2019

Feel free to /retest on #77612 to verify our work status.

@draveness
Copy link
Contributor

draveness commented May 15, 2019

This is the remaining file with the common formats

  • gomega.Expect(err).NotTo(gomega.HaveOccurred(), msg)
  • gomega.Expect(err).NotTo(gomega.HaveOccurred())
$ ag -l "gomega\.Expect\(err\)\.NotTo\(gomega.HaveOccurred\(\).*"
test/e2e/network/dns.go
test/e2e/network/firewall.go
test/e2e/network/proxy.go
test/e2e/network/service.go
test/e2e/network/ingress.go
test/e2e/network/dns_common.go
test/e2e/network/example_cluster_dns.go
test/e2e/network/network_tiers.go
test/e2e/network/network_policy.go
test/e2e/common/pods.go
test/e2e/node/kubelet.go
test/e2e/node/security_context.go
test/e2e/node/pre_stop.go
test/e2e/node/pods.go
test/e2e/node/ttlafterfinished.go
test/e2e/node/kubelet_perf.go
test/e2e/apps/disruption.go

I'll take care of the test/e2e/apps/disruption.go, and the other files seem like already been taken.

@oomichi
Copy link
Member Author

oomichi commented May 15, 2019

Thanks for doing this again @draveness
test/e2e/apps/disruption.go had been fixed at once, but after that new test code contains gomega.Expect(err).NotTo(gomega.HaveOccurred()) again.
So it is nice to take care of that again and now I really want to enable #77612 at the CI so that we don't need to take care of this issue forever.

@draveness
Copy link
Contributor

Thanks for doing this again @draveness
test/e2e/apps/disruption.go had been fixed at once, but after that new test code contains gomega.Expect(err).NotTo(gomega.HaveOccurred()) again.
So it is nice to take care of that again and now I really want to enable #77612 at the CI so that we don't need to take care of this issue forever.

Yeah, that would be great, but we have to fix all the gomega.Expect(err).NotTo(gomega.HaveOccurred()) ahead.

@k-toyoda-pi
Copy link
Contributor

k-toyoda-pi commented May 15, 2019

I'm done all files in e2e/network at #77901 #77909.

@oomichi
Copy link
Member Author

oomichi commented May 15, 2019

Thanks everyone, all PRs are ready for fixing this issue at this time.
I'd like to get attention from reviewers for making progress :-)

@k-toyoda-pi
Copy link
Contributor

It seems that some files in e2e/common contain "Expect(err).NotTo(HaveOccurred()".
Is someone working to that? Can I take it?

  • test/e2e/common/configmap_volume.go
  • test/e2e/common/downwardapi_volume.go
  • test/e2e/common/expansion.go
  • test/e2e/common/init_container.go
  • test/e2e/common/node_lease.go
  • test/e2e/common/privileged.go
  • test/e2e/common/projected_configmap.go
  • test/e2e/common/projected_downwardapi.go
  • test/e2e/common/projected_secret.go
  • test/e2e/common/secrets_volume.go
  • test/e2e/common/volumes.go

Oops, it might cause conflict between #77852 and this ...

@draveness
Copy link
Contributor

It seems that some files in e2e/common contain "Expect(err).NotTo(HaveOccurred()".
Is someone working to that? Can I take it?

  • test/e2e/common/configmap_volume.go
  • test/e2e/common/downwardapi_volume.go
  • test/e2e/common/expansion.go
  • test/e2e/common/init_container.go
  • test/e2e/common/node_lease.go
  • test/e2e/common/privileged.go
  • test/e2e/common/projected_configmap.go
  • test/e2e/common/projected_downwardapi.go
  • test/e2e/common/projected_secret.go
  • test/e2e/common/secrets_volume.go
  • test/e2e/common/volumes.go

Oops, it might cause conflict between #77852 and this ...

I'll work on this after the above PRs get merged.

@k-toyoda-pi
Copy link
Contributor

I believe that NotTo is the same behavior as ToNot.
So, can we replace Expect(err).ToNot(HaveOccurred()) to ExpectNoError?

@s-ito-ts
Copy link
Contributor

It seems that "Expect(err).NotTo(gomega.HaveOccurred())" remains with some files under test/e2e/storage/vsphere.
I fix it in #78021

@oomichi
Copy link
Member Author

oomichi commented May 17, 2019

@k-toyoda-pi

I believe that NotTo is the same behavior as ToNot.
So, can we replace Expect(err).ToNot(HaveOccurred()) to ExpectNoError?

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 #77612
After that, we will be able to take care of 'ToNot' case with another issue.

@oomichi
Copy link
Member Author

oomichi commented May 17, 2019

@s-ito-ts Thanks approved.

@oomichi
Copy link
Member Author

oomichi commented May 17, 2019

@k-toyoda-pi

It seems that some files in e2e/common contain "Expect(err).NotTo(HaveOccurred()".
Is someone working to that? Can I take it?

Sorry, that was my bad. I've taken care of that with the above PR.
I will try asking folks in KubeCon next week so that these all PRs are merged.

@odinuge
Copy link
Member

odinuge commented Jun 6, 2019

Hi! Noticed that this only checked the normal e2e tests. I have made the script check e2e_node and e2e_kubeadm as well in #78779.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. sig/testing Categorizes an issue or PR as relevant to SIG Testing.
Projects
None yet
8 participants