feat: use framework.ExpectEqual in storage e2e test

This commit is contained in:
draveness 2019-07-04 09:19:54 +08:00
parent a33840e023
commit 4c2e77a53e
16 changed files with 56 additions and 63 deletions

View File

@ -463,7 +463,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
framework.ExpectNoError(err, "while waiting for PVC resize to finish") framework.ExpectNoError(err, "while waiting for PVC resize to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
} }
// if node expansion is not required PVC should be resized as well // if node expansion is not required PVC should be resized as well
@ -476,7 +476,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
inProgressConditions := pvc.Status.Conditions inProgressConditions := pvc.Status.Conditions
if len(inProgressConditions) > 0 { if len(inProgressConditions) > 0 {
gomega.Expect(inProgressConditions[0].Type).To(gomega.Equal(v1.PersistentVolumeClaimFileSystemResizePending), "pvc must have fs resizing condition") framework.ExpectEqual(inProgressConditions[0].Type, v1.PersistentVolumeClaimFileSystemResizePending, "pvc must have fs resizing condition")
} }
ginkgo.By("Deleting the previously created pod") ginkgo.By("Deleting the previously created pod")
@ -548,7 +548,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
framework.ExpectNoError(err, "while waiting for PVC to finish") framework.ExpectNoError(err, "while waiting for PVC to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
}) })
} }

View File

@ -243,7 +243,7 @@ func (d *driverDefinition) GetDynamicProvisionStorageClass(config *testsuites.Pe
items, err := f.LoadFromManifests(d.StorageClass.FromFile) items, err := f.LoadFromManifests(d.StorageClass.FromFile)
framework.ExpectNoError(err, "load storage class from %s", d.StorageClass.FromFile) framework.ExpectNoError(err, "load storage class from %s", d.StorageClass.FromFile)
gomega.Expect(len(items)).To(gomega.Equal(1), "exactly one item from %s", d.StorageClass.FromFile) framework.ExpectEqual(len(items), 1, "exactly one item from %s", d.StorageClass.FromFile)
err = f.PatchItems(items...) err = f.PatchItems(items...)
framework.ExpectNoError(err, "patch items") framework.ExpectNoError(err, "patch items")

View File

@ -142,7 +142,7 @@ var _ = utils.SIGDescribe("Mounted flexvolume expand[Slow]", func() {
pvs, err = framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err = framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
ginkgo.By("Creating a deployment with the provisioned volume") ginkgo.By("Creating a deployment with the provisioned volume")
deployment, err := e2edeploy.CreateDeployment(c, int32(1), map[string]string{"test": "app"}, nodeKeyValueLabel, ns, pvcClaims, "") deployment, err := e2edeploy.CreateDeployment(c, int32(1), map[string]string{"test": "app"}, nodeKeyValueLabel, ns, pvcClaims, "")
@ -182,6 +182,6 @@ var _ = utils.SIGDescribe("Mounted flexvolume expand[Slow]", func() {
framework.ExpectNoError(err, "while waiting for fs resize to finish") framework.ExpectNoError(err, "while waiting for fs resize to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
}) })
}) })

View File

@ -141,7 +141,7 @@ var _ = utils.SIGDescribe("Mounted flexvolume volume expand [Slow] [Feature:Expa
pvs, err = framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err = framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
var pod *v1.Pod var pod *v1.Pod
ginkgo.By("Creating pod") ginkgo.By("Creating pod")
@ -173,6 +173,6 @@ var _ = utils.SIGDescribe("Mounted flexvolume volume expand [Slow] [Feature:Expa
framework.ExpectNoError(err, "while waiting for fs resize to finish") framework.ExpectNoError(err, "while waiting for fs resize to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
}) })
}) })

View File

@ -18,7 +18,6 @@ package storage
import ( import (
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
"github.com/onsi/gomega"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
@ -97,7 +96,7 @@ func createPodPVCFromSC(f *framework.Framework, c clientset.Interface, ns string
pvcClaims := []*v1.PersistentVolumeClaim{pvc} pvcClaims := []*v1.PersistentVolumeClaim{pvc}
pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
ginkgo.By("Creating a pod with dynamically provisioned volume") ginkgo.By("Creating a pod with dynamically provisioned volume")
pod, err := framework.CreateNginxPod(c, ns, nil, pvcClaims) pod, err := framework.CreateNginxPod(c, ns, nil, pvcClaims)

View File

@ -124,7 +124,7 @@ var _ = utils.SIGDescribe("Mounted volume expand", func() {
ginkgo.By("Checking for bound PVC") ginkgo.By("Checking for bound PVC")
pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
ginkgo.By("Expanding current pvc") ginkgo.By("Expanding current pvc")
newSize := resource.MustParse("6Gi") newSize := resource.MustParse("6Gi")
@ -159,7 +159,7 @@ var _ = utils.SIGDescribe("Mounted volume expand", func() {
framework.ExpectNoError(err, "while waiting for fs resize to finish") framework.ExpectNoError(err, "while waiting for fs resize to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
}) })
}) })

View File

@ -397,7 +397,7 @@ var _ = utils.SIGDescribe("Pod Disks", func() {
framework.ExpectNoError(err, fmt.Sprintf("Failed to delete host0Pod: err=%v", err)) framework.ExpectNoError(err, fmt.Sprintf("Failed to delete host0Pod: err=%v", err))
ginkgo.By("expecting host0 node to be re-created") ginkgo.By("expecting host0 node to be re-created")
numNodes := countReadyNodes(cs, host0Name) numNodes := countReadyNodes(cs, host0Name)
gomega.Expect(numNodes).To(gomega.Equal(origNodeCnt), fmt.Sprintf("Requires current node count (%d) to return to original node count (%d)", numNodes, origNodeCnt)) framework.ExpectEqual(numNodes, origNodeCnt, fmt.Sprintf("Requires current node count (%d) to return to original node count (%d)", numNodes, origNodeCnt))
output, err = gceCloud.ListInstanceNames(framework.TestContext.CloudConfig.ProjectID, framework.TestContext.CloudConfig.Zone) output, err = gceCloud.ListInstanceNames(framework.TestContext.CloudConfig.ProjectID, framework.TestContext.CloudConfig.Zone)
framework.ExpectNoError(err, fmt.Sprintf("Unable to get list of node instances err=%v output=%s", err, output)) framework.ExpectNoError(err, fmt.Sprintf("Unable to get list of node instances err=%v output=%s", err, output))
gomega.Expect(false, strings.Contains(string(output), string(host0Name))) gomega.Expect(false, strings.Contains(string(output), string(host0Name)))
@ -470,7 +470,7 @@ func verifyPDContentsViaContainer(f *framework.Framework, podName, containerName
break break
} }
} }
gomega.Expect(strings.TrimSpace(value)).To(gomega.Equal(strings.TrimSpace(expectedContents))) framework.ExpectEqual(strings.TrimSpace(value), strings.TrimSpace(expectedContents))
} }
} }

View File

@ -849,7 +849,7 @@ func verifyLocalPod(config *localTestConfig, volume *localTestVolume, pod *v1.Po
podNodeName, err := podNodeName(config, pod) podNodeName, err := podNodeName(config, pod)
framework.ExpectNoError(err) framework.ExpectNoError(err)
e2elog.Logf("pod %q created on Node %q", pod.Name, podNodeName) e2elog.Logf("pod %q created on Node %q", pod.Name, podNodeName)
gomega.Expect(podNodeName).To(gomega.Equal(expectedNodeName)) framework.ExpectEqual(podNodeName, expectedNodeName)
} }
func makeLocalPVCConfig(config *localTestConfig, volumeType localVolumeType) framework.PersistentVolumeClaimConfig { func makeLocalPVCConfig(config *localTestConfig, volumeType localVolumeType) framework.PersistentVolumeClaimConfig {
@ -930,7 +930,7 @@ func createLocalPVCsPVs(config *localTestConfig, volumes []*localTestVolume, mod
for _, volume := range volumes { for _, volume := range volumes {
pvc, err := config.client.CoreV1().PersistentVolumeClaims(volume.pvc.Namespace).Get(volume.pvc.Name, metav1.GetOptions{}) pvc, err := config.client.CoreV1().PersistentVolumeClaims(volume.pvc.Namespace).Get(volume.pvc.Name, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Expect(pvc.Status.Phase).To(gomega.Equal(v1.ClaimPending)) framework.ExpectEqual(pvc.Status.Phase, v1.ClaimPending)
} }
return false, nil return false, nil
}) })
@ -1165,10 +1165,10 @@ func validateStatefulSet(config *localTestConfig, ss *appsv1.StatefulSet, anti b
if anti { if anti {
// Verify that each pod is on a different node // Verify that each pod is on a different node
gomega.Expect(nodes.Len()).To(gomega.Equal(len(pods.Items))) framework.ExpectEqual(nodes.Len(), len(pods.Items))
} else { } else {
// Verify that all pods are on same node. // Verify that all pods are on same node.
gomega.Expect(nodes.Len()).To(gomega.Equal(1)) framework.ExpectEqual(nodes.Len(), 1)
} }
// Validate all PVCs are bound // Validate all PVCs are bound

View File

@ -269,8 +269,7 @@ func testZonalFailover(c clientset.Interface, ns string) {
} }
ginkgo.By("verifying the same PVC is used by the new pod") ginkgo.By("verifying the same PVC is used by the new pod")
gomega.Expect(getPVC(c, ns, regionalPDLabels).Name).To(gomega.Equal(pvc.Name), framework.ExpectEqual(getPVC(c, ns, regionalPDLabels).Name, pvc.Name, "The same PVC should be used after failover.")
"The same PVC should be used after failover.")
ginkgo.By("verifying the container output has 2 lines, indicating the pod has been created twice using the same regional PD.") ginkgo.By("verifying the container output has 2 lines, indicating the pod has been created twice using the same regional PD.")
logs, err := e2epod.GetPodLogs(c, ns, pod.Name, "") logs, err := e2epod.GetPodLogs(c, ns, pod.Name, "")
@ -278,8 +277,7 @@ func testZonalFailover(c clientset.Interface, ns string) {
"Error getting logs from pod %s in namespace %s", pod.Name, ns) "Error getting logs from pod %s in namespace %s", pod.Name, ns)
lineCount := len(strings.Split(strings.TrimSpace(logs), "\n")) lineCount := len(strings.Split(strings.TrimSpace(logs), "\n"))
expectedLineCount := 2 expectedLineCount := 2
gomega.Expect(lineCount).To(gomega.Equal(expectedLineCount), framework.ExpectEqual(lineCount, expectedLineCount, "Line count of the written file should be %d.", expectedLineCount)
"Line count of the written file should be %d.", expectedLineCount)
} }
@ -426,7 +424,7 @@ func getPVC(c clientset.Interface, ns string, pvcLabels map[string]string) *v1.P
options := metav1.ListOptions{LabelSelector: selector.String()} options := metav1.ListOptions{LabelSelector: selector.String()}
pvcList, err := c.CoreV1().PersistentVolumeClaims(ns).List(options) pvcList, err := c.CoreV1().PersistentVolumeClaims(ns).List(options)
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Expect(len(pvcList.Items)).To(gomega.Equal(1), "There should be exactly 1 PVC matched.") framework.ExpectEqual(len(pvcList.Items), 1, "There should be exactly 1 PVC matched.")
return &pvcList.Items[0] return &pvcList.Items[0]
} }
@ -436,7 +434,7 @@ func getPod(c clientset.Interface, ns string, podLabels map[string]string) *v1.P
options := metav1.ListOptions{LabelSelector: selector.String()} options := metav1.ListOptions{LabelSelector: selector.String()}
podList, err := c.CoreV1().Pods(ns).List(options) podList, err := c.CoreV1().Pods(ns).List(options)
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Expect(len(podList.Items)).To(gomega.Equal(1), "There should be exactly 1 pod matched.") framework.ExpectEqual(len(podList.Items), 1, "There should be exactly 1 pod matched.")
return &podList.Items[0] return &podList.Items[0]
} }

View File

@ -237,12 +237,12 @@ func (t StorageClassTest) TestDynamicProvisioning() *v1.PersistentVolume {
var err error var err error
if class != nil { if class != nil {
gomega.Expect(*claim.Spec.StorageClassName).To(gomega.Equal(class.Name)) framework.ExpectEqual(*claim.Spec.StorageClassName, class.Name)
ginkgo.By("creating a StorageClass " + class.Name) ginkgo.By("creating a StorageClass " + class.Name)
_, err = client.StorageV1().StorageClasses().Create(class) _, err = client.StorageV1().StorageClasses().Create(class)
// The "should provision storage with snapshot data source" test already has created the class. // The "should provision storage with snapshot data source" test already has created the class.
// TODO: make class creation optional and remove the IsAlreadyExists exception // TODO: make class creation optional and remove the IsAlreadyExists exception
gomega.Expect(err == nil || apierrs.IsAlreadyExists(err)).To(gomega.Equal(true)) framework.ExpectEqual(err == nil || apierrs.IsAlreadyExists(err), true)
class, err = client.StorageV1().StorageClasses().Get(class.Name, metav1.GetOptions{}) class, err = client.StorageV1().StorageClasses().Get(class.Name, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
defer func() { defer func() {
@ -300,11 +300,11 @@ func (t StorageClassTest) checkProvisioning(client clientset.Interface, claim *v
// Check sizes // Check sizes
expectedCapacity := resource.MustParse(t.ExpectedSize) expectedCapacity := resource.MustParse(t.ExpectedSize)
pvCapacity := pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)] pvCapacity := pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)]
gomega.Expect(pvCapacity.Value()).To(gomega.Equal(expectedCapacity.Value()), "pvCapacity is not equal to expectedCapacity") framework.ExpectEqual(pvCapacity.Value(), expectedCapacity.Value(), "pvCapacity is not equal to expectedCapacity")
requestedCapacity := resource.MustParse(t.ClaimSize) requestedCapacity := resource.MustParse(t.ClaimSize)
claimCapacity := claim.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)] claimCapacity := claim.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
gomega.Expect(claimCapacity.Value()).To(gomega.Equal(requestedCapacity.Value()), "claimCapacity is not equal to requestedCapacity") framework.ExpectEqual(claimCapacity.Value(), requestedCapacity.Value(), "claimCapacity is not equal to requestedCapacity")
// Check PV properties // Check PV properties
ginkgo.By("checking the PV") ginkgo.By("checking the PV")
@ -322,17 +322,17 @@ func (t StorageClassTest) checkProvisioning(client clientset.Interface, claim *v
gomega.Expect(found).To(gomega.BeTrue()) gomega.Expect(found).To(gomega.BeTrue())
} }
gomega.Expect(pv.Spec.ClaimRef.Name).To(gomega.Equal(claim.ObjectMeta.Name)) framework.ExpectEqual(pv.Spec.ClaimRef.Name, claim.ObjectMeta.Name)
gomega.Expect(pv.Spec.ClaimRef.Namespace).To(gomega.Equal(claim.ObjectMeta.Namespace)) framework.ExpectEqual(pv.Spec.ClaimRef.Namespace, claim.ObjectMeta.Namespace)
if class == nil { if class == nil {
gomega.Expect(pv.Spec.PersistentVolumeReclaimPolicy).To(gomega.Equal(v1.PersistentVolumeReclaimDelete)) framework.ExpectEqual(pv.Spec.PersistentVolumeReclaimPolicy, v1.PersistentVolumeReclaimDelete)
} else { } else {
gomega.Expect(pv.Spec.PersistentVolumeReclaimPolicy).To(gomega.Equal(*class.ReclaimPolicy)) framework.ExpectEqual(pv.Spec.PersistentVolumeReclaimPolicy, *class.ReclaimPolicy)
gomega.Expect(pv.Spec.MountOptions).To(gomega.Equal(class.MountOptions)) framework.ExpectEqual(pv.Spec.MountOptions, class.MountOptions)
} }
if claim.Spec.VolumeMode != nil { if claim.Spec.VolumeMode != nil {
gomega.Expect(pv.Spec.VolumeMode).NotTo(gomega.BeNil()) gomega.Expect(pv.Spec.VolumeMode).NotTo(gomega.BeNil())
gomega.Expect(*pv.Spec.VolumeMode).To(gomega.Equal(*claim.Spec.VolumeMode)) framework.ExpectEqual(*pv.Spec.VolumeMode, *claim.Spec.VolumeMode)
} }
return pv return pv
} }
@ -404,7 +404,7 @@ func PVWriteReadSingleNodeCheck(client clientset.Interface, claim *v1.Persistent
// //
// This is a common test that can be called from a StorageClassTest.PvCheck. // This is a common test that can be called from a StorageClassTest.PvCheck.
func PVMultiNodeCheck(client clientset.Interface, claim *v1.PersistentVolumeClaim, node framework.NodeSelection) { func PVMultiNodeCheck(client clientset.Interface, claim *v1.PersistentVolumeClaim, node framework.NodeSelection) {
gomega.Expect(node.Name).To(gomega.Equal(""), "this test only works when not locked onto a single node") framework.ExpectEqual(node.Name, "", "this test only works when not locked onto a single node")
var pod *v1.Pod var pod *v1.Pod
defer func() { defer func() {
@ -526,7 +526,7 @@ func (t StorageClassTest) TestBindingWaitForFirstConsumerMultiPVC(claims []*v1.P
framework.ExpectNoError(err) framework.ExpectNoError(err)
pvs = append(pvs, pv) pvs = append(pvs, pv)
} }
gomega.Expect(len(pvs)).To(gomega.Equal(len(createdClaims))) framework.ExpectEqual(len(pvs), len(createdClaims))
return pvs, node return pvs, node
} }
@ -608,7 +608,7 @@ func verifyPVCsPending(client clientset.Interface, pvcs []*v1.PersistentVolumeCl
// Get new copy of the claim // Get new copy of the claim
claim, err := client.CoreV1().PersistentVolumeClaims(claim.Namespace).Get(claim.Name, metav1.GetOptions{}) claim, err := client.CoreV1().PersistentVolumeClaims(claim.Namespace).Get(claim.Name, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Expect(claim.Status.Phase).To(gomega.Equal(v1.ClaimPending)) framework.ExpectEqual(claim.Status.Phase, v1.ClaimPending)
} }
} }

View File

@ -21,7 +21,6 @@ import (
"time" "time"
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
"github.com/onsi/gomega"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors" apierrs "k8s.io/apimachinery/pkg/api/errors"
@ -75,7 +74,7 @@ func (s *snapshottableTestSuite) defineTests(driver TestDriver, pattern testpatt
ginkgo.BeforeEach(func() { ginkgo.BeforeEach(func() {
// Check preconditions. // Check preconditions.
gomega.Expect(pattern.SnapshotType).To(gomega.Equal(testpatterns.DynamicCreatedSnapshot)) framework.ExpectEqual(pattern.SnapshotType, testpatterns.DynamicCreatedSnapshot)
dInfo := driver.GetDriverInfo() dInfo := driver.GetDriverInfo()
ok := false ok := false
sDriver, ok = driver.(SnapshottableTestDriver) sDriver, ok = driver.(SnapshottableTestDriver)
@ -185,10 +184,10 @@ func (s *snapshottableTestSuite) defineTests(driver TestDriver, pattern testpatt
// Check SnapshotContent properties // Check SnapshotContent properties
ginkgo.By("checking the SnapshotContent") ginkgo.By("checking the SnapshotContent")
gomega.Expect(snapshotContentSpec["snapshotClassName"]).To(gomega.Equal(vsc.GetName())) framework.ExpectEqual(snapshotContentSpec["snapshotClassName"], vsc.GetName())
gomega.Expect(volumeSnapshotRef["name"]).To(gomega.Equal(snapshot.GetName())) framework.ExpectEqual(volumeSnapshotRef["name"], snapshot.GetName())
gomega.Expect(volumeSnapshotRef["namespace"]).To(gomega.Equal(snapshot.GetNamespace())) framework.ExpectEqual(volumeSnapshotRef["namespace"], snapshot.GetNamespace())
gomega.Expect(persistentVolumeRef["name"]).To(gomega.Equal(pv.Name)) framework.ExpectEqual(persistentVolumeRef["name"], pv.Name)
}) })
} }

View File

@ -90,7 +90,7 @@ func VerifyExecInPodFail(pod *v1.Pod, bashExec string, exitCode int) {
if err != nil { if err != nil {
if err, ok := err.(uexec.CodeExitError); ok { if err, ok := err.(uexec.CodeExitError); ok {
actualExitCode := err.ExitStatus() actualExitCode := err.ExitStatus()
gomega.Expect(actualExitCode).To(gomega.Equal(exitCode), framework.ExpectEqual(actualExitCode, exitCode,
"%q should fail with exit code %d, but failed with exit code %d and error message %q", "%q should fail with exit code %d, but failed with exit code %d and error message %q",
bashExec, exitCode, actualExitCode, err) bashExec, exitCode, actualExitCode, err)
} else { } else {

View File

@ -96,7 +96,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
pvcClaims := []*v1.PersistentVolumeClaim{pvc} pvcClaims := []*v1.PersistentVolumeClaim{pvc}
pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
ginkgo.By("Expanding non-expandable pvc") ginkgo.By("Expanding non-expandable pvc")
newSize := resource.MustParse("6Gi") newSize := resource.MustParse("6Gi")
@ -112,7 +112,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
pvcClaims := []*v1.PersistentVolumeClaim{pvc} pvcClaims := []*v1.PersistentVolumeClaim{pvc}
pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
ginkgo.By("Creating a pod with dynamically provisioned volume") ginkgo.By("Creating a pod with dynamically provisioned volume")
pod, err := framework.CreatePod(c, ns, nil, pvcClaims, false, "") pod, err := framework.CreatePod(c, ns, nil, pvcClaims, false, "")
@ -147,8 +147,8 @@ var _ = utils.SIGDescribe("Volume expand", func() {
framework.ExpectNoError(err, "While fetching pvc after controller resize") framework.ExpectNoError(err, "While fetching pvc after controller resize")
inProgressConditions := pvc.Status.Conditions inProgressConditions := pvc.Status.Conditions
gomega.Expect(len(inProgressConditions)).To(gomega.Equal(1), "pvc must have file system resize pending condition") framework.ExpectEqual(len(inProgressConditions), 1, "pvc must have file system resize pending condition")
gomega.Expect(inProgressConditions[0].Type).To(gomega.Equal(v1.PersistentVolumeClaimFileSystemResizePending), "pvc must have fs resizing condition") framework.ExpectEqual(inProgressConditions[0].Type, v1.PersistentVolumeClaimFileSystemResizePending, "pvc must have fs resizing condition")
ginkgo.By("Creating a new pod with same volume") ginkgo.By("Creating a new pod with same volume")
pod2, err := framework.CreatePod(c, ns, nil, pvcClaims, false, "") pod2, err := framework.CreatePod(c, ns, nil, pvcClaims, false, "")
@ -163,7 +163,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
framework.ExpectNoError(err, "while waiting for fs resize to finish") framework.ExpectNoError(err, "while waiting for fs resize to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
}) })
ginkgo.It("should resize volume when PVC is edited while pod is using it", func() { ginkgo.It("should resize volume when PVC is edited while pod is using it", func() {
@ -174,7 +174,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
pvcClaims := []*v1.PersistentVolumeClaim{pvc} pvcClaims := []*v1.PersistentVolumeClaim{pvc}
pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
ginkgo.By("Creating a pod with dynamically provisioned volume") ginkgo.By("Creating a pod with dynamically provisioned volume")
pod, err := framework.CreatePod(c, ns, nil, pvcClaims, false, "") pod, err := framework.CreatePod(c, ns, nil, pvcClaims, false, "")
@ -205,7 +205,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
framework.ExpectNoError(err, "while waiting for fs resize to finish") framework.ExpectNoError(err, "while waiting for fs resize to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
}) })
ginkgo.It("should allow expansion of block volumes", func() { ginkgo.It("should allow expansion of block volumes", func() {
@ -215,7 +215,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
pvcClaims := []*v1.PersistentVolumeClaim{pvc} pvcClaims := []*v1.PersistentVolumeClaim{pvc}
pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout) pvs, err := framework.WaitForPVClaimBoundPhase(c, pvcClaims, framework.ClaimProvisionTimeout)
framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err) framework.ExpectNoError(err, "Failed waiting for PVC to be bound %v", err)
gomega.Expect(len(pvs)).To(gomega.Equal(1)) framework.ExpectEqual(len(pvs), 1)
ginkgo.By("Expanding current pvc") ginkgo.By("Expanding current pvc")
newSize := resource.MustParse("6Gi") newSize := resource.MustParse("6Gi")
@ -237,7 +237,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
framework.ExpectNoError(err, "while waiting for fs resize to finish") framework.ExpectNoError(err, "while waiting for fs resize to finish")
pvcConditions := pvc.Status.Conditions pvcConditions := pvc.Status.Conditions
gomega.Expect(len(pvcConditions)).To(gomega.Equal(0), "pvc should not have conditions") framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
}) })
}) })

View File

@ -415,8 +415,7 @@ var _ = utils.SIGDescribe("[Serial] Volume metrics", func() {
// should be 4, and the elements should be bound pv count, unbound pv count, bound // should be 4, and the elements should be bound pv count, unbound pv count, bound
// pvc count, unbound pvc count in turn. // pvc count, unbound pvc count in turn.
validator := func(metricValues []map[string]int64) { validator := func(metricValues []map[string]int64) {
gomega.Expect(len(metricValues)).To(gomega.Equal(4), framework.ExpectEqual(len(metricValues), 4, "Wrong metric size: %d", len(metricValues))
"Wrong metric size: %d", len(metricValues))
controllerMetrics, err := metricsGrabber.GrabFromControllerManager() controllerMetrics, err := metricsGrabber.GrabFromControllerManager()
framework.ExpectNoError(err, "Error getting c-m metricValues: %v", err) framework.ExpectNoError(err, "Error getting c-m metricValues: %v", err)
@ -431,8 +430,7 @@ var _ = utils.SIGDescribe("[Serial] Volume metrics", func() {
// test suit are equal to expectValues. // test suit are equal to expectValues.
actualValues := calculateRelativeValues(originMetricValues[i], actualValues := calculateRelativeValues(originMetricValues[i],
getPVControllerMetrics(controllerMetrics, metric.name, metric.dimension)) getPVControllerMetrics(controllerMetrics, metric.name, metric.dimension))
gomega.Expect(actualValues).To(gomega.Equal(expectValues), framework.ExpectEqual(actualValues, expectValues, "Wrong pv controller metric %s(%s): wanted %v, got %v",
"Wrong pv controller metric %s(%s): wanted %v, got %v",
metric.name, metric.dimension, expectValues, actualValues) metric.name, metric.dimension, expectValues, actualValues)
} }
} }
@ -660,7 +658,7 @@ func findVolumeStatMetric(metricKeyName string, namespace string, pvcName string
} }
} }
} }
gomega.Expect(errCount).To(gomega.Equal(0), "Found invalid samples") framework.ExpectEqual(errCount, 0, "Found invalid samples")
return found return found
} }

View File

@ -804,7 +804,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
e2elog.Logf(err.Error()) e2elog.Logf(err.Error())
claim, err = c.CoreV1().PersistentVolumeClaims(ns).Get(claim.Name, metav1.GetOptions{}) claim, err = c.CoreV1().PersistentVolumeClaims(ns).Get(claim.Name, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Expect(claim.Status.Phase).To(gomega.Equal(v1.ClaimPending)) framework.ExpectEqual(claim.Status.Phase, v1.ClaimPending)
}) })
// Modifying the default storage class can be disruptive to other tests that depend on it // Modifying the default storage class can be disruptive to other tests that depend on it
@ -838,7 +838,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
e2elog.Logf(err.Error()) e2elog.Logf(err.Error())
claim, err = c.CoreV1().PersistentVolumeClaims(ns).Get(claim.Name, metav1.GetOptions{}) claim, err = c.CoreV1().PersistentVolumeClaims(ns).Get(claim.Name, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Expect(claim.Status.Phase).To(gomega.Equal(v1.ClaimPending)) framework.ExpectEqual(claim.Status.Phase, v1.ClaimPending)
}) })
}) })
@ -985,7 +985,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
func verifyDefaultStorageClass(c clientset.Interface, scName string, expectedDefault bool) { func verifyDefaultStorageClass(c clientset.Interface, scName string, expectedDefault bool) {
sc, err := c.StorageV1().StorageClasses().Get(scName, metav1.GetOptions{}) sc, err := c.StorageV1().StorageClasses().Get(scName, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Expect(storageutil.IsDefaultAnnotation(sc.ObjectMeta)).To(gomega.Equal(expectedDefault)) framework.ExpectEqual(storageutil.IsDefaultAnnotation(sc.ObjectMeta), expectedDefault)
} }
func updateDefaultStorageClass(c clientset.Interface, scName string, defaultStr string) { func updateDefaultStorageClass(c clientset.Interface, scName string, defaultStr string) {

View File

@ -20,7 +20,6 @@ import (
"time" "time"
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
"github.com/onsi/gomega"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -91,6 +90,6 @@ var _ = utils.SIGDescribe("Volume Disk Size [Feature:vsphere]", func() {
ginkgo.By("Verifying if provisioned PV has the correct size") ginkgo.By("Verifying if provisioned PV has the correct size")
expectedCapacity := resource.MustParse(expectedDiskSize) expectedCapacity := resource.MustParse(expectedDiskSize)
pvCapacity := pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)] pvCapacity := pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)]
gomega.Expect(pvCapacity.Value()).To(gomega.Equal(expectedCapacity.Value())) framework.ExpectEqual(pvCapacity.Value(), expectedCapacity.Value())
}) })
}) })