test: check stopped status repeatedly
In TestStartStop(), check for stopped status once in 5 seconds, up to 30 seconds, instead of always sleeping for 30 seconds before stopping it. That way we can reduce duration of the test. To do that, we need to split out MinikubeRunner.CheckStatus() into CheckStatusNoFail() that doesn't lead to T.Fatalf(). Other call sites of CheckStatus() would not be then affected.pull/1115/head
parent
f52805360d
commit
c58e5dd10f
|
@ -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")
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue