I created below scenario with two exec functions, each will have its own data file. I dont want to load both the files for each Vuser. I tried using env to load the file but the env is not available in init code. Please suggest
export let options = {
scenarios: {
PDP_UI : {
executor: 'ramping-vus',
startVUs: 0,
stages: [
{ duration: '1s', target: 1 },
{ duration: '1s', target: 1 },
],
gracefulRampDown: '0s',
tags: { test_type: 'PDP_UI',name:"PDPUI" },
exec: 'pdp_ui',
env: { appname: 'PDP_UI' },
},
PDP_XAPI : {
executor: 'ramping-vus',
startVUs: 0,
stages: [
{ duration: '15m', target: 9000 },
{ duration: '30m', target: 9000 },
],
gracefulRampDown: '0s',
tags: { test_type: 'PDP_XAPI',name:"PDPXAPI" },
exec: 'pdp_xapi',
env: { appname: 'PDP_XAPI' },
},
}
}
var datafile
if (__ENV.appname == 'PDP_UI')
{
datafile = papaparse.parse(open('product_ui.csv'), { header: false }).data;
}
else if (__ENV.appname == 'PDP_xapi')
{
datafile = papaparse.parse(open('product_xapi.csv'), { header: false }).data;
}
export function pdp_ui() {
let data = datafile[Math.floor(Math.random() * datafile.length)];
http.get(site+data);
}
export function pdp_xapi() {
let data = datafile[Math.floor(Math.random() * datafile.length)];
http.get(site+data);
}
Thanks
Rama