mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-22 18:16:52 +00:00
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.
This commit is contained in:
parent
6b6336e5c0
commit
34206a610a
@ -21,7 +21,6 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -356,7 +355,6 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
|
|||||||
ginkgo.Context("CSI volume limit information using mock driver", func() {
|
ginkgo.Context("CSI volume limit information using mock driver", func() {
|
||||||
ginkgo.It("should report attach limit when limit is bigger than 0 [Slow]", func() {
|
ginkgo.It("should report attach limit when limit is bigger than 0 [Slow]", func() {
|
||||||
// define volume limit to be 2 for this test
|
// define volume limit to be 2 for this test
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
init(testParameters{attachLimit: 2})
|
init(testParameters{attachLimit: 2})
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
@ -563,19 +561,15 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
func waitForMaxVolumeCondition(pod *v1.Pod, cs clientset.Interface) error {
|
func waitForMaxVolumeCondition(pod *v1.Pod, cs clientset.Interface) error {
|
||||||
reg, err := regexp.Compile(`max.+volume.+count`)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
waitErr := wait.PollImmediate(10*time.Second, csiPodUnschedulableTimeout, func() (bool, error) {
|
waitErr := wait.PollImmediate(10*time.Second, csiPodUnschedulableTimeout, func() (bool, error) {
|
||||||
pod, err = cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
|
pod, err := cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
conditions := pod.Status.Conditions
|
for _, c := range pod.Status.Conditions {
|
||||||
for _, condition := range conditions {
|
// Conformance tests cannot rely on specific output of optional fields (e.g., Reason
|
||||||
matched := reg.MatchString(condition.Message)
|
// and Message) because these fields are not suject to the deprecation policy.
|
||||||
if condition.Reason == v1.PodReasonUnschedulable && matched {
|
if c.Type == v1.PodScheduled && c.Status == v1.ConditionFalse && c.Reason != "" && c.Message != "" {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user