You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by ma...@interia.pl on 2006/08/01 15:25:57 UTC

Problem with CSVRead and multithread

Hello,

I've encountered a non-trivial problem I cannot solve - how to open many times the same file (each
in separate thread) or - how to manage file pointer for one opened file for each
thread separately?

Here is a short description of my application:

It's a bot created to perform tests. Bot is created based on jmeter. The structure
of test is simple:
- each test plan (scenario) consists of sequence of test modules.
- each module represents a bit of test (e.g. - loading a single webpage)
Both - scenarios and modules have unique IDs. Scenario is defines as sequence of
modules' IDs, module - as java codes (Beanshell samplers).

While running a test user has to enter at least a scenario ID. Bot reads (CSVRead)
line of definition of scenario (module IDs), and then loads (BeanShell sampler) and
runs the appropriate module. Module returns at end status of operation, that
determinates the following operations (return with Err or continue to the happy
end).

As long as I run one-thread tests all seems to be working properly. The problem
begins in case of number of threads. CSVRead allows to manage file pointers in each
thread independently but - here is the catch - each time I load value from CSV in
new thread - I'm given not the first value from file, but the next to previously
read by another thread. So - I cannot operate on the same whole file with number of
threads.

I've tried to use *ALIAS statement, but it doesn't work for me. There are no
examples of *ALIAS in manual nor in mailing lists.

I've tried also CSV Data Set Config and StringFromFile either - but both of them are
unusual in this context.

Perhaps is there any undocumented function of CSVRead allowing to fetch the value in
next thread from the very beginning of file?

Can anybody help me? Any suggestions are welcome.


Greetings,

mart


------------------------------------------------------------------------
Szybko i tanio ubezpiecz samochod! 
Kupno polisy zajmie Ci 15 minut! Kontakt przez telefon albo Internet. 
Kliknij i sprawdz: http://link.interia.pl/f198b


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


Re: Problem with CSVRead and multithread

Posted by sebb <se...@gmail.com>.
On 01/08/06, Yanroy <rm...@wpi.edu> wrote:
>
> I'm actually interested in checking this... I wrote a little script to print
> the hash value using the print() beanshell command, but I can't figure out
> where the output goes... I checked the jmeter.log file and it wasn't there,
> and I also looked around for a beanshell log and didn't find one.  It
> doesn't appear to be among the data in the jmeter results elements either.
> The beanshell listener is some kind of scriptable element?  I can't even
> imagine what that would do... the fact that it appears amongst the other
> listener elements made me think it might be the beanshell output console.
> How do I get the data?  Thanks.

print() writes to standard output.

For Windows, this appears in the DOS box, assuming that you use
java.exe rather than javaw.exe.

You can also use the "log" object, as in

log.info("informational message");

which should appear in jmeter.log

> --
> View this message in context: http://www.nabble.com/Problem-with-CSVRead-and-multithread-tf2033541.html#a5599383
> Sent from the JMeter - User forum at Nabble.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: Problem with CSVRead and multithread

Posted by Yanroy <rm...@wpi.edu>.
I'm actually interested in checking this... I wrote a little script to print
the hash value using the print() beanshell command, but I can't figure out
where the output goes... I checked the jmeter.log file and it wasn't there,
and I also looked around for a beanshell log and didn't find one.  It
doesn't appear to be among the data in the jmeter results elements either. 
The beanshell listener is some kind of scriptable element?  I can't even
imagine what that would do... the fact that it appears amongst the other
listener elements made me think it might be the beanshell output console. 
How do I get the data?  Thanks.
-- 
View this message in context: http://www.nabble.com/Problem-with-CSVRead-and-multithread-tf2033541.html#a5599383
Sent from the JMeter - User forum at Nabble.com.


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


Re: Problem with CSVRead and multithread

Posted by sebb <se...@gmail.com>.
On 01/08/06, Yanroy <rm...@wpi.edu> wrote:
>
> Mart,
> It seems you're having almost exactly the same problem I am!  I was wishing
> for something similar to the CSV data set config element, except that would
> allow each thread to have its own pointer.  No such thing exists.  I was

But it could be created ;-)

> told beanshell would be a good solution to this.  Since I'm still learning
> beanshell, I haven't gotten back to that point in my design yet, but I
> currently intend to read the entire file into memory at startup and then it
> can be randomly accessed.  I need more of a hashtable than a CSV data set
> anyways.  I suspect, however, that because each thread has it's own instance

This depends on the BeanShell element.
Samplers are cloned per thread, but functions are shared between threads.
I'm fairly sure that Config elements are shared. Not sure off-hand
about Pre- and Post- processors or the Listener.

Easy enough to check in Beanshell - just use the system hash function on "this".

> of the beanshell interpreter, it will load a copy of the file for each
> thread - the only advantage of loading into memory (aside from lookup speed)
> is that it will prevent file locking problems between threads (if there
> would be any).  Good luck.
>
> Ryan (aka Yanroy)
> --
> View this message in context: http://www.nabble.com/Problem-with-CSVRead-and-multithread-tf2033541.html#a5598922
> Sent from the JMeter - User forum at Nabble.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: Problem with CSVRead and multithread

Posted by Yanroy <rm...@wpi.edu>.
Mart,
It seems you're having almost exactly the same problem I am!  I was wishing
for something similar to the CSV data set config element, except that would
allow each thread to have its own pointer.  No such thing exists.  I was
told beanshell would be a good solution to this.  Since I'm still learning
beanshell, I haven't gotten back to that point in my design yet, but I
currently intend to read the entire file into memory at startup and then it
can be randomly accessed.  I need more of a hashtable than a CSV data set
anyways.  I suspect, however, that because each thread has it's own instance
of the beanshell interpreter, it will load a copy of the file for each
thread - the only advantage of loading into memory (aside from lookup speed)
is that it will prevent file locking problems between threads (if there
would be any).  Good luck.

Ryan (aka Yanroy)
-- 
View this message in context: http://www.nabble.com/Problem-with-CSVRead-and-multithread-tf2033541.html#a5598922
Sent from the JMeter - User forum at Nabble.com.


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


Re: Problem with CSVRead and multithread

Posted by sebb <se...@gmail.com>.
On 01 Aug 2006 15:25:57 +0200, mart@interia.pl <ma...@interia.pl> wrote:
> Hello,
>
> I've encountered a non-trivial problem I cannot solve - how to open many times the same file (each
> in separate thread) or - how to manage file pointer for one opened file for each
> thread separately?
>
> Here is a short description of my application:
>
> It's a bot created to perform tests. Bot is created based on jmeter. The structure
> of test is simple:
> - each test plan (scenario) consists of sequence of test modules.
> - each module represents a bit of test (e.g. - loading a single webpage)
> Both - scenarios and modules have unique IDs. Scenario is defines as sequence of
> modules' IDs, module - as java codes (Beanshell samplers).
>
> While running a test user has to enter at least a scenario ID. Bot reads (CSVRead)
> line of definition of scenario (module IDs), and then loads (BeanShell sampler) and
> runs the appropriate module. Module returns at end status of operation, that
> determinates the following operations (return with Err or continue to the happy
> end).
>
> As long as I run one-thread tests all seems to be working properly. The problem
> begins in case of number of threads. CSVRead allows to manage file pointers in each
> thread independently but - here is the catch - each time I load value from CSV in
> new thread - I'm given not the first value from file, but the next to previously
> read by another thread. So - I cannot operate on the same whole file with number of
> threads.

Did you remember to add a next() command?

> I've tried to use *ALIAS statement, but it doesn't work for me. There are no
> examples of *ALIAS in manual nor in mailing lists.
>
> I've tried also CSV Data Set Config and StringFromFile either - but both of them are
> unusual in this context.

CSV Data Set  is the preferred way to read from a file.

> Perhaps is there any undocumented function of CSVRead allowing to fetch the value in
> next thread from the very beginning of file?
>
> Can anybody help me? Any suggestions are welcome.
>

Use CSV Data Set instead.

> Greetings,
>
> mart
>
>
> ------------------------------------------------------------------------
> Szybko i tanio ubezpiecz samochod!
> Kupno polisy zajmie Ci 15 minut! Kontakt przez telefon albo Internet.
> Kliknij i sprawdz: http://link.interia.pl/f198b
>
>
> ---------------------------------------------------------------------
> 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