Skip to content

Commit 97af926

Browse files
committed
fixed review feedbacks on clusterstate field and tests
Signed-off-by: Tharun <[email protected]>
1 parent c9d449f commit 97af926

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Diff for: cmd/minikube/cmd/status.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ type ClusterState struct {
143143
BaseState
144144

145145
BinaryVersion string
146+
TimeToStop string
146147
Components map[string]BaseState
147148
Nodes []NodeState
148149
}
@@ -485,10 +486,6 @@ func clusterState(sts []*Status) ClusterState {
485486
}
486487
sc := statusCode(statusName)
487488

488-
timeToStopStatusCode := Configured
489-
if sts[0].TimeToStop == Nonexistent {
490-
timeToStopStatusCode = Nonexistent
491-
}
492489
cs := ClusterState{
493490
BinaryVersion: version.GetVersion(),
494491

@@ -499,9 +496,10 @@ func clusterState(sts []*Status) ClusterState {
499496
StatusDetail: codeDetails[sc],
500497
},
501498

499+
TimeToStop: sts[0].TimeToStop,
500+
502501
Components: map[string]BaseState{
503502
"kubeconfig": {Name: "kubeconfig", StatusCode: statusCode(sts[0].Kubeconfig)},
504-
"timetostop": {Name: "timetostop", StatusCode: statusCode(timeToStopStatusCode)},
505503
},
506504
}
507505

Diff for: test/integration/scheduled_stop_test.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ func TestScheduledStopWindows(t *testing.T) {
5151

5252
// schedule a stop for 5m from now
5353
scheduledStopMinikube(ctx, t, profile, "5m")
54-
54+
// sleep for 1 second
55+
time.Sleep(time.Second)
56+
// make sure timeToStop is present in status
57+
checkTimetoStop(ctx, t, profile, "4m")
5558
// make sure the systemd service is running
5659
rr, err := Run(t, exec.CommandContext(ctx, Target(), []string{"ssh", "-p", profile, "--", "sudo", "systemctl", "show", constants.ScheduledStopSystemdService, "--no-page"}...))
5760
if err != nil {
@@ -84,6 +87,10 @@ func TestScheduledStopUnix(t *testing.T) {
8487

8588
// schedule a stop for 5 min from now and make sure PID is created
8689
scheduledStopMinikube(ctx, t, profile, "5m")
90+
// sleep for 1 second
91+
time.Sleep(time.Second)
92+
// make sure timeToStop is present in status
93+
checkTimetoStop(ctx, t, profile, "4m")
8794
pid := checkPID(t, profile)
8895
if !processRunning(t, pid) {
8996
t.Fatalf("process %v is not running", pid)
@@ -164,3 +171,10 @@ func ensureMinikubeStatusStopped(ctx context.Context, t *testing.T, profile stri
164171
t.Fatalf("error %v", err)
165172
}
166173
}
174+
175+
func checkTimetoStop(ctx context.Context, t *testing.T, profile string, currentTimeToStop string) {
176+
got := Status(ctx, t, Target(), profile, "TimeToStop", profile)
177+
if !strings.Contains(got, currentTimeToStop) {
178+
t.Fatalf("expected timetostop status to be -%q- but got *%q*", currentTimeToStop, got)
179+
}
180+
}

0 commit comments

Comments
 (0)