e2e_cloud:stop using deprecated framework.ExpectError

This commit is contained in:
wlq1212 2023-08-31 10:05:55 +08:00 committed by liqing.wu
parent 7bde29372a
commit a56745c706
7 changed files with 8 additions and 7 deletions

View File

@ -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.
})

View File

@ -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) {

View File

@ -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)
}

View File

@ -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)
}
}

View File

@ -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)
}

View File

@ -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)
})
/*

View File

@ -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)
}