You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Robert Inder <ro...@interactive.co.uk> on 2014/12/05 00:50:46 UTC

Re: Can I use a variable in a Configuration Element?

Sebb was right when he wrote...

On 20 November 2014 at 00:10, sebb <se...@gmail.com> wrote:
>> In any case, what is the best way to achieve what I'm trying to do?
>> To get each thread to use a different CSV Data Source file?
>
> ${__threadNum} might work.

It does.

And, with some hacking about, I have managed to do what I wanted

I wanted each thread to read values from a different (named) CSV file.

I can't do it the "obvious" way -- using a User Parameters component
to assign a file name differently for each thread/user -- because all
configuration components (including CSV Data Set Configs that would need
the file names) are run before Pre-processors (including the User
Parameters component that would assign them).

But the following approached, based on Sebb's comment, has done the necessary.

I have a User Defined Variables (configuration) component which
assigns includes
   ${__split(file1|file2|file3,FILE,|)}
which puts my files into FILE_1, FILE_2, FILE_3...

Then, I have set the "Filename" parameter of the CSV Data Set Config to

   FOLDER/${__V(FILE_${__javaScript(1+${__threadNum} % ${FILE_n})})}

(N.B. I've had to cut-and-paste this code, because cut-and-paste
 from JMeter GUI on Windows 7 is not actually working.

The Javascript is there to get threadNum modulo FILE_n, which
makes the threads wrap round the available files.

So thanks to Sebb.

Robert


-- 
Robert Inder,                                    0131 229 1052 / 07808 492 213
Interactive Information Ltd,   3, Lauriston Gardens, Edinburgh EH3 9HH
Registered in Scotland, Company no. SC 150689
                                           Interactions speak louder than words

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