From 97af926f7894571c2c1c30940369d46842cfdf06 Mon Sep 17 00:00:00 2001 From: Tharun Date: Sat, 5 Dec 2020 14:23:34 +0530 Subject: [PATCH] fixed review feedbacks on clusterstate field and tests Signed-off-by: Tharun --- cmd/minikube/cmd/status.go | 8 +++----- test/integration/scheduled_stop_test.go | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index 2ce2f2064a71..bfcde0880bb4 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -143,6 +143,7 @@ type ClusterState struct { BaseState BinaryVersion string + TimeToStop string Components map[string]BaseState Nodes []NodeState } @@ -485,10 +486,6 @@ func clusterState(sts []*Status) ClusterState { } sc := statusCode(statusName) - timeToStopStatusCode := Configured - if sts[0].TimeToStop == Nonexistent { - timeToStopStatusCode = Nonexistent - } cs := ClusterState{ BinaryVersion: version.GetVersion(), @@ -499,9 +496,10 @@ func clusterState(sts []*Status) ClusterState { StatusDetail: codeDetails[sc], }, + TimeToStop: sts[0].TimeToStop, + Components: map[string]BaseState{ "kubeconfig": {Name: "kubeconfig", StatusCode: statusCode(sts[0].Kubeconfig)}, - "timetostop": {Name: "timetostop", StatusCode: statusCode(timeToStopStatusCode)}, }, } diff --git a/test/integration/scheduled_stop_test.go b/test/integration/scheduled_stop_test.go index 6c74ea787372..cfd284e35bf8 100644 --- a/test/integration/scheduled_stop_test.go +++ b/test/integration/scheduled_stop_test.go @@ -51,7 +51,10 @@ func TestScheduledStopWindows(t *testing.T) { // schedule a stop for 5m from now scheduledStopMinikube(ctx, t, profile, "5m") - + // sleep for 1 second + time.Sleep(time.Second) + // make sure timeToStop is present in status + checkTimetoStop(ctx, t, profile, "4m") // make sure the systemd service is running rr, err := Run(t, exec.CommandContext(ctx, Target(), []string{"ssh", "-p", profile, "--", "sudo", "systemctl", "show", constants.ScheduledStopSystemdService, "--no-page"}...)) if err != nil { @@ -84,6 +87,10 @@ func TestScheduledStopUnix(t *testing.T) { // schedule a stop for 5 min from now and make sure PID is created scheduledStopMinikube(ctx, t, profile, "5m") + // sleep for 1 second + time.Sleep(time.Second) + // make sure timeToStop is present in status + checkTimetoStop(ctx, t, profile, "4m") pid := checkPID(t, profile) if !processRunning(t, pid) { t.Fatalf("process %v is not running", pid) @@ -164,3 +171,10 @@ func ensureMinikubeStatusStopped(ctx context.Context, t *testing.T, profile stri t.Fatalf("error %v", err) } } + +func checkTimetoStop(ctx context.Context, t *testing.T, profile string, currentTimeToStop string) { + got := Status(ctx, t, Target(), profile, "TimeToStop", profile) + if !strings.Contains(got, currentTimeToStop) { + t.Fatalf("expected timetostop status to be -%q- but got *%q*", currentTimeToStop, got) + } +}