On 10 February 2012 17:09, Eric Olson <[email protected]> wrote:
> It's alright if two threads share a token, in fact it's probably preferable
> for that to be part of my test since I'd expect to see that from real users.

If you say so - seems odd to me.
How can you tell the sessions apart?

Would a real user login to the service through two separate browsers at once?

> I still don't see how I can write to a CSV, however.  I was able to get it
> to write 1 CSV file per token, but I'm not really interested in having my
> folder get filled up with numbered csv files.  I was hoping to have it all
> in one CSV.

Use RE extractor (or similar) to put the token in a fixed named
variable, and save it to the CSV file:

http://jakarta.apache.org/jmeter/usermanual/listeners.html#sample_variables

You can configure the listener to skip just about everything else in
the sample result.

You may need to run this as a separate test in order to ensure that
the file is closed.

> As for sharing within a thread, this still isn't working for me, so I guess
> that's what I need help with.  Here's how my setup looks.
>
> ThreadGroup
> -BSF PreProcessor or Sampler (javascript) -> var myArray = new Array();
> vars.putObject("myArray",myArray);
> -Loop Controller -> 5 loops
> --HTTP Sampler
> ---Regex postprocessor -> Reference Name = myToken
> ---BSF postprocessor - > var myArray = vars.getOject("myArray");
> myArray.push(myToken);  vars.putObject("myArray",myArray);
> -BSF Sampler -> var myArray = vars.getObject("myArray");  //At this point,
> I expect myArray.length to be 5.  Instead it is 0.

BSF interpreters are not shared between samplers (or threads), but
they should be able to see a variable created earlier in the same
thread.

> Right now I'm taking the approach of serializing into a comma
> delimitted string and storing it in props, but that just feels wrong to me.

OK to use properties if you want to share read-only information across
threads; props are not really suitable for frequently updated values.

> Sebb, when you say "iteratively create a jmeter array", what do you mean?

Not guilty.

> Is there some other data structure that I'm completely missing?  I thought
> the only way you could get a jmeter array was if your single regular
> expression returned multiple matching groups...

That does not generate an array; just lots of variables with numeric suffixes.

> rather than having multiple
> runs of a thread or a loop add on to an existing array.  If there's some
> way to do that, I would love to know.

Use a pre-populated CSV data set.

> -Eric
> On Fri, Feb 10, 2012 at 8:50 AM, sebb <[email protected]> wrote:
>
>> On 10 February 2012 16:26, Bruce Ide <[email protected]> wrote:
>> > In the same thread you can use vars.putObject in a bsf or beanshell
>> sampler
>> > to store an array in a variable. Or you can just iteratively create a
>> > jmeter array.
>> >
>> > I wrote an addon to allow sharing across threads, see
>> > https://github.com/FlyingRhenquest/JmeterThreadGlobal. It's a pretty
>> simple
>> > addon and isn't currently set up to share arbitrary objects, but it
>> should
>> > be easy to modify to do that.
>> >
>> > If you used the new setup things you shouldn't have to synchronize
>> between
>> > the threads. If it turns out you need to, you can use a synchronizing
>> timer
>> > or my thread synchronization sampler (Which is also on github.)
>> >
>> > All this does add quite a bit of complexity to the test though, so if
>> > you're ever going to need to explain it to another tester you might want
>> to
>> > simplify your test design.
>>
>> Very good point.
>>
>> Why not create CSV data files containing the tokens in a separate test
>> phase?
>> You can then randomise the data file if you want.
>>
>> By the way, you say each thread picks a random token.
>> If you have multiple threads, a simple random choice will sometimes
>> result in two threads having the same token.
>> Is that allowed? If not, the token entries will have to be marked as
>> used; this will necessarily entail synchronising across threads.
>>
>> The CSV data file can be set to only be used once; threads cannot then
>> get the same token (unless it is duplicated in the file).
>>
>> If you have hundreds or thousands of tokens, using a data file is the way
>> to go.
>>
>> > --
>> > Bruce Ide
>> > [email protected]
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to