Skip to content

Commit 34206a6

Browse files
committed
Don't rely on contents of optional Condition fields in CSI mock test
In order to promote the volume limits e2e test (from CSI Mock driver) to Conformance, we can't rely on specific output of optional Condition fields. Thus, this commit changes the test to only check the presence of the right condition and verify that the optional fields are not empty.
1 parent 6b6336e commit 34206a6

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

test/e2e/storage/csi_mock_volume.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"crypto/sha256"
2222
"encoding/json"
2323
"fmt"
24-
"regexp"
2524
"strconv"
2625
"strings"
2726
"time"
@@ -356,7 +355,6 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
356355
ginkgo.Context("CSI volume limit information using mock driver", func() {
357356
ginkgo.It("should report attach limit when limit is bigger than 0 [Slow]", func() {
358357
// define volume limit to be 2 for this test
359-
360358
var err error
361359
init(testParameters{attachLimit: 2})
362360
defer cleanup()
@@ -563,19 +561,15 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
563561
})
564562

565563
func waitForMaxVolumeCondition(pod *v1.Pod, cs clientset.Interface) error {
566-
reg, err := regexp.Compile(`max.+volume.+count`)
567-
if err != nil {
568-
return err
569-
}
570564
waitErr := wait.PollImmediate(10*time.Second, csiPodUnschedulableTimeout, func() (bool, error) {
571-
pod, err = cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
565+
pod, err := cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
572566
if err != nil {
573567
return false, err
574568
}
575-
conditions := pod.Status.Conditions
576-
for _, condition := range conditions {
577-
matched := reg.MatchString(condition.Message)
578-
if condition.Reason == v1.PodReasonUnschedulable && matched {
569+
for _, c := range pod.Status.Conditions {
570+
// Conformance tests cannot rely on specific output of optional fields (e.g., Reason
571+
// and Message) because these fields are not suject to the deprecation policy.
572+
if c.Type == v1.PodScheduled && c.Status == v1.ConditionFalse && c.Reason != "" && c.Message != "" {
579573
return true, nil
580574
}
581575
}

0 commit comments

Comments
 (0)