use PollUntilContextTimeout to replace PollImmediateWithContext in test

Signed-off-by: bzsuni <bingzhe.sun@daocloud.io>
This commit is contained in:
bzsuni
2023-10-19 22:50:21 +08:00
parent de054fbf94
commit 8775d805fa
55 changed files with 140 additions and 140 deletions

View File

@@ -552,7 +552,7 @@ func createBatchPodSequential(ctx context.Context, f *framework.Framework, pods
create := metav1.Now()
createTimes[pod.Name] = create
p := e2epod.NewPodClient(f).Create(ctx, pod)
framework.ExpectNoError(wait.PollImmediateWithContext(ctx, 2*time.Second, framework.PodStartTimeout, podWatchedRunning(watchTimes, p.Name)))
framework.ExpectNoError(wait.PollUntilContextTimeout(ctx, 2*time.Second, framework.PodStartTimeout, true, podWatchedRunning(watchTimes, p.Name)))
e2eLags = append(e2eLags,
e2emetrics.PodLatencyData{Name: pod.Name, Latency: watchTimes[pod.Name].Time.Sub(create.Time)})
}

View File

@@ -162,7 +162,7 @@ func pollConfigz(ctx context.Context, timeout time.Duration, pollInterval time.D
req.Header.Add("Accept", "application/json")
var respBody []byte
err = wait.PollImmediateWithContext(ctx, pollInterval, timeout, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(ctx, pollInterval, timeout, true, func(ctx context.Context) (bool, error) {
resp, err := client.Do(req)
if err != nil {
framework.Logf("Failed to get /configz, retrying. Error: %v", err)

View File

@@ -435,7 +435,7 @@ func checkMirrorPodRunning(ctx context.Context, cl clientset.Interface, name, na
func checkMirrorPodRunningWithRestartCount(ctx context.Context, interval time.Duration, timeout time.Duration, cl clientset.Interface, name, namespace string, count int32) error {
var pod *v1.Pod
var err error
err = wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) {
pod, err = cl.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return false, fmt.Errorf("expected the mirror pod %q to appear: %w", name, err)