test: fix ginkgolinter issues

All of these issues were reported by https://github.com/nunnatsa/ginkgolinter.
Fixing these issues is useful (several expressions get simpler, using
framework.ExpectNoError is better because it has additional support for
failures) and a necessary step for enabling that linter in our golangci-lint
invocation.
This commit is contained in:
Patrick Ohly
2023-02-22 10:35:09 +01:00
parent 443b1c6c23
commit 41f23f52d0
17 changed files with 47 additions and 47 deletions

View File

@@ -753,7 +753,7 @@ metadata:
return strings.Contains(logOutput, content), nil
})
gomega.Expect(err).To(gomega.BeNil(), fmt.Sprintf("unexpected error waiting for '%v' output", content))
framework.ExpectNoError(err, "waiting for '%v' output", content)
return logOutput
}
@@ -768,7 +768,7 @@ metadata:
gomega.Expect(runOutput).To(gomega.ContainSubstring("abcd1234"))
gomega.Expect(runOutput).To(gomega.ContainSubstring("stdin closed"))
gomega.Expect(c.CoreV1().Pods(ns).Delete(ctx, "run-test", metav1.DeleteOptions{})).To(gomega.BeNil())
framework.ExpectNoError(c.CoreV1().Pods(ns).Delete(ctx, "run-test", metav1.DeleteOptions{}))
ginkgo.By("executing a command with run and attach without stdin")
// There is a race on this scenario described in #73099
@@ -784,7 +784,7 @@ metadata:
gomega.Expect(runOutput).ToNot(gomega.ContainSubstring("abcd1234"))
gomega.Expect(runOutput).To(gomega.ContainSubstring("stdin closed"))
gomega.Expect(c.CoreV1().Pods(ns).Delete(ctx, "run-test-2", metav1.DeleteOptions{})).To(gomega.BeNil())
framework.ExpectNoError(c.CoreV1().Pods(ns).Delete(ctx, "run-test-2", metav1.DeleteOptions{}))
ginkgo.By("executing a command with run and attach with stdin with open stdin should remain running")
e2ekubectl.NewKubectlCommand(ns, "run", "run-test-3", "--image="+busyboxImage, "--restart=OnFailure", podRunningTimeoutArg, "--attach=true", "--leave-stdin-open=true", "--stdin", "--", "sh", "-c", "cat && echo 'stdin closed'").
@@ -800,7 +800,7 @@ metadata:
framework.ExpectNoError(err)
framework.ExpectNoError(e2epod.WaitTimeoutForPodReadyInNamespace(ctx, c, runTestPod.Name, ns, time.Minute))
gomega.Expect(c.CoreV1().Pods(ns).Delete(ctx, "run-test-3", metav1.DeleteOptions{})).To(gomega.BeNil())
framework.ExpectNoError(c.CoreV1().Pods(ns).Delete(ctx, "run-test-3", metav1.DeleteOptions{}))
})
ginkgo.It("should contain last line of the log", func(ctx context.Context) {

View File

@@ -125,7 +125,7 @@ var _ = SIGDescribe("Kubectl logs", func() {
ginkgo.By("limiting log lines")
out := e2ekubectl.RunKubectlOrDie(ns, "logs", podName, containerName, "--tail=1")
framework.Logf("got output %q", out)
gomega.Expect(len(out)).NotTo(gomega.BeZero())
gomega.Expect(out).NotTo(gomega.BeEmpty())
framework.ExpectEqual(len(lines(out)), 1)
ginkgo.By("limiting log bytes")
@@ -191,13 +191,13 @@ var _ = SIGDescribe("Kubectl logs", func() {
ginkgo.By("specified container log lines")
out := e2ekubectl.RunKubectlOrDie(ns, "logs", podName, "-c", "container-1")
framework.Logf("got output %q", out)
gomega.Expect(len(out)).NotTo(gomega.BeZero())
gomega.Expect(out).NotTo(gomega.BeEmpty())
framework.ExpectEqual(len(lines(out)), 10)
ginkgo.By("log all containers log lines")
out = e2ekubectl.RunKubectlOrDie(ns, "logs", podName, "--all-containers")
framework.Logf("got output %q", out)
gomega.Expect(len(out)).NotTo(gomega.BeZero())
gomega.Expect(out).NotTo(gomega.BeEmpty())
framework.ExpectEqual(len(lines(out)), 30)
ginkgo.By("default container logs")