BIG NEWS! Remember all that messy math we’ve spoken about for months, above? Well, throw it away because a new era has arrived!
As of k6 0.34.0 we have released k6/execution
which includes a property scenario.iterationInTest
. This will return a unique value across all VUs, even in cloud tests!!!
For example:
import exec from "k6/execution";
import { SharedArray } from "k6/data";
const data = new SharedArray("my dataset", function(){
return JSON.parse(open('my-large-dataset.json'));
})
export const options = {
scenarios :{
"use-all-the-data": {
executor: "shared-iterations",
vus: 100,
iterations: data.length,
maxDuration: "1h"
}
}
}
export default function() {
// this is unique even in the cloud
var item = data[exec.scenario.iterationInTest];
http.post("https://httpbin.test.k6.io/anything?endpoint=amazing", item)
}
Full release notes are here: Release v0.34.0 · grafana/k6 · GitHub
Docs on k6/execution
: k6/execution