提交 17666c2f 编写于 作者: P Priya Wadhwa

Combine pause status test into existing pause test

上级 a03b01fa
......@@ -24,6 +24,8 @@ import (
"os/exec"
"strings"
"testing"
"k8s.io/minikube/cmd/minikube/cmd"
)
func TestPause(t *testing.T) {
......@@ -43,6 +45,7 @@ func TestPause(t *testing.T) {
{"Start", validateFreshStart},
{"SecondStartNoReconfiguration", validateStartNoReconfigure},
{"Pause", validatePause},
{"VerifyStatus", validateStatus},
{"Unpause", validateUnpause},
{"PauseAgain", validatePause},
{"DeletePaused", validateDelete},
......@@ -166,3 +169,20 @@ func validateVerifyDeleted(ctx context.Context, t *testing.T, profile string) {
}
}
func validateStatus(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
statusOutput := runStatusCmd(ctx, t, profile, false)
var cs cmd.ClusterState
if err := json.Unmarshal(statusOutput, &cs); err != nil {
t.Fatalf("unmarshalling: %v", err)
}
// verify the status looks as we expect
if cs.StatusCode != cmd.Paused {
t.Fatalf("incorrect status code: %v", cs.StatusCode)
}
if cs.StatusName != "Paused" {
t.Fatalf("incorrect status name: %v", cs.StatusName)
}
}
......@@ -98,41 +98,3 @@ func verifyClusterState(t *testing.T, contents []byte) {
}
}
}
func TestPauseStatus(t *testing.T) {
// run start
profile := UniqueProfileName("pause-status")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(5))
defer Cleanup(t, profile, cancel)
startArgs := []string{"start", "-p", profile, "--output=json", "--wait=true"}
startArgs = append(startArgs, StartArgs()...)
c := exec.CommandContext(ctx, Target(), startArgs...)
rr, err := Run(t, c)
if err != nil {
t.Fatalf("minikube start failed %v\n%v", rr.Command(), err)
}
// run pause
pauseArgs := []string{"pause", "-p", profile}
c = exec.CommandContext(ctx, Target(), pauseArgs...)
rr, err = Run(t, c)
if err != nil {
t.Fatalf("minikube pause failed %v\n%v", rr.Command(), err)
}
// run status
statusOutput := runStatusCmd(context.Background(), t, profile, false)
var cs cmd.ClusterState
if err := json.Unmarshal(statusOutput, &cs); err != nil {
t.Fatalf("unmarshalling: %v", err)
}
// verify the status looks as we expect
if cs.StatusCode != cmd.Paused {
t.Fatalf("incorrect status code: %v", cs.StatusCode)
}
if cs.StatusName != "Paused" {
t.Fatalf("incorrect status name: %v", cs.StatusName)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册