jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Abts <josh.a...@vistracks.com>
Subject Re: Shared variable among threads in single group
Date Fri, 10 Dec 2010 01:03:50 GMT
No, they should not have the same timestamp.  That is the problem, basically
the coordinates in the CSV are organized in a "route" so the timestamps have
to be successive or the route will be out of order.  Essentially this will
test a route over and over with time constantly moving forward (no repeated
time stamps, but repeated coordinates).  A further description:

Thread 1
1, 2, 2010-12-9T11:15:00
3, 4, 2010-12-9T11:15:10
5, 6, 2010-12-9T11:15:30

Thread 2
1, 2, 2010-12-9T11:15:20
3, 4, 2010-12-9T11:15:40
5, 6, 2010-12-9T11:15:50

This would be acceptable.  It would also be nice if the time was
configurable (could specify a starting time and the amount by which each
successive entry should increment, but that wouldn't be necessary.

Thanks again Deepak!

On Thu, Dec 9, 2010 at 6:53 PM, Deepak Shetty <shettyd@gmail.com> wrote:

> hi
> so why not use a timestamp (different threads may have same values , is
> this
> allowed?)
> http://jakarta.apache.org/jmeter/usermanual/functions.html#__time
> again we can help you write a shared incrementing counter , the only
> question is do you really need it or whether there are simpler ways.
> regards
> deepak
>
>
> On Thu, Dec 9, 2010 at 4:47 PM, Josh Abts <josh.abts@vistracks.com> wrote:
>
> > 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 <shettyd@gmail.com> 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 <josh.abts@vistracks.com>
> > 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
> > > >
> > >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message