Skip to content

Commit 770d5ce

Browse files
authored
test fix post-mortem not showing (#21328)
1 parent 772a9ee commit 770d5ce

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/integration/helpers_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,23 @@ func VolumeSnapshotWait(ctx context.Context, t *testing.T, profile string, ns st
435435
}
436436

437437
// Status returns a minikube component status as a string
438+
// If the command outputs multiple lines, only the first line is returned to avoid https://github.com/kubernetes/minikube/issues/21326
438439
func Status(ctx context.Context, t *testing.T, path string, profile string, key string, node string) string {
439440
t.Helper()
440441
// Reminder of useful keys: "Host", "Kubelet", "APIServer"
441442
rr, err := Run(t, exec.CommandContext(ctx, path, "status", fmt.Sprintf("--format={{.%s}}", key), "-p", profile, "-n", node))
442443
if err != nil {
443444
t.Logf("status error: %v (may be ok)", err)
444445
}
445-
return strings.TrimSpace(rr.Stdout.String())
446+
out := strings.TrimSpace(rr.Stdout.String())
447+
if out == "" {
448+
return out
449+
}
450+
// Take only the first line if multi-line (ignore warnings or extra notes)
451+
if idx := strings.IndexByte(out, '\n'); idx >= 0 {
452+
out = out[:idx]
453+
}
454+
return strings.TrimSpace(out)
446455
}
447456

448457
// showPodLogs logs debug info for pods

0 commit comments

Comments
 (0)