Skip to content

Commit

Permalink
fixed review feedbacks on clusterstate field and tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tharun <rajendrantharun@live.com>
  • Loading branch information
tharun208 committed Dec 5, 2020
1 parent c9d449f commit 97af926
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 3 additions & 5 deletions cmd/minikube/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type ClusterState struct {
BaseState

BinaryVersion string
TimeToStop string
Components map[string]BaseState
Nodes []NodeState
}
Expand Down Expand Up @@ -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(),

Expand All @@ -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)},
},
}

Expand Down
16 changes: 15 additions & 1 deletion test/integration/scheduled_stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 97af926

Please sign in to comment.