Skip to content

Commit 5d28e86

Browse files
authored
Merge pull request kubernetes#130097 from bitoku/podrejectionstatus
Modify how to check the status in PodRejectionStatus test
2 parents c5b83f7 + 9539541 commit 5d28e86

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

test/e2e/node/pod_admission.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/onsi/ginkgo/v2"
2323
"github.com/onsi/gomega"
24+
"github.com/onsi/gomega/gstruct"
2425
v1 "k8s.io/api/core/v1"
2526
"k8s.io/apimachinery/pkg/api/resource"
2627
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -97,14 +98,24 @@ var _ = SIGDescribe("PodRejectionStatus", func() {
9798

9899
// This detects if there are any new fields in Status that were dropped by the pod rejection.
99100
// These new fields either should be kept by kubelet's admission or added explicitly in the list of fields that are having a different value or must be cleared.
100-
expectedStatus := pod.Status.DeepCopy()
101-
expectedStatus.Phase = gotPod.Status.Phase
102-
expectedStatus.Conditions = nil
103-
expectedStatus.Message = gotPod.Status.Message
104-
expectedStatus.Reason = gotPod.Status.Reason
105-
expectedStatus.StartTime = gotPod.Status.StartTime
106-
// expectedStatus.QOSClass keep it as is
107-
gomega.Expect(gotPod.Status).To(gomega.Equal(*expectedStatus))
101+
gomega.Expect(gotPod.Status).To(gstruct.MatchAllFields(gstruct.Fields{
102+
"Phase": gstruct.Ignore(),
103+
"Conditions": gstruct.Ignore(),
104+
"Message": gstruct.Ignore(),
105+
"Reason": gstruct.Ignore(),
106+
"NominatedNodeName": gstruct.Ignore(),
107+
"HostIP": gstruct.Ignore(),
108+
"HostIPs": gstruct.Ignore(),
109+
"PodIP": gstruct.Ignore(),
110+
"PodIPs": gstruct.Ignore(),
111+
"StartTime": gstruct.Ignore(),
112+
"InitContainerStatuses": gstruct.Ignore(),
113+
"ContainerStatuses": gstruct.Ignore(),
114+
"QOSClass": gomega.Equal(pod.Status.QOSClass), // QOSClass should be kept
115+
"EphemeralContainerStatuses": gstruct.Ignore(),
116+
"Resize": gstruct.Ignore(),
117+
"ResourceClaimStatuses": gstruct.Ignore(),
118+
}))
108119
})
109120
})
110121
})

0 commit comments

Comments
 (0)