Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch logs output to speedup minikube logs command #11274

Merged
merged 6 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/minikube/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
failed = append(failed, name)
continue
}
l := ""
scanner := bufio.NewScanner(&b)
for scanner.Scan() {
out.Styled(style.Empty, scanner.Text())
l += scanner.Text() + "\n"
}
out.Styled(style.Empty, l)
}

if len(failed) > 0 {
Expand Down Expand Up @@ -223,10 +225,12 @@ func outputLastStart() error {
return fmt.Errorf("failed to open file %s: %v", fp, err)
}
defer f.Close()
l := ""
s := bufio.NewScanner(f)
for s.Scan() {
out.Styled(style.Empty, s.Text())
l += s.Text() + "\n"
}
out.Styled(style.Empty, l)
if err := s.Err(); err != nil {
return fmt.Errorf("failed to read file %s: %v", fp, err)
}
Expand Down
12 changes: 12 additions & 0 deletions test/integration/aaa_download_only_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ func TestDownloadOnly(t *testing.T) {
}
})

t.Run("minikube logs", func(t *testing.T) {
spowelljr marked this conversation as resolved.
Show resolved Hide resolved
ctx, cancel := context.WithTimeout(context.Background(), Seconds(5))
defer cancel()
args := []string{"logs", "-p", profile}
if _, err := Run(t, exec.CommandContext(ctx, Target(), args...)); err != nil {
t.Errorf("minikube logs failed with error: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can ignore minikube logs error here...just care about the duration.

Copy link
Member Author

@spowelljr spowelljr May 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't ignore error or linting fails, I replaced with a t.Logf so it won't fail the test.

}
spowelljr marked this conversation as resolved.
Show resolved Hide resolved
if err := ctx.Err(); err == context.DeadlineExceeded {
t.Error("minikube logs expected to finish by 5 seconds, but took longer")
}
})

})
}

Expand Down