Collections parallel execution

What is the simplest way to execute different collections in parallel with newman? On local machine. Right now we do it on Jenkins but I want to try on my computer before push.

I have different collection under different folders(but the same root folder) and I’m run them with this command in .bat script for /r %%f in (./*) do newman run %%f -e Environment.json --bail
but it’s ‘single thread’.
So , how to run all those collections in parallel? I want to cut execution time.

This script in the Newman repo runs parallel collections using async: https://github.com/postmanlabs/newman/blob/develop/examples/parallel-collection-runs.js

And here’s an article about load testing with more words about that: https://medium.com/better-practices/dont-get-techcrunched-performance-testing-for-your-http-apis-3196e40f6b70#7e8e

Hi Joyce,

I’ve followed a similar thing by doing this your colleague @matt did however I have an issue with the environment variables. Basically I want to run the same collection in parallel but with a different value as environment variable. I therefore did that

newman.run({
      collection: require('./config/postman/collection.json'),
      environment: [activity],
      folder: collectionFolderName,
      reporters: 'cli',
      timeoutRequest: constants.TIMEOUT_REQUEST,
      iterationCount: constants.NUMBER_OF_CARTS,
      bail: true,
  })  

and they are supposed to call URL with a different value such as
{{api_base_url}}/activities/{{activityUuid}}
how ever it seems that the run are using the same value. It is possible that environment variables are shared between runs? If yes could you tell me how can I set dynamically a value such as a part of the URL path without altering others runs?

Thank you in advance
Aurélien

@aurelien.lair it looks like you might only be sharing an excerpt of your script as it matches neither the example @jetison provided or the gist out on my GitHub. If you’re specifying different environment files/objects, it should definitely not be using the same one - the snippet you included looks like just a singular Newman run however.

Hi Matt,
thanks for answering me. What I am doing is to loop on an array of objects and to prepare a set of commands to run. The collection is the same but I’d like to change the environment variable within each command so that each command has its own URL like

{{api_base_url}}/activities/{{activityUuid}}

By doing this it seems that the environment variable is not different hence the URL is the same…

constants.CARTS.map(cart => {
    activity = require('./out/activities/' + cart.id + '.json'); 
    
    newman.run({
      collection: require('./config/postman/collection.json'),
      environment: [activity],
      folder: cart.collectionFolderName,
      reporters: 'cli',
      timeoutRequest: constants.TIMEOUT_REQUEST,
      iterationCount: constants.NUMBER_OF_CARTS,
      bail: true,
   })
});

async.parallel(commands);

I want to split request within collection and run is it possible, say I Have 50 test request in a collection can i split 25*2 in two parallel runs

That, exactly. I don’t want to run multiple collections in parallel. I want to run a single collection’s requests in parallel. Can Newman do that?