You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by "Purdy, Ron" <rp...@globalspec.com> on 2008/04/28 20:35:20 UTC

How do you read and use values from a file?

I would like to take a text file containing hundreds of URLs and have
JMeter go through the file visiting each URL.

Any suggestions as to what parts of JMeter I should be trying to use?
I have version 2.3.1.


Ron Purdy
rpurdy@globalspec.com

Re: How do you read and use values from a file?

Posted by Michael Giroux <ml...@gmail.com>.
> Is there some way to make this definition global to the entire test plan?

Answered my own question: __setProperty()

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by Michael Giroux <ml...@gmail.com>.
> The docs specifically state that variables are local to threads.

Yes, I see that now.  It is mentioned in a highlighted box in 19.
Functions and Variables topic.

As I was hunting around the JMeter documentation, and came upon an
entry in the Wiki asking whether users actually read the docs.  I can
assure you that I have been reviewing these docs for a few days and
this fact that variables are local to a thread didn't really hit at
first.  Perhaps I overlooked it the first time or two.

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


RE: How do you read and use values from a file?

Posted by Steve Kapinos <St...@tandberg.com>.
>Part of the confusion is caused by the fact that user defined variables
at 
>the test plan level are visible to the entire plan, and the reference
is 
>exactly the same ${varname} leading the first time users of JMeter to
think 
>that any variable is global. 

The docs specifically state that variables are local to threads.  And
also say the first thing to do is add a threadgroup.. Not create
elements above the threadgroup :)  Part of the issue is conceptualizing
'threads' being different instances with their own values because it can
be confusing on which data is reset/refreshed per thread while others
may be persistant.

The problem with the docs on variables is they are kind of spread out..
Being primarily referenced as an after thought in functions.  

Docs need a concise summary table detailing usage of variables vs
properties (and difference between system and local properties).  Items
of note are when they are processed, their scope, and possibilities to
define them (like command line vs UDV etc).

-----Original Message-----
From: Michael Giroux [mailto:mlgiroux@gmail.com] 
Sent: Wednesday, May 07, 2008 5:13 PM
To: JMeter Users List
Subject: Re: How do you read and use values from a file?

> Variables are specifically designed to be local to threads (not just 
> thread groups).
> This is because threads represent different users.
>
> JMeter properties are global, see:
>
> http://jakarta.apache.org/jmeter/usermanual/functions.html

It would be helpful to include little reminders such as this in the
documentation that creates variables.  For example, the __javaScript
function reminds us to "Remember to include the necessary quotes ..."

It would be handy to remind us that the reference name created by a
function or element is local to the thread.

Part of the confusion is caused by the fact that user defined variables
at the test plan level are visible to the entire plan, and the reference
is exactly the same ${varname} leading the first time users of JMeter to
think that any variable is global.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by Michael Giroux <ml...@gmail.com>.
> Variables are specifically designed to be local to threads (not just
> thread groups).
> This is because threads represent different users.
>
> JMeter properties are global, see:
>
> http://jakarta.apache.org/jmeter/usermanual/functions.html

It would be helpful to include little reminders such as this in the
documentation that creates variables.  For example, the __javaScript
function reminds us to "Remember to include the necessary quotes ..."

It would be handy to remind us that the reference name created by a
function or element is local to the thread.

Part of the confusion is caused by the fact that user defined
variables at the test plan level are visible to the entire plan, and
the reference is exactly the same ${varname} leading the first time
users of JMeter to think that any variable is global.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by sebb <se...@gmail.com>.
2008/5/7 Michael Giroux <ml...@gmail.com>:
> I just ran another test and discovered that the variable defined by
>  the RegEx Extractor is only visible within the thread group that
>  crated it.
>
>  As I explained, I execute a transaction to echo the value of the
>  variable to confirm that the value has been extracted correctly.  This
>  echo correctly displays the variable when executed in the same
>  threadgroup that contains the RegEx Extractor.  However, when I copy
>  that HTTP Request element to a subsequent thread group, the variable
>  is not expanded.
>
>  Is there some way to make this definition global to the entire test plan?
>

Variables are specifically designed to be local to threads (not just
thread groups).
This is because threads represent different users.

JMeter properties are global, see:

http://jakarta.apache.org/jmeter/usermanual/functions.html


>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by Michael Giroux <ml...@gmail.com>.
I just ran another test and discovered that the variable defined by
the RegEx Extractor is only visible within the thread group that
crated it.

As I explained, I execute a transaction to echo the value of the
variable to confirm that the value has been extracted correctly.  This
echo correctly displays the variable when executed in the same
threadgroup that contains the RegEx Extractor.  However, when I copy
that HTTP Request element to a subsequent thread group, the variable
is not expanded.

Is there some way to make this definition global to the entire test plan?

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by Michael Giroux <ml...@gmail.com>.
> Are you sure?
>
> It works fine for me.
>
> Try defining VAR as fixed text, and check that the RA works.

Yes, that works.

> If the VAR appears to be set, but is not being picked up by the RA,
> then perhaps the variable is being defined after the RA is processed.

That would seem to be a bug.

The test plan is like this:
1. thread group with single thread executes a transaction to obtain
the expected result.

This thread group uses regular expression extractor to define a
reference name containing the text to be matched later in the test.

The reference name is fed into another transaction to verify that the
pattern is correct and the reference variable has been set correctly.
.. it is correct

2. a second thread group with 9 threads executes a series of transactions.

3. finally, a thread group with a single thread executes a transaction
and uses the Response Assertion to validate the result.

If the RA uses a variable that is defined in the test plan user
defined variables, then the RA correctly matches the output.

If the RA uses a variable that is difined using the Regular Expression
Extractor from the first thread group, the RA does not match.

>From this it appears that:
a. user defined variables defined in the Test Plan can be substituted
into the patterns of a Response Assertion.
b. variables created using Regular Expression Extractor cannot be
substituted into the patterns of an RA.

So back to my original question, is there a way to substitute
variables created by RegEx Extractor into an RA pattern?

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by sebb <se...@gmail.com>.
2008/5/7 Michael Giroux <ml...@gmail.com>:
> > Start with fixed strings, and replace them with variables defined in
>  > the CSV Dataset.
>
>  I have tried to do something similar, but cannot figure out how to use
>  a variable in a response assertion.  The documentation is not overly
>  clear on this point.
>
>  1. I have an HTTP request that generates a well defined output message
>  2. I have successfully used a regular expression extractor to define a
>  variable that extracts
>  an expected value from the output message
>  3. I have used HTTP Request to invoke a simple ECHO ${VAR} to prove
>  that VAR was correctly defined in the regex extractor.
>
>  I have not been successful in using this var in a pattern for a
>  response assertion.
>
>  What is the correct way to do this?
>
>  For example, the following pattern does not work
>  some known text followed by ${VAR}

Are you sure?

It works fine for me.

Try defining VAR as fixed text, and check that the RA works.

If the VAR appears to be set, but is not being picked up by the RA,
then perhaps the variable is being defined after the RA is processed.

>  Nor does
>  some known text followed by ${__V(${VAR})}
>
>  or
>  ${__V(some known text followed by ${VAR})}
>
>  Surely there must be a way to drop a variable into a pattern for a
>  response assertion.
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by Michael Giroux <ml...@gmail.com>.
> Start with fixed strings, and replace them with variables defined in
> the CSV Dataset.

I have tried to do something similar, but cannot figure out how to use
a variable in a response assertion.  The documentation is not overly
clear on this point.

1. I have an HTTP request that generates a well defined output message
2. I have successfully used a regular expression extractor to define a
variable that extracts
an expected value from the output message
3. I have used HTTP Request to invoke a simple ECHO ${VAR} to prove
that VAR was correctly defined in the regex extractor.

I have not been successful in using this var in a pattern for a
response assertion.

What is the correct way to do this?

For example, the following pattern does not work
some known text followed by ${VAR}

Nor does
some known text followed by ${__V(${VAR})}

or
${__V(some known text followed by ${VAR})}

Surely there must be a way to drop a variable into a pattern for a
response assertion.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by sebb <se...@gmail.com>.
2008/4/28 Purdy, Ron <rp...@globalspec.com>:
> Maybe I don't understand enough to properly answer.  Here is my
>  attempt..
>  I am actually trying to run a functionality test.
>  I want to go to a URL and then try to positively verify that certain
>  words appear and then negatively verify that other words do not appear
>  (404 error, generic error, problem)
>

JMeter has CSV Dataset

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#CSV_Data_Set_Config

which can be used to read variables from CSV files.

The variables can then be used in Samplers and the Response Assertion:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Response_Assertion

I suggest you start by creating a very simple test plan:

Thread Group
+ CSV Dataset (Recycle EOF=false, Stop on EOF=true)
+ HTTP Sampler
+ + Response Assertion Contains
+ + Response Assertion Contains Not

Start with fixed strings, and replace them with variables defined in
the CSV Dataset.




>  I have tried to use commercial software, but it can not handle the large
>  number of URLs I am trying
>  to hit. (I have thousands) Also since this software actually uses a
>  browser, there are long time delays for each entry and memory leak
>  issues in the browser.
>
>  I have always believed that load tests could be functional tests with
>  the volume turned up.
>  So I could use this for load testing at some point in the future.
>
>  You used the terms "screen scrape" Could I use that to look for the
>  specific words?
>  and "proxy record"  I am drawing a complete blank on that one and my
>  Google search seemed related to
>  temperature studies.. Can you define what you meant?
>
>
>   Ron Purdy
>   rpurdy@globalspec.com
>
>
>
> -----Original Message-----
>  From: David Brown [mailto:david@davidwbrown.name]
>  Sent: Monday, April 28, 2008 4:18 PM
>  To: JMeter Users List
>  Subject: Re: How do you read and use values from a file?
>
>  What r u trying to do?: monitor?, load test?, proxy record?, screen
>  scrape? JMeter has many Samplers and Listeners.
>
>  Purdy, Ron wrote ..
>  > I would like to take a text file containing hundreds of URLs and have
>  > JMeter go through the file visiting each URL.
>  >
>  > Any suggestions as to what parts of JMeter I should be trying to use?
>  > I have version 2.3.1.
>  >
>  >
>  > Ron Purdy
>  > rpurdy@globalspec.com
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


RE: How do you read and use values from a file?

Posted by David Brown <da...@davidwbrown.name>.
JMeter has no Screen scrape built in functionality but I suppose u could use JMeter Proxy recording as a type of screen scraping since it records all of the input invoked by the user using the browser as a proxy. As far as file input I have not done so myself but I have seen plenty of folks on this ML that have used all types of file input including CSV. JMeter is open source so if it does not have the functionality you want then navigate to the JMeter bugzilla and put in a feature request. Otherwise if all you need is a screen scrape see: http://noodle.tigris.org/. HTH


Purdy, Ron wrote ..
> Maybe I don't understand enough to properly answer.  Here is my
> attempt..
> I am actually trying to run a functionality test.   
> I want to go to a URL and then try to positively verify that certain
> words appear and then negatively verify that other words do not appear
> (404 error, generic error, problem)
> 
> I have tried to use commercial software, but it can not handle the large
> number of URLs I am trying
> to hit. (I have thousands) Also since this software actually uses a
> browser, there are long time delays for each entry and memory leak
> issues in the browser. 
> 
> I have always believed that load tests could be functional tests with
> the volume turned up.
> So I could use this for load testing at some point in the future.
> 
> You used the terms "screen scrape" Could I use that to look for the
> specific words?
> and "proxy record"  I am drawing a complete blank on that one and my
> Google search seemed related to
> temperature studies.. Can you define what you meant?
> 
>  Ron Purdy
>  rpurdy@globalspec.com
> 
> -----Original Message-----
> From: David Brown [mailto:david@davidwbrown.name] 
> Sent: Monday, April 28, 2008 4:18 PM
> To: JMeter Users List
> Subject: Re: How do you read and use values from a file?
> 
> What r u trying to do?: monitor?, load test?, proxy record?, screen
> scrape? JMeter has many Samplers and Listeners.
> 
> Purdy, Ron wrote ..
> > I would like to take a text file containing hundreds of URLs and have 
> > JMeter go through the file visiting each URL.
> > 
> > Any suggestions as to what parts of JMeter I should be trying to use?
> > I have version 2.3.1.
> > 
> > 
> > Ron Purdy
> > rpurdy@globalspec.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


RE: How do you read and use values from a file?

Posted by "Purdy, Ron" <rp...@globalspec.com>.
Maybe I don't understand enough to properly answer.  Here is my
attempt..
I am actually trying to run a functionality test.   
I want to go to a URL and then try to positively verify that certain
words appear and then negatively verify that other words do not appear
(404 error, generic error, problem)

I have tried to use commercial software, but it can not handle the large
number of URLs I am trying
to hit. (I have thousands) Also since this software actually uses a
browser, there are long time delays for each entry and memory leak
issues in the browser. 

I have always believed that load tests could be functional tests with
the volume turned up.
So I could use this for load testing at some point in the future.

You used the terms "screen scrape" Could I use that to look for the
specific words?
and "proxy record"  I am drawing a complete blank on that one and my
Google search seemed related to
temperature studies.. Can you define what you meant?

 Ron Purdy
 rpurdy@globalspec.com

-----Original Message-----
From: David Brown [mailto:david@davidwbrown.name] 
Sent: Monday, April 28, 2008 4:18 PM
To: JMeter Users List
Subject: Re: How do you read and use values from a file?

What r u trying to do?: monitor?, load test?, proxy record?, screen
scrape? JMeter has many Samplers and Listeners.

Purdy, Ron wrote ..
> I would like to take a text file containing hundreds of URLs and have 
> JMeter go through the file visiting each URL.
> 
> Any suggestions as to what parts of JMeter I should be trying to use?
> I have version 2.3.1.
> 
> 
> Ron Purdy
> rpurdy@globalspec.com

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How do you read and use values from a file?

Posted by David Brown <da...@davidwbrown.name>.
What r u trying to do?: monitor?, load test?, proxy record?, screen scrape? JMeter has many Samplers and Listeners.

Purdy, Ron wrote ..
> I would like to take a text file containing hundreds of URLs and have
> JMeter go through the file visiting each URL.
> 
> Any suggestions as to what parts of JMeter I should be trying to use?
> I have version 2.3.1.
> 
> 
> Ron Purdy
> rpurdy@globalspec.com

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org