Change:
What happened: After fixing golint failures under (now still in progress), we need to put for each and . Then very common error checking code has become like: We can replace this code with 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) [x] test/e2e ( ) [x] test/e2e/apimachinery ( ) [x] test/e2e/apps () [x] test/e2e/auth ( [x] test/e2e/autoscaling ( [x] test/e2e/common ( ) [x] test/e2e/framework/providers/gce [x] test/e2e/lifecycle ( ) [x] test/e2e/lifecycle/bootstrap ( ) [x] test/e2e/network ( ) [x] test/e2e/node ( ) [x] test/e2e/instrumentation ( [x] test/e2e/kubectl ( [x] test/e2e/scalability ( ) [x] test/e2e/scheduling ( ) [x] test/e2e/servicecatalog [x] e2e/storage/vsphere () [x] test/e2e/ui ( [x] test/e2e/upgrades/apps ( ) [x] test/e2e/upgrades ( ) [x] test/e2e/upgrades/storage ( [x] test/e2e/windows ( After finishing all the above, we need to add the checking script to the CI system for blocking PRs which contain this issue: [ ]
/sig testing
I can work to following items. test/e2e/lifecycle test/e2e/lifecycle/bootstrap
I think that we can replace , 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
Thanks, I updated the list based on your comment :-)
Thanks, I can work to the following item. test/e2e/apps
I can work to the following item. test/e2e/autoscaling
I want to take the files below. And I use the following cmd to do the refactor, which may be helpful.
I am creating a hacking script which detects what code we need to update for this issue as Still we have almost 400 lines what we need to update at this time.
Here is the remaining files with I'd like to take files except for and since they are already taken.
It seems like this issue will be solved after merged. :)
which you are using cannot cover the following case which contains error message: So still we have a lot of targets at this time :-(
Thank you everyone who are fighting for this issue. After the pull-kubernetes-verify job of pass, we can close this issue.
Feel free to on to verify our work status.
I just dug around to find the remaining case with the form of : And I have left a message in , the issue will be solved after: update with the cmd I left and merged. merged merged
There are still codes with the form when the var does not have the name , I could fix the problem after all the above PR get merged.
done .
Following items are target of this issue too. This is a case that is consisted of multiple lines. These were gotten by and filtered in manual way. I've confirmed that these are target by checking each item.
Yeah, I noticed that and I'll fix all the remaining case after the PRs above get merged :)
All PRs which try fixing this issue have been merged except my PRs at this time. To make progress for merging I am making assignees free for each file which is not fixed now. Please feel free to raise hands again if possible.
I can work to test/e2e/network.
I can work to test/e2e/node.
I am working on test/e2e/scheduling and test/e2e/scalability.
I could take the files below
This is the remaining file with the common formats + I'll take care of the , and the other files seem like already been taken.
Thanks for doing this again had been fixed at once, but after that new test code contains again. So it is nice to take care of that again and now I really want to enable 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 ahead.
I'm done all files in e2e/network at .
Thanks everyone, all PRs are ready for fixing this issue at this time. I'd like to get attention from reviewers for making progress :-)
It seems that some files in e2e/common contain "Expect(err).NotTo(HaveOccurred()". Is someone working to that? Can I take it? Oops, it might cause conflict between and this ...
I'll work on this after the above PRs get merged.
I believe that is the same behavior as . So, can we replace to ?
It seems that "Expect(err).NotTo(gomega.HaveOccurred())" remains with some files under test/e2e/storage/vsphere. I fix it in
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 After that, we will be able to take care of 'ToNot' case with another issue.
Thanks approved.
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.
Hi! Noticed that this only checked the normal e2e tests. I have made the script check and as well in

Discussion:
<ins> #!/usr/bin/env bash # Copyright 2019 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #     http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -o errexit set -o nounset set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. cd "${KUBE_ROOT}" mapfile -t all_e2e_files < <(find test/e2e -name '*.go') errors_expect_no_error=() for file in "${all_e2e_files[@]}" do if grep "Expect(.*).NotTo(.*HaveOccurred()" "${file}" > /dev/null then errors_expect_no_error+=( "${file}" ) fi done if [ ${#errors_expect_no_error[@]} -ne 0 ]; then { echo "Errors:" for err in "${errors_expect_no_error[@]}"; do echo "$err" done echo echo 'The above files need to use framework.ExpectNoError(err) instead of ' echo 'Expect(err).NotTo(HaveOccurred()) or gomega.Expect(err).NotTo(gomega.HaveOccurred())' echo } >&2 exit 1 fi echo 'Congratulations!  All e2e test source files are valid.' </ins>

client := f.ClientSet configmap := nonDeletableConfigmap(f) _, err := client.CoreV1().ConfigMaps(f.Namespace.Name).Create(configmap) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to create configmap %s in namespace: %s", configmap.Name, f.Namespace.Name) </del> <ins> framework.ExpectNoError(err, "failed to create configmap %s in namespace: %s", configmap.Name, f.Namespace.Name) </ins> ginkgo.By("deleting the configmap should be denied by the webhook") err = client.CoreV1().ConfigMaps(f.Namespace.Name).Delete(configmap.Name, &metav1.DeleteOptions{})

cm.Data["webhook-e2e-test"] = "webhook-allow" } _, err = updateConfigMap(client, f.Namespace.Name, configmap.Name, toCompliantFn) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to update configmap %s in namespace: %s", configmap.Name, f.Namespace.Name) </del> <ins> framework.ExpectNoError(err, "failed to update configmap %s in namespace: %s", configmap.Name, f.Namespace.Name) </ins> ginkgo.By("deleting the updated configmap should be successful") err = client.CoreV1().ConfigMaps(f.Namespace.Name).Delete(configmap.Name, &metav1.DeleteOptions{}) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to delete configmap %s in namespace: %s", configmap.Name, f.Namespace.Name) </del> <ins> framework.ExpectNoError(err, "failed to delete configmap %s in namespace: %s", configmap.Name, f.Namespace.Name) </ins> } func testAttachingPodWebhook(f *framework.Framework) {

}, } _, err := customResourceClient.Create(crInstance, metav1.CreateOptions{}) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to create custom resource %s in namespace: %s", crInstanceName, f.Namespace.Name) </del> <ins> framework.ExpectNoError(err, "failed to create custom resource %s in namespace: %s", crInstanceName, f.Namespace.Name) </ins> ginkgo.By("Deleting the custom resource should be denied") err = customResourceClient.Delete(crInstanceName, &metav1.DeleteOptions{})

data["webhook-e2e-test"] = "webhook-allow" } _, err = updateCustomResource(customResourceClient, f.Namespace.Name, crInstanceName, toCompliantFn) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to update custom resource %s in namespace: %s", crInstanceName, f.Namespace.Name) </del> <ins> framework.ExpectNoError(err, "failed to update custom resource %s in namespace: %s", crInstanceName, f.Namespace.Name) </ins> ginkgo.By("Deleting the updated custom resource should be successful") err = customResourceClient.Delete(crInstanceName, &metav1.DeleteOptions{}) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to delete custom resource %s in namespace: %s", crInstanceName, f.Namespace.Name) </del> <ins> framework.ExpectNoError(err, "failed to delete custom resource %s in namespace: %s", crInstanceName, f.Namespace.Name) </ins> }

ginkgo.By("Verifying LimitRange updating is effective") err = wait.Poll(time.Second*2, time.Second*20, func() (bool, error) { limitRange, err = f.ClientSet.CoreV1().LimitRanges(f.Namespace.Name).Get(limitRange.Name, metav1.GetOptions{}) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred()) </del> <ins> framework.ExpectNoError(err) </ins> return reflect.DeepEqual(limitRange.Spec.Limits[0].Min, newMin), nil }) framework.ExpectNoError(err)

// Get the related PV pv, err := c.CoreV1().PersistentVolumes().Get(claim.Spec.VolumeName, metav1.GetOptions{}) <del> gomega.Expect(err).NotTo(gomega.HaveOccurred()) </del> framework.ExpectNoError(err) pvZone, ok := pv.ObjectMeta.Labels[v1.LabelZoneFailureDomain]