You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Nicola Ambrosetti Brolin <am...@gmail.com> on 2013/10/02 10:11:45 UTC

Comparing results from two samplers in JMeter

I have several samplers in a thread group, each retrieving a piece of
information. I then need to validate the consistency of the results from
two (or more) different samplers. In particular I need to assert whether a
field in one sampler response equals a field in the JDBC response. What is
the best way to do something like that?

I have thought about adding a beanshell postprocessor to each sampler in
order to extract the field value from each sample and save it in two
variables and then adding a beanshell assertion that accesses those
variables, but I wonder if there is a more direct approach.

In the JMeter API documentation I could not see anything to access another
sampler response other than the previous one.


Any thoughts?

Nicola

Re: Comparing results from two samplers in JMeter

Posted by Sergio Boso <se...@bosoconsulting.it>.
Non knowing much about your application, and its complexity,
I would extract the value from the first sample (using regular expression),
and the use it on the second sampler (you can use regex also inside assertions, if needed)
using response assertion.

Your solution is more complicate, it may be useful when regex are not suitable.

HTH
Sergio


Il 02/10/2013 10.11, Nicola Ambrosetti Brolin ha scritto:
> I have several samplers in a thread group, each retrieving a piece of
> information. I then need to validate the consistency of the results from
> two (or more) different samplers. In particular I need to assert whether a
> field in one sampler response equals a field in the JDBC response. What is
> the best way to do something like that?
>
> I have thought about adding a beanshell postprocessor to each sampler in
> order to extract the field value from each sample and save it in two
> variables and then adding a beanshell assertion that accesses those
> variables, but I wonder if there is a more direct approach.
>
> In the JMeter API documentation I could not see anything to access another
> sampler response other than the previous one.
>
>
> Any thoughts?
>
> Nicola
>


-- 

Ing. Sergio Boso




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


Re: Comparing results from two samplers in JMeter

Posted by sebb <se...@gmail.com>.
On 3 October 2013 07:10, Nicola Ambrosetti Brolin
<am...@gmail.com> wrote:
> On 3 October 2013 00:03, sebb <se...@gmail.com> wrote:
>
>>
>> Use Regex Post-Processor to extract the information and store it in
>> variables, one for each sample.
>>
>> Then use Response Assertion to compare the JMeter variables against each
>> other.
>> Provide one variable using the variable name, and the other as the
>> text to match using the ${varname} syntax.
>>
>
> That's more or less how I did it in the end. Still I feel a little
> frustrated by the impossibility to programmatically "navigate" through the
> sampler responses like you can do in the gui with the View Results Tree,
> for example. In soapUI you can access any test step programmatically and
> even configure it or rerun it, from any other test step (though that might
> not be a good idea with maintainability and readability in mind).

Access to arbitrary sample responses would require keeping them in memory.

> In Jmeter
> it seems that to configure a sampler programmatically all one can do is set
> a variable (for example in a preprocessor) which then is evaluated with the
> ${variable} notation inside the corresponding field. However this cannot be
> done for checkboxes, option boxes, drop-downs, etc.

One could use a scripting pre-processor to set the properties that are
used to save the values of the GUI fields.
Many sampler fields have setters; those that don't can be set using
the appropriate property name.

> I suspect that most of these restrictions are heritage of the fact that
> Jmeter is (correct me if I'm wrong) first and foremost a performance and
> load testing tool, where scripting (which is typically much slower) should
> be reduced to a minimum.

Perhaps.

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


Re: Comparing results from two samplers in JMeter

Posted by Deepak Shetty <sh...@gmail.com>.
>That's more or less how I did it in the end. Still I feel a little
frustrated by the impossibility to programmatically "navigate" through the
sampler responses like you can do in the gui with the View Results Tree,
for example.
Create a (for e.g. beanshell) listener and store the responses wherever you
want in whatever format you want that allows you the navigation you need


On Wed, Oct 2, 2013 at 11:10 PM, Nicola Ambrosetti Brolin <
ambrosetti.nicola@gmail.com> wrote:

> On 3 October 2013 00:03, sebb <se...@gmail.com> wrote:
>
> >
> > Use Regex Post-Processor to extract the information and store it in
> > variables, one for each sample.
> >
> > Then use Response Assertion to compare the JMeter variables against each
> > other.
> > Provide one variable using the variable name, and the other as the
> > text to match using the ${varname} syntax.
> >
>
> That's more or less how I did it in the end. Still I feel a little
> frustrated by the impossibility to programmatically "navigate" through the
> sampler responses like you can do in the gui with the View Results Tree,
> for example. In soapUI you can access any test step programmatically and
> even configure it or rerun it, from any other test step (though that might
> not be a good idea with maintainability and readability in mind). In Jmeter
> it seems that to configure a sampler programmatically all one can do is set
> a variable (for example in a preprocessor) which then is evaluated with the
> ${variable} notation inside the corresponding field. However this cannot be
> done for checkboxes, option boxes, drop-downs, etc.
>
> I suspect that most of these restrictions are heritage of the fact that
> Jmeter is (correct me if I'm wrong) first and foremost a performance and
> load testing tool, where scripting (which is typically much slower) should
> be reduced to a minimum.
>

Re: Comparing results from two samplers in JMeter

Posted by Nicola Ambrosetti Brolin <am...@gmail.com>.
On 3 October 2013 00:03, sebb <se...@gmail.com> wrote:

>
> Use Regex Post-Processor to extract the information and store it in
> variables, one for each sample.
>
> Then use Response Assertion to compare the JMeter variables against each
> other.
> Provide one variable using the variable name, and the other as the
> text to match using the ${varname} syntax.
>

That's more or less how I did it in the end. Still I feel a little
frustrated by the impossibility to programmatically "navigate" through the
sampler responses like you can do in the gui with the View Results Tree,
for example. In soapUI you can access any test step programmatically and
even configure it or rerun it, from any other test step (though that might
not be a good idea with maintainability and readability in mind). In Jmeter
it seems that to configure a sampler programmatically all one can do is set
a variable (for example in a preprocessor) which then is evaluated with the
${variable} notation inside the corresponding field. However this cannot be
done for checkboxes, option boxes, drop-downs, etc.

I suspect that most of these restrictions are heritage of the fact that
Jmeter is (correct me if I'm wrong) first and foremost a performance and
load testing tool, where scripting (which is typically much slower) should
be reduced to a minimum.

Re: Comparing results from two samplers in JMeter

Posted by sebb <se...@gmail.com>.
On 2 October 2013 09:11, Nicola Ambrosetti Brolin
<am...@gmail.com> wrote:
> I have several samplers in a thread group, each retrieving a piece of
> information. I then need to validate the consistency of the results from
> two (or more) different samplers. In particular I need to assert whether a
> field in one sampler response equals a field in the JDBC response. What is
> the best way to do something like that?

Use Regex Post-Processor to extract the information and store it in
variables, one for each sample.

Then use Response Assertion to compare the JMeter variables against each other.
Provide one variable using the variable name, and the other as the
text to match using the ${varname} syntax.

> I have thought about adding a beanshell postprocessor to each sampler in
> order to extract the field value from each sample and save it in two
> variables and then adding a beanshell assertion that accesses those
> variables, but I wonder if there is a more direct approach.

See above.

> In the JMeter API documentation I could not see anything to access another
> sampler response other than the previous one.

You cannot do so.

>
> Any thoughts?
>
> Nicola

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