Last active
May 11, 2025 15:24
-
-
Save nikajordania/c211264baa216e1dd3bd89cff2878a41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {open} from 'k6/experimental/fs' | |
import csv from 'k6/experimental/csv' | |
import {scenario} from 'k6/execution' | |
import exec from "k6/execution"; | |
export const options = { | |
executor: "shared-iterations", | |
vus: 10, | |
iterations: 200, | |
} | |
let file = await open('data.csv'); | |
let csvRecords = await csv.parse(file, {delimiter: ',', asObjects: true}); | |
export default async function () { | |
console.log(`VU: ${__VU} - ITER: ${__ITER}`); | |
let uniqueNumber = __VU * 100 + __ITER -100 ; | |
console.log(uniqueNumber); | |
console.log(exec.test.options.scenarios.default.vus + "asdsd"); // 10 | |
let record = csvRecords[scenario.iterationInTest]; | |
// The csvRecords a SharedArray. Each element is a record from the CSV file, represented as an array | |
// where each element is a field from the CSV record. | |
// | |
// Thus, `csvRecords[scenario.iterationInTest]` will give us the record for the current iteration. | |
console.log(record.user) | |
console.log(record.param) | |
// | |
// let uniqueNumber1 = __VU * 100 + __ITER; | |
// let user = data.users[uniqueNumber1]; | |
// console.log(data.users[uniqueNumber1].username); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment