Updating e2e test to check EndpointSlices and Endpoints as well
This commit is contained in:
@@ -135,15 +135,17 @@ func DeepHashObjectToString(objectToWrite interface{}) string {
|
||||
return hex.EncodeToString(hasher.Sum(nil)[0:])
|
||||
}
|
||||
|
||||
// ShouldPodBeInEndpointSlice returns true if a specified pod should be in an Endpoint or EndpointSlice object.
|
||||
// Terminating pods are only included if includeTerminating is true
|
||||
func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool {
|
||||
// ShouldPodBeInEndpoints returns true if a specified pod should be in an
|
||||
// Endpoints or EndpointSlice resource. Terminating pods are only included if
|
||||
// includeTerminating is true.
|
||||
func ShouldPodBeInEndpoints(pod *v1.Pod, includeTerminating bool) bool {
|
||||
// "Terminal" describes when a Pod is complete (in a succeeded or failed phase).
|
||||
// This is distinct from the "Terminating" condition which represents when a Pod
|
||||
// is being terminated (metadata.deletionTimestamp is non nil).
|
||||
if podutil.IsPodTerminal(pod) {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(pod.Status.PodIP) == 0 && len(pod.Status.PodIPs) == 0 {
|
||||
return false
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ func TestDetermineNeededServiceUpdates(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldPodBeInEndpointSlice(t *testing.T) {
|
||||
func TestShouldPodBeInEndpoints(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
pod *v1.Pod
|
||||
@@ -263,7 +263,7 @@ func TestShouldPodBeInEndpointSlice(t *testing.T) {
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
result := ShouldPodBeInEndpointSlice(test.pod, test.includeTerminating)
|
||||
result := ShouldPodBeInEndpoints(test.pod, test.includeTerminating)
|
||||
if result != test.expected {
|
||||
t.Errorf("expected: %t, got: %t", test.expected, result)
|
||||
}
|
||||
|
Reference in New Issue
Block a user