Hi @mstoykov,
Thanks for responding. Sorry for not making it clear the first time. Below is my script and csv file content.
my csv file content
AIds,BId,tagNewTrend
0122-1254-5579,112,Most RecentTag
0122-5932-5552,372,Most UpdatedTag
0122-1254-5987,239,Most LatestTag
my main.js script
import http from 'k6/http';
import { SharedArray } from "k6/data";
import papaparse from "https://jslib.k6.io/papaparse/5.1.1/index.js";
import { group, sleep, check } from 'k6';
import { Trend } from 'k6/metrics';
import { vu } from 'k6/execution';
import exec from "k6/execution";
import {RecentTag, UpdatedTag, LatestTag } from "./my_tags.js";;
const data = new SharedArray("credentials", function() {
return papaparse.parse(open('./data.csv'), {header: true}).data;
});
export const options = {
scenarios: {
login: {
executor: 'per-vu-iterations',
vus: data.length,
iterations: 1,
maxDuration: '10s',
},
},
};
let payload = JSON.parse(open('./testdata_v1.json'));
export default function(token) {
let headers = { 'Content-Type': 'application/json' };
let $token = "a8X3yRXkCPTs"
let data_Ids = data[vu.idInTest - 1].AIds;
let hub_Ids = data[vu.idInTest - 1].BId;
let tmpTrend = data[vu.idInTest - 1].tagNewTrend;
let tmpTrend = Newtrend;
payload.parameter[0].valueString = data_Ids;
payload.parameter[1].part[0].valueString = hub_Ids;
const BASE_URL = 'https://example.test.com/resolve/';
let f = JSON.stringify(payload);
sleep(1);
let res = http.request('POST', BASE_URL, JSON.stringify(({"resourceType":"Parameters","parameter":[{"name":"Ids","valueString": data_Ids},{"name":"context","part":[{"name":"randId","valueString": hub_Ids},{"name":"fhirtoken","valueString": $token},{"name":"sampleId","valueString":"23344"}]}]})), {
headers: headers,
});
check(res, {
'is status 200': (r) => r.status === 200});
# able to get the tagID from the csv file
console.log("Individual API Response Time (ms): " + Newtrend + " " + res.timings.duration);
Newtrend.add(res.timings.duration);
};
So when I try to use the “Newtrend” I get the error message saying object has no “add” member.
Also, is there a way to have the VUs run in sequence rather than all at once. My response time for the VUs executing at the end is very high since all the VUs are getting executed in parallel.
How do I run the VUs in order so that all of the response times are similar? Thanks in advance.