Hi ,
I have a collection for performance testing , it reads data from the input data.json file , should be pretty much straight forward and works correctly in functional run , but when run performance test , variables values are not substituted .
Data in json looks like :
let initialData =
[
{
clientId:"",
tenant:"",
agents:[
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
},
{
agent_id:"",
agent_token:""
}
],
list:"",
assets:[{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},
{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""}],
policies:[],
rules:[],
}]
In each request in the collection we fetch data in pre-requisite scripts with code
var stringAgents = JSON.stringify(pm.iterationData.get("agents"));
var agents = JSON.parse(stringAgents);
var agent_token = agents[0].agent_token;
pm.collectionVariables.set("agent_token", agent_token);
var stringAssets = JSON.stringify(pm.iterationData.get("assets"));
var assets = JSON.parse(stringAssets);
var asset_id = assets[0].asset_id;
console.log("asset_id:" + asset_id)
pm.collectionVariables.set("asset_id", asset_id);
var ip = assets[0].ip;
console.log("ip:" +ip)
pm.collectionVariables.set("ip", ip);
var tenant = pm.iterationData.get("tenant");
console.log("tenant:" +tenant)
pm.collectionVariables.set("tenant", tenant);
var list = pm.iterationData.get("list");
console.log("list"+list)
pm.collectionVariables.set("list", list);
But every time when I run performance test , with data.json , 20 UV users with rump up period , I got 100% fails because variables that are expected in the request headers and authentication are not substituted
While when functional run with same data.json file , all data is substituted correctly
Please advise what am i doing wrong