From ff6668433147a67335c4c83e3d017e502ce64e72 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 10 Jun 2021 11:32:13 +0200 Subject: [PATCH] test: Ginkgo and Gomega update The new Gomega version supports testing a function with no return value (https://github.com/onsi/gomega/issues/198#issuecomment-858240599). This makes it possible to simplify the metrics test. --- go.mod | 2 +- go.sum | 2 ++ test/e2e/metrics/metrics.go | 11 +---------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index d26d3e15f..db0de5f73 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/kubernetes-csi/csi-test/v4 v4.2.0 github.com/miekg/dns v1.1.38 // indirect github.com/onsi/ginkgo v1.16.4 - github.com/onsi/gomega v1.13.0 + github.com/onsi/gomega v1.13.1-0.20210610024953-2f04e6e3467d github.com/operator-framework/operator-lib v0.4.0 github.com/prometheus/client_golang v1.11.0 github.com/prometheus/client_model v0.2.0 diff --git a/go.sum b/go.sum index f7d564b1e..bd9b0d22e 100644 --- a/go.sum +++ b/go.sum @@ -522,6 +522,8 @@ github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.10.4/go.mod h1:g/HbgYopi++010VEqkFgJHKC09uJiW9UkXvMUuKHUCQ= github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= +github.com/onsi/gomega v1.13.1-0.20210610024953-2f04e6e3467d h1:xP4paM8h3wbI0mhcjOZeeRNI2HzqxIgKSMJv+brTHaE= +github.com/onsi/gomega v1.13.1-0.20210610024953-2f04e6e3467d/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= diff --git a/test/e2e/metrics/metrics.go b/test/e2e/metrics/metrics.go index b1282f7ea..fae4a596c 100644 --- a/test/e2e/metrics/metrics.go +++ b/test/e2e/metrics/metrics.go @@ -78,13 +78,6 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d * pod.Namespace, pod.Name, port.ContainerPort) resp, err := client.Get(url) framework.ExpectNoError(err, "GET failed") - // When wrapped with InterceptGomegaFailures, err == nil doesn't - // cause the function to abort. We have to do that ourselves before - // using resp to avoid a panic. - // https://github.com/onsi/gomega/issues/198#issuecomment-856630787 - if err != nil { - return - } data, err := ioutil.ReadAll(resp.Body) framework.ExpectNoError(err, "read GET response") name := pod.Name + "/" + container.Name @@ -109,9 +102,7 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d * } Expect(numPods).NotTo(Equal(0), "at least one container should have a 'metrics' port") } - Eventually(func() string { - return strings.Join(InterceptGomegaFailures(test), "\n") - }, "10s", "1s").Should(BeEmpty()) + Eventually(test, "10s", "1s").Should(Succeed()) }) It("rejects large headers", func() {