diff --git a/test/e2e/framework/pods.go b/test/e2e/framework/pods.go index 2c39288e595..b3d6887d750 100644 --- a/test/e2e/framework/pods.go +++ b/test/e2e/framework/pods.go @@ -83,8 +83,9 @@ func (c *PodClient) Create(pod *v1.Pod) *v1.Pod { return p } -// CreateSyncInNamespace creates a new pod according to the framework specifications in the given namespace, and waits for it to start. -func (c *PodClient) CreateSyncInNamespace(pod *v1.Pod, namespace string) *v1.Pod { +// CreateSync creates a new pod according to the framework specifications, and wait for it to start. +func (c *PodClient) CreateSync(pod *v1.Pod) *v1.Pod { + namespace := c.f.Namespace.Name p := c.Create(pod) ExpectNoError(e2epod.WaitForPodNameRunningInNamespace(c.f.ClientSet, p.Name, namespace)) // Get the newest pod after it becomes running, some status may change after pod created, such as pod ip. @@ -93,11 +94,6 @@ func (c *PodClient) CreateSyncInNamespace(pod *v1.Pod, namespace string) *v1.Pod return p } -// CreateSync creates a new pod according to the framework specifications, and wait for it to start. -func (c *PodClient) CreateSync(pod *v1.Pod) *v1.Pod { - return c.CreateSyncInNamespace(pod, c.f.Namespace.Name) -} - // CreateBatch create a batch of pods. All pods are created before waiting. func (c *PodClient) CreateBatch(pods []*v1.Pod) []*v1.Pod { ps := make([]*v1.Pod, len(pods)) @@ -140,12 +136,7 @@ func (c *PodClient) Update(name string, updateFn func(pod *v1.Pod)) { // DeleteSync deletes the pod and wait for the pod to disappear for `timeout`. If the pod doesn't // disappear before the timeout, it will fail the test. func (c *PodClient) DeleteSync(name string, options *metav1.DeleteOptions, timeout time.Duration) { - c.DeleteSyncInNamespace(name, c.f.Namespace.Name, options, timeout) -} - -// DeleteSyncInNamespace deletes the pod from the namespace and wait for the pod to disappear for `timeout`. If the pod doesn't -// disappear before the timeout, it will fail the test. -func (c *PodClient) DeleteSyncInNamespace(name string, namespace string, options *metav1.DeleteOptions, timeout time.Duration) { + namespace := c.f.Namespace.Name err := c.Delete(name, options) if err != nil && !apierrors.IsNotFound(err) { Failf("Failed to delete pod %q: %v", name, err) diff --git a/test/e2e_node/critical_pod_test.go b/test/e2e_node/critical_pod_test.go index 3eeafab38d4..218504264ca 100644 --- a/test/e2e_node/critical_pod_test.go +++ b/test/e2e_node/critical_pod_test.go @@ -89,7 +89,7 @@ var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:C // Create pods, starting with non-critical so that the critical preempts the other pods. f.PodClient().CreateBatch([]*v1.Pod{nonCriticalBestEffort, nonCriticalBurstable, nonCriticalGuaranteed}) - f.PodClientNS(kubeapi.NamespaceSystem).CreateSyncInNamespace(criticalPod, kubeapi.NamespaceSystem) + f.PodClientNS(kubeapi.NamespaceSystem).CreateSync(criticalPod) // Check that non-critical pods other than the besteffort have been evicted updatedPodList, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).List(metav1.ListOptions{}) @@ -107,7 +107,7 @@ var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:C f.PodClient().DeleteSync(guaranteedPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) f.PodClient().DeleteSync(burstablePodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) f.PodClient().DeleteSync(bestEffortPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) - f.PodClientNS(kubeapi.NamespaceSystem).DeleteSyncInNamespace(criticalPodName, kubeapi.NamespaceSystem, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) + f.PodClientNS(kubeapi.NamespaceSystem).DeleteSync(criticalPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) err := f.ClientSet.SchedulingV1().PriorityClasses().Delete(systemCriticalPriorityName, &metav1.DeleteOptions{}) framework.ExpectNoError(err) // Log Events