From a56745c7066a289496f2eaf86461086646d3effe Mon Sep 17 00:00:00 2001 From: wlq1212 Date: Thu, 31 Aug 2023 10:05:55 +0800 Subject: [PATCH] e2e_cloud:stop using deprecated framework.ExpectError --- test/e2e/cloud/gcp/addon_update.go | 2 +- test/e2e/common/node/configmap.go | 2 +- test/e2e/common/node/pods.go | 2 +- test/e2e/common/node/privileged.go | 3 ++- test/e2e/common/node/runtimeclass.go | 2 +- test/e2e/common/node/secrets.go | 2 +- test/e2e/framework/volume/fixtures.go | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/e2e/cloud/gcp/addon_update.go b/test/e2e/cloud/gcp/addon_update.go index ee8d844ac47..6d6a51770e2 100644 --- a/test/e2e/cloud/gcp/addon_update.go +++ b/test/e2e/cloud/gcp/addon_update.go @@ -340,7 +340,7 @@ var _ = SIGDescribe("Addon update", func() { ginkgo.By("verify invalid addons weren't created") _, err = f.ClientSet.CoreV1().ReplicationControllers(addonNsName).Get(ctx, "invalid-addon-test", metav1.GetOptions{}) - framework.ExpectError(err) + gomega.Expect(err).To(gomega.HaveOccurred()) // Invalid addon manifests and the "ensure exist class" addon will be deleted by the deferred function. }) diff --git a/test/e2e/common/node/configmap.go b/test/e2e/common/node/configmap.go index 49f74fdfa46..893ac3a0971 100644 --- a/test/e2e/common/node/configmap.go +++ b/test/e2e/common/node/configmap.go @@ -138,7 +138,7 @@ var _ = SIGDescribe("ConfigMap", func() { */ framework.ConformanceIt("should fail to create ConfigMap with empty key", func(ctx context.Context) { configMap, err := newConfigMapWithEmptyKey(ctx, f) - framework.ExpectError(err, "created configMap %q with empty key in namespace %q", configMap.Name, f.Namespace.Name) + gomega.Expect(err).To(gomega.HaveOccurred(), "created configMap %q with empty key in namespace %q", configMap.Name, f.Namespace.Name) }) ginkgo.It("should update ConfigMap successfully", func(ctx context.Context) { diff --git a/test/e2e/common/node/pods.go b/test/e2e/common/node/pods.go index be7b602ac93..f0620832a22 100644 --- a/test/e2e/common/node/pods.go +++ b/test/e2e/common/node/pods.go @@ -1067,7 +1067,7 @@ var _ = SIGDescribe("Pods", func() { if postDeletePod != nil { postDeletePodJSON, _ = json.Marshal(postDeletePod) } - framework.ExpectError(err, "pod %v found in namespace %v, but it should be deleted: %s", testPodName, testNamespaceName, string(postDeletePodJSON)) + gomega.Expect(err).To(gomega.HaveOccurred(), "pod %v found in namespace %v, but it should be deleted: %s", testPodName, testNamespaceName, string(postDeletePodJSON)) if !apierrors.IsNotFound(err) { framework.Failf("expected IsNotFound error, got %#v", err) } diff --git a/test/e2e/common/node/privileged.go b/test/e2e/common/node/privileged.go index 2e979f1c69c..0769047acd9 100644 --- a/test/e2e/common/node/privileged.go +++ b/test/e2e/common/node/privileged.go @@ -21,6 +21,7 @@ import ( "fmt" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/test/e2e/framework" @@ -81,7 +82,7 @@ func (c *PrivilegedPodTestConfig) run(containerName string, expectSuccess bool) framework.ExpectNoError(err, fmt.Sprintf("could not remove dummy1 link: %v", err)) } else { - framework.ExpectError(err, msg) + gomega.Expect(err).To(gomega.HaveOccurred(), msg) } } diff --git a/test/e2e/common/node/runtimeclass.go b/test/e2e/common/node/runtimeclass.go index 267e050835b..3f167faeab9 100644 --- a/test/e2e/common/node/runtimeclass.go +++ b/test/e2e/common/node/runtimeclass.go @@ -376,7 +376,7 @@ func createRuntimeClass(ctx context.Context, f *framework.Framework, name, handl func expectPodRejection(ctx context.Context, f *framework.Framework, pod *v1.Pod) { _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, pod, metav1.CreateOptions{}) - framework.ExpectError(err, "should be forbidden") + gomega.Expect(err).To(gomega.HaveOccurred(), "should be forbidden") if !apierrors.IsForbidden(err) { framework.Failf("expected forbidden error, got %#v", err) } diff --git a/test/e2e/common/node/secrets.go b/test/e2e/common/node/secrets.go index 095fe625506..7bb2bfdc681 100644 --- a/test/e2e/common/node/secrets.go +++ b/test/e2e/common/node/secrets.go @@ -140,7 +140,7 @@ var _ = SIGDescribe("Secrets", func() { */ framework.ConformanceIt("should fail to create secret due to empty secret key", func(ctx context.Context) { secret, err := createEmptyKeySecretForTest(ctx, f) - framework.ExpectError(err, "created secret %q with empty key in namespace %q", secret.Name, f.Namespace.Name) + gomega.Expect(err).To(gomega.HaveOccurred(), "created secret %q with empty key in namespace %q", secret.Name, f.Namespace.Name) }) /* diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index c84d9222d15..c0953c7f819 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -706,5 +706,5 @@ func VerifyExecInPodFail(f *framework.Framework, pod *v1.Pod, shExec string, exi shExec, exitCode, err, stdout, stderr) } } - framework.ExpectError(err, "%q should fail with exit code %d, but exit without error", shExec, exitCode) + gomega.Expect(err).To(gomega.HaveOccurred(), "%q should fail with exit code %d, but exit without error", shExec, exitCode) }