How can I run simultaneous request parallely

request
simultaneous-request
#1

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

@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.

Help needed , How do i run all collections in one Folder
#3

@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

#4

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?

#5

@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.

#6

@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
#7

@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
#8

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

1 Like