Skip to content

Commit

Permalink
fix tunnel integration tests for driver None (#4105)
Browse files Browse the repository at this point in the history
* added more wait to the integration tests for the tunnel
  • Loading branch information
balopat committed Apr 25, 2019
1 parent 6de90ae commit 3ebb16c
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions test/integration/tunnel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"testing"
"time"

"k8s.io/apimachinery/pkg/util/wait"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/minikube/pkg/minikube/tunnel"
Expand Down Expand Up @@ -76,26 +78,42 @@ func testTunnel(t *testing.T) {
t.Fatal(errors.Wrap(err, "waiting for nginx pods"))
}

if err := commonutil.WaitForService(client, "default", "nginx-svc", true, time.Millisecond*500, time.Minute*10); err != nil {
if err := commonutil.WaitForService(client, "default", "nginx-svc", true, 1*time.Second, 2*time.Minute); err != nil {
t.Fatal(errors.Wrap(err, "Error waiting for nginx service to be up"))
}

t.Log("getting nginx ingress...")

nginxIP := ""

for i := 1; i < 3 && len(nginxIP) == 0; i++ {
stdout, err := kubectlRunner.RunCommand([]string{"get", "svc", "nginx-svc", "-o", "jsonpath={.status.loadBalancer.ingress[0].ip}"})

if err != nil {
t.Fatalf("error listing nginx service: %s", err)
err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
cmd := []string{"get", "svc", "nginx-svc", "-o", "jsonpath={.status.loadBalancer.ingress[0].ip}"}
stdout, err := kubectlRunner.RunCommand(cmd)
switch {
case err == nil:
nginxIP = string(stdout)
return len(stdout) != 0, nil
case !commonutil.IsRetryableAPIError(err):
t.Errorf("`%s` failed with non retriable error: %v", cmd, err)
return false, err
default:
t.Errorf("`%s` failed: %v", cmd, err)
return false, nil
}
nginxIP = string(stdout)
time.Sleep(1 * time.Second)
})

if err != nil {
t.Errorf("error getting ingress IP for nginx: %s", err)
}

if len(nginxIP) == 0 {
t.Fatal("svc should have ingress after tunnel is created, but it was empty!")
stdout, err := kubectlRunner.RunCommand([]string{"get", "svc", "nginx-svc", "-o", "jsonpath={.status}"})

if err != nil {
t.Errorf("error debugging nginx service: %s", err)
}

t.Fatalf("svc should have ingress after tunnel is created, but it was empty! Result of `kubectl describe svc nginx-svc`:\n %s", string(stdout))
}

responseBody, err := getResponseBody(nginxIP)
Expand Down

0 comments on commit 3ebb16c

Please sign in to comment.