Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TestWaitForPodSucceeded flake #3818

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/skaffold/kubernetes/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package kubernetes

import (
"context"
"errors"
"fmt"
"time"

Expand All @@ -43,7 +42,7 @@ func watchUntilTimeout(ctx context.Context, timeout time.Duration, w watch.Inter
for {
select {
case <-ctx.Done():
return errors.New("context closed while waiting for condition")
return ctx.Err()
case event := <-w.ResultChan():
done, err := condition(&event)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/skaffold/kubernetes/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ func TestWaitForPodSucceeded(t *testing.T) {
tests := []struct {
description string
phases []v1.PodPhase
timeout time.Duration
shouldErr bool
}{
{
description: "pod eventually succeeds",
timeout: 1 * time.Second,
phases: []v1.PodPhase{v1.PodRunning, v1.PodSucceeded},
}, {
description: "pod eventually fails",
timeout: 1 * time.Second,
phases: []v1.PodPhase{v1.PodRunning, v1.PodFailed},
shouldErr: true,
}, {
description: "pod times out",
timeout: 10 * time.Millisecond,
phases: []v1.PodPhase{v1.PodRunning, v1.PodRunning, v1.PodRunning, v1.PodRunning, v1.PodRunning, v1.PodRunning},
shouldErr: true,
},
Expand All @@ -59,7 +63,7 @@ func TestWaitForPodSucceeded(t *testing.T) {

errChan := make(chan error)
go func() {
errChan <- WaitForPodSucceeded(context.TODO(), fakePods, "", 10*time.Millisecond)
errChan <- WaitForPodSucceeded(context.TODO(), fakePods, "", test.timeout)
}()

for _, phase := range test.phases {
Expand Down