mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
test/integration/endpoints: check for pod existencen in TestEndpointWithTerminatingPod
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
parent
e0a22acaa0
commit
9fa641b9ad
@ -18,10 +18,13 @@ package endpoints
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@ -291,6 +294,20 @@ func TestEndpointWithTerminatingPod(t *testing.T) {
|
|||||||
|
|
||||||
// poll until endpoint for deleted Pod is no longer in Endpoints.
|
// poll until endpoint for deleted Pod is no longer in Endpoints.
|
||||||
if err := wait.PollImmediate(1*time.Second, 10*time.Second, func() (bool, error) {
|
if err := wait.PollImmediate(1*time.Second, 10*time.Second, func() (bool, error) {
|
||||||
|
// Ensure that the recently deleted Pod exists but with a deletion timestamp. If the Pod does not exist,
|
||||||
|
// we should fail the test since it is no longer validating against a terminating pod.
|
||||||
|
pod, err := client.CoreV1().Pods(ns.Name).Get(context.TODO(), pod.Name, metav1.GetOptions{})
|
||||||
|
if apierrors.IsNotFound(err) {
|
||||||
|
return false, fmt.Errorf("expected Pod %q to exist with deletion timestamp but was not found: %v", pod.Name, err)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if pod.DeletionTimestamp == nil {
|
||||||
|
return false, errors.New("pod did not have deletion timestamp set")
|
||||||
|
}
|
||||||
|
|
||||||
endpoints, err := client.CoreV1().Endpoints(ns.Name).Get(context.TODO(), svc.Name, metav1.GetOptions{})
|
endpoints, err := client.CoreV1().Endpoints(ns.Name).Get(context.TODO(), svc.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user