How can I run simultaneous request parallely

I would like to know is there any way to run request parallel [i.e : run 2 POST/PATCH request parallely instead of sequential order]

Please help me in this.

I have used parallel runner but it fails to run, any suggestion using postman.

Thanks
Logesh

2 Likes

@Lohcaiz It sounds like your best bet for this would be to utilize the Newman runner, if you havent yet.

If your collections can run in parallel with no need to interact with each other then this would be the ideal way to make this happen. I have done something similar in the past to help simulate a lot of traffic.

To do this I simply created a bash script and added the command I would to execute the newman runs in as many times as needed.
It looked something like this …

#!/bin/bash
newman run postman/smoke-test/collection.json -e postman/smoke-test/environments/staging.json &
newman run postman/smoke-test/collection.json -e postman/smoke-test/environments/staging.json &
newman run postman/smoke-test/collection.json -e postman/smoke-test/environments/staging.json

This basically kicks off 3 runs at the same time, executing the exact same collection against the same environment. Not perfect by any means but got the job done for me.

Hope this helps and let me know if you have any questions.

2 Likes

@tmccann

Hi… regrading the solution you suggested for running multiple Collections in one folder, how can i solve the issue with using Newman with the Postman API. I wanted to run it in Jenkins has a collection of smoke tests… please

Thanks in advance for your help

Hey @ola100
So you are looking to make some calls to the Postman API first? Assuming you want to retrieve your collections/environments and then using that information execute multiple runs like I suggested in my above post?

@tmccann

Thanks for your response, much appreciated

We are running it in Jenkins using Postman API. In the smokeTest folder there are multiple collections in it , but any time we execute the job on Jenkins, it only runs the first Collection in the smokeTest folder.

So how can run newman with Postman API in Jenkins and be able to execute all the collections in the smokeTest folder and where should we put the " #!/bin/bas" file.

@ola100 So I had to think about this a bit as I am sure there are a few ways you can accomplish this.
Depending on what you are looking to do exactly I would say you would just need to loop though things.

So here is an example of a bash script I have that does something like that:

#!/usr/bin/env bash

# Loop though each collection in the folder.
for filename in src/tests/*.json; do
    newman run ${filename} \
        --environment "configs/${1}.test.json" \
        --verbose \
        --disable-unicode \
        --color on \
        --delay-request 100
done 

So what I am doing here is just doing a for loop against a directory, that contains my collections.

There is also a parameter I am passing in here as well. ${1} is the name of the environment I am running it against, I have different environment templates for each supported env I want to run against.
This is good practice if you plan to execute in more than a single env as then you wont require multiple scripts, one for each env.

So from this you can add in other things to the for loop if you wanted. Like if you wanted to kick off a few runs at once or call something else.

Before you do this though you will prob want to have something in your Jenkins build job that calls the Postman API to get the collections you want and place them in a specific folder. You can do this by simply adding in Execute Shell commands in your Jenkins job.

So a quick and dirty way to me would be to add in an execute shell command to get your collection:

curl -X GET \
  https://api.getpostman.com/collections/394625-00000000-0000-0000-0000-000000000000 \
  -H 'Cache-Control: no-cache' \
  -H 'x-api-key: 1idxvfcbpanc4ydm9vdah28j8rwmm08n' > collection.json

Then get your env template, if you are using them:

curl -X GET \
  https://api.getpostman.com/environments/394625-00000000-0000-0000-0000-000000000000 \
  -H 'Cache-Control: no-cache' \
  -H 'x-api-key: 1idxvfcbpanc4ydm9vdah28j8rwmm08n' > environment.json

You can do this for each collection you need to pull down or add some logic here to loop though and get them but this is just a quick walk though, so keeping some logic out of this.

Now you can run though the loop of collections as another execute shell command.

Not sure if this makes things any clearer but let me know and I will try to focus more on areas that you are having trouble with.

2 Likes

@tmccann

Hi, I want to thank you for taking your time to help with this issue much appreciated , the snippet point me to the right direction

2 Likes

Thats great to hear @ola100
Let me know if you have any questions.

1 Like

I want to see this as a native option in Postman / Collection Runner.

We get parallel posts a lot, even from the same source.

And Postman would have a cool feature that similar apps do not.

I found a quick and dirty UI workaround.

Open your requests in new Postman windows, not tabs.
Then stack the windows so the Send buttons can be clicked fast.

@tmccann parallel run with the above bash file you mentioned , each collection runner will run parallel or one after another ? I created window batch file to run it but it is running one collection at a time. Can you please help me, how can i run multiple collection at same time ?

@echo off

call newman run “XXXXXX.postman_collection.json”
call newman run “YYYYYY.postman_collection.json”
call newman run “ZZZZZZ.postman_collection.json”
pause

I think someone mentioned using the Start command which opens the command in a separate environment/command instance. This means the newman calls will happen in parallel.

Hi I would like to run my multiple postman collections in Jenkin, i tried to run the below command it is not working. Can you please help me.

#!/usr/bin/env bash
for filename in C:/Users/Admin/.jenkins/workspace*.json; do
newman run ${filename}
–verbose
–disable-unicode
–color on
–delay-request 100
done

Your script is slightly different to the one that @tmccann mentioned.

#!/usr/bin/env bash

# Loop though each collection in the folder.
for filename in src/tests/*.json; do
    newman run ${filename} \
        --environment "configs/${1}.test.json" \
        --verbose \
        --disable-unicode \
        --color on \
        --delay-request 100
done

What error are you seeing when running this? Could you provide an example?

1 Like

Hello, I am also trying to run a collection parallelly. I have newman on my machine, but not sure how to run the collection parallely.

Hello all, I want to make a simultaneous request to two different endpoints. Can anyone advise on how to implement this in postman…Any help will be greatly appreciated

Stack Overflow - Postman: How to make multiple requests at the same time