diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index 558c882c17..116903ee06 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -24,6 +24,7 @@ import ( "testing" "time" + commonutil "k8s.io/minikube/pkg/util" "k8s.io/minikube/test/integration/util" ) @@ -45,12 +46,14 @@ func TestStartStop(t *testing.T) { t.Fatalf("IP command returned an invalid address: %s", ip) } - // TODO:r2d4 The KVM driver can't handle - // starting and stopping immediately - time.Sleep(30 * time.Second) + checkStop := func() error { + runner.RunCommand("stop", true) + return runner.CheckStatusNoFail("Stopped") + } - runner.RunCommand("stop", true) - runner.CheckStatus("Stopped") + if err := commonutil.RetryAfter(6, checkStop, 5*time.Second); err != nil { + t.Fatalf("timed out while checking stopped status: %s", err) + } runner.Start() runner.CheckStatus("Running") diff --git a/test/integration/util/util.go b/test/integration/util/util.go index c2945cbf5e..ee444d0cfd 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -111,10 +111,17 @@ func (m *MinikubeRunner) GetStatus() string { } func (m *MinikubeRunner) CheckStatus(desired string) { + if err := m.CheckStatusNoFail(desired); err != nil { + m.T.Fatalf("%v", err) + } +} + +func (m *MinikubeRunner) CheckStatusNoFail(desired string) error { s := m.GetStatus() if s != desired { - m.T.Fatalf("Machine is in the wrong state: %s, expected %s", s, desired) + return fmt.Errorf("Machine is in the wrong state: %s, expected %s", s, desired) } + return nil } type KubectlRunner struct {