1

I want to read a variable from CSV and use that value into another variable. Example: I have a variable as: ${url}: wwww.$(value_from_csv}.com

and secondary url ${url}/xyz

In my Jmeter script, ${value_from_csv} is not passed.

What I am missing?

6
  • try with __evalVar function. here is my detailed answer stackoverflow.com/a/41287325/2575259 Commented Dec 29, 2016 at 6:03
  • thank you. it worked. But MongoDB Source Config doesn't read variable from CSV. Example: Server Address List : ${address_from_csv} but it doesn't read variables from csv. _ ERROR - jmeter.JMeter: Uncaught exception: java.lang.IllegalStateException: java.net.UnknownHostException: ${address_from_csv}: nodename nor servname provided, or not known_ can you help me on this?? Commented Dec 29, 2016 at 7:50
  • I don't understand the question fully. please add all necessary details. like test plan, where you defined address_from_csv and how are using it etc. Commented Dec 29, 2016 at 8:11
  • I have a CSV which contains variable Server Address List and other variables used in my script. In MongoDb Source Config" I input **Server Address List as ${address_from_csv} where address_from_csv is the server address of my mongoDB. But the problem is, MongoDb Source Config doesn't read variable value(address_from_csv) from CSV. On the other hand, other variables from CSV is working fine. Which implies there is no error in CSV Data Set Config. Commented Dec 29, 2016 at 8:18
  • can you please show me the test plan screenshot? Commented Dec 29, 2016 at 8:31

2 Answers 2

1

Observed that CSV Dataset Config values are not passed (not available) to any of the Config Elements irrespective of the order of the components (Config Elements) in JMeter Test Plan (checked with User Defined Config & MongoDB Source Config), though passed to Samplers.

so, suggested the OP to define the value in jmeter.properties instead of a CSV file, so we can access user.host in MongoDB Source Config.

Steps:

  1. Add user.host=address in jmeter.properties
  2. Restart Jmeter
  3. Add ${__P(user.host,)} in Server Address List field in MongoDB Source Config

Note: In case of running JMeter script from Jenkins, property will be picked by the script, from jmeter.properites file.

Sign up to request clarification or add additional context in comments.

10 Comments

s24.postimg.org/8cudoufwl/… I don't think this issue is because of ordering. Please refer to the screen shot for more info.
Thanks. will look into it. meanwhile, please share the CSV file content and CSV Dataset Config screenshot also
Here is the screenshot of csv data set config s30.postimg.org/51sc10mzl/… the other variables used in my script is working fine except the variable used in MongoDb Source Config.So, i think the issue is with mongodb config. Thanks
Checked. It seems CSV Dataset Config values are not available to other Config elements, checked with User Defined Variables also, but available to Samplers. so, there is no way you can use the value from the CSV file. But, From User Defined Variables/Test Plan, you can access the variables. so, you have to try with one of them. define address as a User Defined variable or in Test Plan, and access it MongoDb Source Config. I tried, it is working.
Thanks Naveen, I will try :) Thank you for all your effort and replying all my queries :)
|
0

MongoDB Source Config is initialized before any JMeter Variables so the only way to make it dynamic is using JMeter Properties instead.

You can set a JMeter Property in 2 ways:

  1. Define it in user.properties file like:

    server.address.1=some.ip.or.hostname.1
    server.address.2=some.ip.or.hostname.2
    
  2. Pass the properties via -J command-line arguments like:

    jmeter -Jserver.address.1=some.ip.or.hostname.1 -Jserver.address.2=some.ip.or.hostname.2 ....
    

See Apache JMeter Properties Customization Guide for more information on using JMeter Properties

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.