Running multiple Unique VUs using Postman to k6

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();
}

Hi @Bruno !

I’m a bit confused, are you asking how to achieve this in postman or in k6 scripts? :thinking:

Cheers

k6 script, using Postman to k6

Hi @Bruno

I’m sorry, I’m not a postman-to-k6 developer and not familiar with the tool.

In fact, currently the fork of it maintains by another company. I’d recommend trying to check directly with them GitHub - apideck-libraries/postman-to-k6: Converts Postman collections to k6 script code.

Sorry for that,
Cheers