You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by "Konstantin S." <mk...@gmail.com> on 2011/05/31 17:07:42 UTC

response assertion: using multiple patterns

hello all

say, i am checking Jmeter variable in response assertion. for example the
value is 89.
also I have number of variables with values 89,90,91,92,93

what i need to check is that variable with value 92 is found in
(89,90,91,92,93)

so how do i specify OR condition in test pattern?

I tried everything :(

for example

${aaa_g1} || ${bbb_g1}

Assertion failure message: Test failed: variable(utag1) expected to match
/92 || 93/

${aaa_g1}
${bbb_g1}
Assertion failure message: Test failed: variable(utag1) expected to match
/92
93/

It works for one on one check. But if I want to check a couple of
variable... What would be a correct OR operator

thanks

Re: response assertion: using multiple patterns

Posted by "Konstantin S." <mk...@gmail.com>.
You are saying this as a vivid BeanShell lover :) or you are 100% sure that
there is no other way?
I've been thinking about BeanShell, but so far it looks like studying
another programing language. Might as well learn Java and write the whole
test on Java )

On Tue, May 31, 2011 at 6:27 PM, Deepak Shetty <sh...@gmail.com> wrote:

> Beanshell assertion should work. You have to code it!
>  On May 31, 2011 8:20 AM, "Konstantin S." <mk...@gmail.com> wrote:
> >> Add another response assertion?
> >>
> >> That will fail other assertions and i dont' want that
> >
> > you see I have a variable
> >
> > tag1 = 89
> >
> > and 5 variables with parsed tags, for example
> > ${aaa_g1} = 89
> > ${bbb_g1} = 90
> > ${ccc_g1} = 91
> > ${ddd_g1} = 92
> > ${eee_g1} = 93
> >
> > what i need is a equivalent of SQL... where tag1 in ('89', '90',
> > '91','92','93')
> >
> > this will give me straight forward result. if tag1 is not found in this
> > collection,array or wahtever you will call it then test failes. if it is
> > found in any of his then success.
> > adding 5 assertions gives me 4 fails and 1 success or 1 fail 4 sucess if
> i
> > invert the rules with "Not"
>

Re: response assertion: using multiple patterns

Posted by Deepak Shetty <sh...@gmail.com>.
Beanshell assertion should work. You have to code it!
 On May 31, 2011 8:20 AM, "Konstantin S." <mk...@gmail.com> wrote:
>> Add another response assertion?
>>
>> That will fail other assertions and i dont' want that
>
> you see I have a variable
>
> tag1 = 89
>
> and 5 variables with parsed tags, for example
> ${aaa_g1} = 89
> ${bbb_g1} = 90
> ${ccc_g1} = 91
> ${ddd_g1} = 92
> ${eee_g1} = 93
>
> what i need is a equivalent of SQL... where tag1 in ('89', '90',
> '91','92','93')
>
> this will give me straight forward result. if tag1 is not found in this
> collection,array or wahtever you will call it then test failes. if it is
> found in any of his then success.
> adding 5 assertions gives me 4 fails and 1 success or 1 fail 4 sucess if i
> invert the rules with "Not"

Re: response assertion: using multiple patterns

Posted by sebb <se...@gmail.com>.
On 31 May 2011 18:32, Bruce Ide <fl...@gmail.com> wrote:
> I have the same problem, I'm always jumping for a BSF sampler or writing my
> own jmeter plugin. The BSF sampler is pretty low-impact, but I need to go
> digging around for simpler solutions before reaching for the Java.
> Ironically the simpler solutions are usually harder to find because everyone
> thinks they're so simple that examples aren't documented.

Documentation patches welcome ...

> --
> Bruce Ide
> FlyingRhenquest@gmail.com
>

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


Re: response assertion: using multiple patterns

Posted by Bruce Ide <fl...@gmail.com>.
I have the same problem, I'm always jumping for a BSF sampler or writing my
own jmeter plugin. The BSF sampler is pretty low-impact, but I need to go
digging around for simpler solutions before reaching for the Java.
Ironically the simpler solutions are usually harder to find because everyone
thinks they're so simple that examples aren't documented.

-- 
Bruce Ide
FlyingRhenquest@gmail.com

Re: response assertion: using multiple patterns

Posted by Deepak Shetty <sh...@gmail.com>.
Damn! was wondering how to concatenate the string without code and missed
the obvious.

On Tue, May 31, 2011 at 8:51 AM, sebb <se...@gmail.com> wrote:

> On 31 May 2011 16:20, Konstantin S. <mk...@gmail.com> wrote:
> >> Add another response assertion?
> >>
> >> That will fail other assertions and i dont' want that
> >
> > you see  I have a variable
> >
> > tag1 = 89
> >
> > and 5 variables with parsed tags, for example
> > ${aaa_g1} = 89
> > ${bbb_g1}  = 90
> > ${ccc_g1}  = 91
> > ${ddd_g1}  = 92
> > ${eee_g1}  = 93
> >
> > what i need is a equivalent  of SQL...  where tag1 in ('89', '90',
> > '91','92','93')
>
> That is easy in the Response Assertion:
>
> Variable name: tag1
> Regex: 89|90|91|92|93
>
> > this will give me straight forward result. if tag1 is not found in this
> > collection,array or wahtever you will call it then test failes. if it is
> > found in any of his then success.
> > adding 5 assertions gives me 4 fails and 1 success or 1 fail 4 sucess if
> i
> > invert the rules with "Not"
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: response assertion: using multiple patterns

Posted by pavelz <za...@gmail.com>.
Hey Konstantin, I have the same issue right now, can you please tell me where
did you state the {aaa_g1} variables? Did you insert them in the Patterns to
Test input field?
Thanks in advance! Pavel

--
View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5713435.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: response assertion: using multiple patterns

Posted by "Konstantin S." <mk...@gmail.com>.
>
> what i need is a equivalent  of SQL...  where tag1 in ('89', '90',
> '91','92','93')

That is easy in the Response Assertion:
>
> Variable name: tag1
> Regex: 89|90|91|92|93
>
>
>

Heck yeah! Sebb, thank you very much!!! It works instead of || that I tried.
Works with variables too
${aaa_g1}|${bbb_g1}|${ccc_g1}|${ddd_g1}|${eee_g1}

Just what I expected: some silly nuance in using operators.

Re: response assertion: using multiple patterns

Posted by sebb <se...@gmail.com>.
On 24 April 2014 20:24, mpistella <mp...@kingsisle.com> wrote:
> sebb-2-2 wrote
>> On 24 April 2014 19:11, mpistella &lt;
>
>> mpistella@
>
>> &gt; wrote:
>>> cthoong wrote
>>>> Thought can't do "OR" condition in assertion, now only found out just
>>>> add
>>>> " | " between 2 set of value in 1 "Patterns to Test" instead of 2
>>>> Patterns.
>>>
>>> You actually must add two of the "or" vertical lines like so: "||"
>>> between
>>> 2 sets of values in only one "Patterns to Test"
>>
>> I don't think that is correct.
>> A single vertical bar is the standard meta character used to separate
>> alternates.
>
> Java, Javascript, and Beanshell all use "||" as the standard "or" operator.

That is for code, not regexes.
Java/Beanshell also use | for bitwise logical OR

> So I am assuming jmeter uses this standard as well. Couldn't find anything
> in the help file confirming this though.

JMeter uses Perl-style regexes which use | for alternation.

>
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719885.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

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


Re: response assertion: using multiple patterns

Posted by mpistella <mp...@kingsisle.com>.
sebb-2-2 wrote
> On 24 April 2014 19:11, mpistella &lt;

> mpistella@

> &gt; wrote:
>> cthoong wrote
>>> Thought can't do "OR" condition in assertion, now only found out just
>>> add
>>> " | " between 2 set of value in 1 "Patterns to Test" instead of 2
>>> Patterns.
>>
>> You actually must add two of the "or" vertical lines like so: "||" 
>> between
>> 2 sets of values in only one "Patterns to Test"
> 
> I don't think that is correct.
> A single vertical bar is the standard meta character used to separate
> alternates.

Java, Javascript, and Beanshell all use "||" as the standard "or" operator.
So I am assuming jmeter uses this standard as well. Couldn't find anything
in the help file confirming this though.




--
View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719885.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: response assertion: using multiple patterns

Posted by sebb <se...@gmail.com>.
On 24 April 2014 21:26, mpistella <mp...@kingsisle.com> wrote:
> sebb-2-2 wrote
>> On 24 April 2014 20:13, mpistella &lt;
>
>> mpistella@
>
>> &gt; wrote:
>>
>> Then there's something else wrong.
>>
>> Two adjacent "|" chars will match everything if using "Contains" and
>> the empty string if using "Matches"
>
> Aha! you are correct!
>
> I had it set to "contains" so it was just accepting everything.

It's always worth checking for both match and non-match.
The Java Sampler can be very useful for this, as it allows one to
return arbitrary strings in the response data.

> Regards
>
>
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719888.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

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


Re: response assertion: using multiple patterns

Posted by mpistella <mp...@kingsisle.com>.
sebb-2-2 wrote
> On 24 April 2014 20:13, mpistella &lt;

> mpistella@

> &gt; wrote:
> 
> Then there's something else wrong.
> 
> Two adjacent "|" chars will match everything if using "Contains" and
> the empty string if using "Matches"

Aha! you are correct! 

I had it set to "contains" so it was just accepting everything. 

Regards




--
View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719888.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: response assertion: using multiple patterns

Posted by sebb <se...@gmail.com>.
On 24 April 2014 20:13, mpistella <mp...@kingsisle.com> wrote:
> sebb-2-2 wrote
>> On 24 April 2014 19:11, mpistella &lt;
>
>> mpistella@
>
>> &gt; wrote:
>>> cthoong wrote
>>>> Thought can't do "OR" condition in assertion, now only found out just
>>>> add
>>>> " | " between 2 set of value in 1 "Patterns to Test" instead of 2
>>>> Patterns.
>>>
>>> You actually must add two of the "or" vertical lines like so: "||"
>>> between
>>> 2 sets of values in only one "Patterns to Test"
>>
>> I don't think that is correct.
>> A single vertical bar is the standard meta character used to separate
>> alternates.
>
> I do agree that it is the standard but for some reason when I only had one
> "|" it just treated it as one single pattern. When I added the second "|" it
> treated it as two patterns.
>
> This is what I have as my pattern to test and it is working right now:
> {"result":"ERROR"} || {"result":"FAIL"}
>

Then there's something else wrong.

Two adjacent "|" chars will match everything if using "Contains" and
the empty string if using "Matches"

>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719884.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

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


Re: response assertion: using multiple patterns

Posted by mpistella <mp...@kingsisle.com>.
sebb-2-2 wrote
> On 24 April 2014 19:11, mpistella &lt;

> mpistella@

> &gt; wrote:
>> cthoong wrote
>>> Thought can't do "OR" condition in assertion, now only found out just
>>> add
>>> " | " between 2 set of value in 1 "Patterns to Test" instead of 2
>>> Patterns.
>>
>> You actually must add two of the "or" vertical lines like so: "||" 
>> between
>> 2 sets of values in only one "Patterns to Test"
> 
> I don't think that is correct.
> A single vertical bar is the standard meta character used to separate
> alternates.

I do agree that it is the standard but for some reason when I only had one
"|" it just treated it as one single pattern. When I added the second "|" it
treated it as two patterns.

This is what I have as my pattern to test and it is working right now:
{"result":"ERROR"} || {"result":"FAIL"}




--
View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719884.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: response assertion: using multiple patterns

Posted by sebb <se...@gmail.com>.
On 24 April 2014 19:11, mpistella <mp...@kingsisle.com> wrote:
> cthoong wrote
>> Thought can't do "OR" condition in assertion, now only found out just add
>> " | " between 2 set of value in 1 "Patterns to Test" instead of 2
>> Patterns.
>
> You actually must add two of the "or" vertical lines like so: "||"  between
> 2 sets of values in only one "Patterns to Test"

I don't think that is correct.
A single vertical bar is the standard meta character used to separate
alternates.

>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719882.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

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


Re: response assertion: using multiple patterns

Posted by mpistella <mp...@kingsisle.com>.
cthoong wrote
> Thought can't do "OR" condition in assertion, now only found out just add
> " | " between 2 set of value in 1 "Patterns to Test" instead of 2
> Patterns.

You actually must add two of the "or" vertical lines like so: "||"  between
2 sets of values in only one "Patterns to Test"



--
View this message in context: http://jmeter.512774.n5.nabble.com/response-assertion-using-multiple-patterns-tp4442287p5719882.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: response assertion: using multiple patterns

Posted by sebb <se...@gmail.com>.
On 31 May 2011 16:20, Konstantin S. <mk...@gmail.com> wrote:
>> Add another response assertion?
>>
>> That will fail other assertions and i dont' want that
>
> you see  I have a variable
>
> tag1 = 89
>
> and 5 variables with parsed tags, for example
> ${aaa_g1} = 89
> ${bbb_g1}  = 90
> ${ccc_g1}  = 91
> ${ddd_g1}  = 92
> ${eee_g1}  = 93
>
> what i need is a equivalent  of SQL...  where tag1 in ('89', '90',
> '91','92','93')

That is easy in the Response Assertion:

Variable name: tag1
Regex: 89|90|91|92|93

> this will give me straight forward result. if tag1 is not found in this
> collection,array or wahtever you will call it then test failes. if it is
> found in any of his then success.
> adding 5 assertions gives me 4 fails and 1 success or 1 fail 4 sucess if i
> invert the rules with "Not"
>

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


Re: response assertion: using multiple patterns

Posted by "Konstantin S." <mk...@gmail.com>.
> Add another response assertion?
>
> That will fail other assertions and i dont' want that

you see  I have a variable

tag1 = 89

and 5 variables with parsed tags, for example
${aaa_g1} = 89
${bbb_g1}  = 90
${ccc_g1}  = 91
${ddd_g1}  = 92
${eee_g1}  = 93

what i need is a equivalent  of SQL...  where tag1 in ('89', '90',
'91','92','93')

this will give me straight forward result. if tag1 is not found in this
collection,array or wahtever you will call it then test failes. if it is
found in any of his then success.
adding 5 assertions gives me 4 fails and 1 success or 1 fail 4 sucess if i
invert the rules with "Not"

Re: response assertion: using multiple patterns

Posted by Bruce Ide <fl...@gmail.com>.
Add another response assertion?

-- 
Bruce Ide
FlyingRhenquest@gmail.com