-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Groups in the end-of-test summary are unordered #1316
Comments
I have also noticed that custom metrics have a seemingly random order in the CLI output. |
@sniku, I'm not sure we ever showed metrics in the order they occurred in the script, but we probably should... I see that it seems like we're sorting them alphabetically now, which is not ideal, but as far as I can see has been the case since at least k6 v0.19.0 and maybe earlier. For example, running the following script with k6 v0.26.0: import { Counter } from "k6/metrics";
import { group, check, sleep } from "k6";
let counter1 = Counter("bbb");
let counter2 = Counter("ccc");
let counter3 = Counter("aaa");
export let options = {
vus: 10,
duration: "2s",
}
const checks = {
"1) is below 0.5": (v) => v < 0.5,
"2) is equal to 0.5": (v) => v == 0.5,
"3) is above 0.5": (v) => v > 0.5,
};
export default function () {
group("group 1", function () {
counter1.add(__ITER);
check(Math.random(), checks);
});
group("group 2", function () {
counter2.add(__ITER);
check(Math.random(), checks);
});
group("group 3", function () {
counter3.add(__ITER);
check(Math.random(), checks);
});
sleep(0.5);
} may result in something like this:
🤦♂️ ... I guess the most immediate and biggest reason for the disorderly listing of groups and checks in the summary is that iteration order of maps is not guaranteed in any way in Go, and we save the groups and the checks as string maps: https://github.com/loadimpact/k6/blob/74f11a6b6703282c282c2baf42ccaa8fa3a23d31/lib/models.go#L110-L112 |
Would it be possible to have the groups ordered in the order they are executed in the script, with the first at the top? I'm not sure alphabetical would be intuitive... |
@safebear, probably yes. At the moment, to me, displaying the groups in chronological order seems to be the most logical and to offer the best UX. That said, if we sort the group names alphabetically, you can always turn that in a chronological order by just naming your first group Ideally, though, I'd like for us to have both options (and maybe more) through the planned templating functionality for the end-of-test summary (#1319 (comment)). It's just a matter of carefully and efficiently storing the groups and checks information in a way that doesn't loose the chronological order, and then providing some simple helper functions in the template that allows for different sort orders... 🤞 😅 |
I would like to throw in some support for chronological order. This is what I was expecting to see, kind of like the result tree in JMeter. I was surprised when they weren't in order, and had to add some console.log statements to verify things were not occurring in an unexpected order. I think chronological order (order of execution) would make the best default. |
@na-- Can we consider using an ordered map for storing the groups and checks? wk8/go-ordered-map seems sensible to import. This would allow us to print the groups in the order they were defined in, as well as alphabetical if needed. |
I think we can make our own version:
|
As I mentioned in #1316 (comment), we should first have template support for the end-of-test summary and then tackle this. That way we can order the groups however we want (by time, by name, etc.), as well as make any number of other adjustments that someone might want. It would still likely require that we change the data structure from a map to some sort of an ordered data structure (though a slice seems better than an ordered map), but |
Environment
Expected Behavior
The hierarchical group information at the end of a test should be ordered in some way.
Actual Behavior
As this user in the community forum complained, and I've confirmed, the information for the hierarchical groups k6 emits at the end of the test run doesn't seem sorted in any way.
Testing old k6 version, this seems to have worked in k6 up to version v0.21.1, which ordered groups
alphabetically, and way broken by k6 v0.22.0...Steps to Reproduce the Problem
Run the following script multiple times:
The text was updated successfully, but these errors were encountered: