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

Keep default summary when custom summary is requested #2729

Open
PabloDelBarrioArnanz opened this issue Oct 14, 2022 · 6 comments
Open

Keep default summary when custom summary is requested #2729

PabloDelBarrioArnanz opened this issue Oct 14, 2022 · 6 comments
Labels
evaluation needed proposal needs to be validated or tested before fully implementing it in k6 feature

Comments

@PabloDelBarrioArnanz
Copy link

Feature Description

When handleSummary it's use also could be provided the default report optionally.

I am interested in return summary as junit report but also i would like keep default summary.

Suggested Solution (optional)

No response

Already existing or connected issues / PRs (optional)

No response

@PabloDelBarrioArnanz
Copy link
Author

@oscar067

@eugercek
Copy link
Contributor

eugercek commented Oct 15, 2022

I used the below to give the default summary output to the stdout. I had other exports but removed them for clarity. To solve the problem asap can use the below.

import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.2/index.js";

export function handleSummary(data) {
  return {
    stdout: textSummary(data, { indent: " ", enableColors: true })
  };
}

Though, it would be useful to have that as an option IMO.

@na-- na-- added the evaluation needed proposal needs to be validated or tested before fully implementing it in k6 label Oct 16, 2022
@na--
Copy link
Member

na-- commented Oct 16, 2022

The solution that @eugercek gave is the official recommendation. Though maybe use the latest v0.0.2 version of the library: https://jslib.k6.io/k6-summary/0.0.2/index.js (or any later ones that have been released since this comment was made).

The reason that k6 doesn't print the default end-of-test summary if you implement handleSummary() yourself is that the user might not want to have that on stdout. They might be using it for something else, e.g. logs, and redirecting k6's stdout to some other process' stdin. There needs to be a way for users to prevent k6 from polluting the stdout with things they don't want.

It might have been better if k6 always prints the text summary to stdout if the user doesn't return a stdout key from handleSummary() 🤔 That way, it will still be easy to prevent k6 from printing anything by just returning an empty string (return {stdout: '', whatever: actualSummary};). However, to do so now will be a relatively big breaking change and I am not sure it's worth it 🤔

@eugercek
Copy link
Contributor

IMO this version is better. If one implemented handleSummary() and saw stdout pollution they need to find how not to print anything to stdout .return {stdout: '', whatever: actualSummary}; like additional line could feel "hacky" since one already said how to handle the summary.

Can we add a new long option, and not break the default behavior? An option like --keep-default-summary could solve this issue. Also a week ago I looked at the k6 run -h to find an option like this.

@na--
Copy link
Member

na-- commented Oct 17, 2022

We'd prefer to keep the number of global options to a minimum, especially when they duplicate behavior that can already be achieved with very little code. We probably already have too many such options and we have plenty of issues with them (e.g. #883 and the many connected issues).

What we could do instead is to expose the built-in function to generate the k6 summary internally, so user would be able to import it instead of the one from https://jslib.k6.io/ 🤔 Not great, but it will limit the number of externally imported files.

@PabloDelBarrioArnanz
Copy link
Author

That's would be a great solution! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluation needed proposal needs to be validated or tested before fully implementing it in k6 feature
Projects
None yet
Development

No branches or pull requests

3 participants