So, I want to execute same request uniquely many times… for example: I want to create items using 50VUs, every VU creates an unique item, how do I make this work?
50 VUs working in parallel but every single one is creating unique item at the same time
let itemName = `ItemNameByPostman${Math.floor(
Math.random() * 10000000 + 1
)}`;
pm.environment.set("creatingSingleItemName", itemName);
postman[Request]({
name: "Creating Item",
id: "25c0cdc1-4cea-462c-917d-1395bf90a548",
method: "POST",
address: "{{core_url}}/api/items",
data:
'{\n "name": "{{creatingSingleItemName}}",\n "description": "{{description}}",\n "foreignId": "{{foreignID}}",\n "serial": "{{serial}}",\n "organizationUnitId": "{{firstOrganisationID}}"\n}',
headers: {
"Content-Type": "application/json",
"Authorization": "" //Bearer token copied from Postman run
},
pre() {
let itemName = `ItemNameByPostman${Math.floor(
Math.random() * 10000000 + 1
)}`;
pm.environment.set("creatingSingleItemName", itemName);
},
post(response) {
pm.test("Successful POST request", () => {
pm.expect(pm.response.code).to.be.oneOf([201, 202]);
});
pm.test(
`Response time is less than ${pm.environment.get("responseTime")}`,
() => {
pm.expect(pm.response.responseTime).to.be.below(
Number(pm.environment.get("responseTime"))
);
}
);
pm.test("Entity location successfully saved", () => {
let entityLocation = postman.getResponseHeader("location");
let entityID = entityLocation.substring(
entityLocation.lastIndexOf("/") + 1,
entityLocation.length
);
pm.environment.set("itemsCreatingItemID", entityID);
});
},
});
postman[Pre].pop();
}