I am not exactly sure how to add a class to do this like you mentioned.
Still new to JMeter.
Basically what I am trying to do is I have a list of coordinates in a CSV.
Each HTTP request contains a pair of coordinates (from the CSV) and then a
timestamp. But the timestamp should be increasing by some value
continuously (persisting throughout runs). As a very simple example, assume
the csv contains 3 pairs of values {1,2; 3,4; 5,6} The requests would look
something like this:
http://myurl/?a=1&b=2&c=2010-12-9T11:15:00
http://myurl/?a=3&b=4&c=2010-12-9T11:15:10
http://myurl/?a=5&b=6&c=2010-12-9T11:15:20
http://myurl/?a=1&b=2&c=2010-12-9T11:15:30
...etc.
So we can't easily add values into the CSV because we want the time to
continuously count up say if we had 200 threads in a forever loop for 5
minutes. Between runs it is fine if the time resets, but there should be
persistence among threads and loops.
I was able to get the CSV to loop properly, its just the time persistence
that is the issue.
Any ideas, samples/pointers?
Thanks for the help!
Josh
On Thu, Dec 9, 2010 at 4:59 PM, Deepak Shetty <[email protected]> wrote:
> Hi
> variables arent shared across threads (even in the same thread group)
> Properties are shared , but when you use multiple threads then you need
> some
> way to synchronize access so that only one thread increments the counter at
> any one time. You could do this with Beanshell , but possibly it will be
> simpler to write a java class that holds a static counter that increments
> synchronously and just call it in a beanshell function to give you your
> number (avoids having the sampler in your results).
>
> However the first question to ask is why do you need actually this ? or do
> you know how many numbers you need in advance (or a maximum) ? if you do
> then you can just generate a CSV file before you run your test(as part of
> your ant build or as a separate threadgroup or something) that has the
> numbers and use a CSV data set config (you can choose the sharing mode
> option that says all threads or current thread group)
>
> regards
> deepak
>
> On Thu, Dec 9, 2010 at 2:50 PM, Josh Abts <[email protected]> wrote:
>
> > Hello all,
> >
> > So I am a little confused with how variables are working in a single
> Thread
> > Group.
> >
> > I have attached a "User Defined Variables" config element to my thread
> > group. From there I setup a HTTP Request sampler under the thread group.
> > I
> > also under the thread group have a BeanShell Sampler with a script that
> > basically acts as a special counter to modify the User defined variables
> > that are used in the Http request.
> >
> > But when I run the test using say 3 threads and 1 loop, it only makes 3
> > http
> > requests using the same value of the variable (the initial). If I run it
> > with 1 thread and 3 loops, it works as intended, giving 3 different
> values
> > properly incremented by the BeanShell sampler.
> >
> > In reading I ran across something that mentioned using JMeter Properties
> to
> > share values between threads. But even with that I am still not able to
> > get
> > it to properly use the values.
> >
> > What is the proper/best way to have a shared value among all the threads
> so
> > that it increments properly? And is a BeanShell sampler the proper way
> to
> > ensure it increments properly? I am using a CSV data set config for the
> > http request for two variables in it. So essentially the CSV has a
> static
> > list of values that is looped through but the counter should keep going
> up
> > independently of that and just tags those values.
> >
> > My test hierarchy looks as such:
> >
> > Test plan
> > |- Thread Group
> > |- Http Request
> > |-Simple Data Writer
> > |- BeanShell Sampler
> > |- User Defined Variables
> >
> > Hopefully that is clear enough, if not, let me know I can provide any
> > additional details/samples.
> >
> > Thanks!
> >
> > --
> > Joshua Abts
> >
>
--
Joshua Abts
IT Specialist
VisTracks, Inc.
[email protected]
(630) 596-5426