Pass dynamic URL's to Requests URL

93 views
Skip to first unread message

Ajith md

unread,
Oct 10, 2023, 2:06:49 AM10/10/23
to codename-taurus
Hi All,

I need pass dynamic URL's from Jenkins to Taurus.
I can either fetch it from json file or send it through Command line arguments from jenkins.

Tried several options like the one mentioned below code snippet, and also to pass as command like argument (bzt testV21.yml -o modules.jmeter.properties.property1='https:iam-s../....).

included-configs:
- prop.json

modules:
jmeter:
properties:
CookieManager.save.cookies : true
property1: ${__P(url_param)}

scenarios:
Perf-Test:
variables:
requests:
- url: ${property1}
method: POST
label: iam
body:
headers:

json file:
{
"url_param": "https://iam-s.."
}


Getting error as below:

Non HTTP response message: Illegal character in path at index 7: http:/${property1} 

Could you please help in understanding what is wrong here ?


DT

unread,
Oct 10, 2023, 3:03:10 AM10/10/23
to codename-taurus
Included configs  are for merging additional Taurus YAML files into your configuration, you cannot set arbitrary attribute/value pairs there.

With regards to passing the URL from the command line you need to change this line:

- url: ${property1}

to this one:
- url: ${__P(property1,)}

If you want to play with full minimal config:

execution:
- executor: jmeter
concurrency: 1
iterations: 1
scenario: get-request

scenarios:
get-request:
requests:
- ${__P(property1,)}


Launch it like:

bzt -o modules.jmeter.properties.property1="http://example.com" /path/to/your/test.yaml

Message has been deleted

DT

unread,
Oct 10, 2023, 4:40:35 AM10/10/23
to codename-taurus
I've given you solution for Taurus and JMeter, I have no idea what kind of shell you're using and how you need to escape special characters there, try using single quotes instead of double quotes, if it doesn't help refer your operating system or shell documentation or ask your boyfriend.



On Tuesday, October 10, 2023 at 10:36:45 AM UTC+2 Ajith md wrote:
Thank you for the quick response.

Still getting error's, could you pls help?

Tried both options suggested above.

Option 1:
scenarios:
Perf-Test:
variables:
requests:
- url: ${__P(property1,)}
method: POST

 bzt -o modules.jmeter.properties.property1=“https:iam.com.."

Response:

zsh: no matches found: modules.jmeter.properties.property1=““https:iam.com.."

Option 2:

scenarios:
Perf-Test:
variables:
get-request:
requests:
- ${__P(property1,)}
method: POST
label: iam
body:

Still getting same error as above -  "no match found"

Also, could you please let me know how to handle if "&" is present in the URL. It shows "zsh: parse error near `&'", if present in the URL.  










Ajith md

unread,
Oct 10, 2023, 5:03:37 AM10/10/23
to codename-taurus
Escape character is not my major concern. That I can solve.
Main problem is about the response received while trying with the solutions provided.
I tried with dummy URL's, and got above errors. 
Could you pls let me know if anything wrong in what I am trying ?


DT

unread,
Oct 10, 2023, 5:50:15 AM10/10/23
to codename-taurus
You're telling me that you tried the YAML config which I provided?

execution:
- executor: jmeter
concurrency: 1
iterations: 1
scenario: get-request

scenarios:
get-request:
requests:
- ${__P(property1,)}

and when you're launching it as:

bzt -o modules.jmeter.properties.property1="http://example.com" /path/to/your/test.yaml

you're getting the error? Because I don't:

Oct-10-2023 11-46-53.gif


If you need training on Taurus I would recommend checking out The Complete Taurus Course, however my expectation is that the problem is with "escape character", in particular weird quotation marks you're using because " and “ are different beasts and treated by your shell differently so get familiarized with Handling Special Characters in Shell Scripts as well.

Ajith md

unread,
Oct 10, 2023, 7:40:29 AM10/10/23
to codename-taurus

Thank you so much DT, it worked.. something went wrong in my previous trials. 
Message has been deleted

DT

unread,
Oct 13, 2023, 9:44:37 AM10/13/23
to codename-taurus
You've been given solution twice and you've been told to refer your shell documentation with regards to escaping special characters.

If you choose to ignore the recommendations I provide my last piece of input on this topic: as a workaround for all the c̶r̶a̶p̶ beautiful engineering solution you build for simple parameterization you can wrap your url parameter into __urldecode() function like

- url: ${__urldecode(${__P(iam_url,)} )}

More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

On Friday, October 13, 2023 at 3:39:01 PM UTC+2 Ajith md wrote:

Kindly help on resolving below issue.

I am able to pass the URL as properties from Jenkins file, by replacing special characters (&) using (%26) escape character's. 

(If I am not replacing &, below command will fail.)

sh("bzt -o modules.jmeter.properties.iam_url=$URL test.yml")

modules:
jmeter:
properties:
CookieManager.save.cookies : true

scenarios:
Perf-Test:
variables:
userToken: no token
xsrfToken: no token
requests:
- url: ${__P(iam_url,)}
method: POST
label: iam
body:
headers:

Issue is that the escape characters are not decoded back to the original form.

In the effective.json, it is still showing as "https://dsf.com/token?client_id=dsffgfd%26secret=ca....". 

I cant open this page directly from browser also, it throws error: error":"invalid_request 


Is this a normal behaviour or I have to enable any more settings ?

If this cannot be resolved, is there any way to pass as separate properties from command line (like currently passing URL) and append as query string to the URL ?

If not, can I read the URL values from any files ?


Request your support.

Reply all
Reply to author
Forward
0 new messages