Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ExpectEqual() to e2e framework #78922

Merged
merged 1 commit into from Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions test/e2e/apimachinery/generated_clientset.go
Expand Up @@ -32,7 +32,6 @@ import (
"k8s.io/kubernetes/test/e2e/framework"

"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
imageutils "k8s.io/kubernetes/test/utils/image"
)

Expand Down Expand Up @@ -115,7 +114,7 @@ var _ = SIGDescribe("Generated clientset", func() {
if err != nil {
framework.Failf("Failed to query for pods: %v", err)
}
gomega.Expect(len(pods.Items)).To(gomega.Equal(0))
framework.ExpectEqual(len(pods.Items), 0)
options = metav1.ListOptions{
LabelSelector: selector,
ResourceVersion: pods.ListMeta.ResourceVersion,
Expand All @@ -140,7 +139,7 @@ var _ = SIGDescribe("Generated clientset", func() {
if err != nil {
framework.Failf("Failed to query for pods: %v", err)
}
gomega.Expect(len(pods.Items)).To(gomega.Equal(1))
framework.ExpectEqual(len(pods.Items), 1)

ginkgo.By("verifying pod creation was observed")
observeCreation(w)
Expand Down Expand Up @@ -231,7 +230,7 @@ var _ = SIGDescribe("Generated clientset", func() {
if err != nil {
framework.Failf("Failed to query for cronJobs: %v", err)
}
gomega.Expect(len(cronJobs.Items)).To(gomega.Equal(0))
framework.ExpectEqual(len(cronJobs.Items), 0)
options = metav1.ListOptions{
LabelSelector: selector,
ResourceVersion: cronJobs.ListMeta.ResourceVersion,
Expand All @@ -256,7 +255,7 @@ var _ = SIGDescribe("Generated clientset", func() {
if err != nil {
framework.Failf("Failed to query for cronJobs: %v", err)
}
gomega.Expect(len(cronJobs.Items)).To(gomega.Equal(1))
framework.ExpectEqual(len(cronJobs.Items), 1)

ginkgo.By("verifying cronJob creation was observed")
observeCreation(w)
Expand All @@ -273,6 +272,6 @@ var _ = SIGDescribe("Generated clientset", func() {
if err != nil {
framework.Failf("Failed to list cronJobs to verify deletion: %v", err)
}
gomega.Expect(len(cronJobs.Items)).To(gomega.Equal(0))
framework.ExpectEqual(len(cronJobs.Items), 0)
})
})
7 changes: 6 additions & 1 deletion test/e2e/framework/util.go
Expand Up @@ -1368,6 +1368,11 @@ func RandomSuffix() string {
return strconv.Itoa(r.Int() % 10000)
}

// ExpectEqual expects the specified two are the same, otherwise an exception raises
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{}) {
gomega.Expect(actual).To(gomega.Equal(extra), explain...)
}

// ExpectError expects an error happens, otherwise an exception raises
func ExpectError(err error, explain ...interface{}) {
gomega.Expect(err).To(gomega.HaveOccurred(), explain...)
Expand Down Expand Up @@ -2092,7 +2097,7 @@ func ExpectNodeHasLabel(c clientset.Interface, nodeName string, labelKey string,
ginkgo.By("verifying the node has the label " + labelKey + " " + labelValue)
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
ExpectNoError(err)
gomega.Expect(node.Labels[labelKey]).To(gomega.Equal(labelValue))
ExpectEqual(node.Labels[labelKey], labelValue)
}

// RemoveTaintOffNode removes the given taint from the given node.
Expand Down