jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Simonov <au...@bk.ru>
Subject Re: JDBC Response Assertion
Date Mon, 17 Aug 2009 14:02:12 GMT

Solution found:

if (Integer.parseInt(vars.get("AA_1")) < 30) {
Failure=true;
}

- vars.get
- if condition in brackets
- actions in brackets
- if starts with lowercase letters
- ";" after condition
- Integer.parseInt
- parseInt with lowercase at start

Why weren't you able to tell me this 3 hours ago??..

I'm happy it works, but it's so simple and I'm not a JMeter specialist, so I
regret a DAY wasted on this simple thing - just to evaluate a variable from
SQL response.


Andrey Simonov wrote:
> 
> If it returns a string, why is an error message about objects?
> 
> Why can't I compare two strings?
> 
> How do I convert string to int or compare strings?
> 
> I could not find this in internet in 10 mins.
> 
> 
> sebb-2-2 wrote:
>> 
>> On 17/08/2009, Andrey Simonov <aurum@bk.ru> wrote:
>>>
>>>  We have already found this.
>>>
>>>  If (vars.get("AA_1") < 30) {Failure=true }
>>>
>> 
>> OK, so you have made some progress.
>> 
>>>  Assertion failure message: org.apache.jorphan.util.JMeterException:
>>> Error
>>>
>>> invoking bsh method: eval       Sourced file: inline evaluation of: ``If
>>>  (vars.get("AA_1") < "30") {Failure=true };'' : Operator: '"<"'
>>> inappropriate
>>>  for objects.
>>>
>>>  However vars.get is supposed to return not objects, but variable
>>> values. You
>>>  can find it in help.
>> 
>> Yes, it does return the variable value; however that is a String.
>> 
>> So the condition is effectively something like:
>> 
>> ("7" < "30")
>> 
>> which - as the error message says - is not valid in BeanShell
>> 
>>>  I think you really have never done assertion like this :)
>>>
>>>  You are wasting your time and mine, too.
>>>
>>>  sebb, please, either stop answering or give me a working example.
>>>
>>>  sebb-2-2 wrote:
>>>  >
>>>  > On 17/08/2009, Andrey Simonov <aurum@bk.ru> wrote:
>>>  >>
>>>  >>  > http://jakarta.apache.org/jmeter/demos/BeanShellAssertion.bsh
>>>  >>
>>>  >>
>>>  >> sebb, you are very stubborn and you don't want to understand what I
>>> am
>>>  >>  asking.
>>>  >
>>>  > I am trying to answer your questions.
>>>  >
>>>  >>  You have sent me links to help 3 times (!), but unfortunately you
>>> are
>>>  >> the
>>>  >>  only one who is answering me.
>>>  >>
>>>  >>  I'll try to be maximum specific, so that you will be not able to
>>> send me
>>>  >> the
>>>  >>  link to help for the 4th time.
>>>  >>
>>>  >>  I make a JDBC request, which results in a following output:
>>>  >>  Count(*)
>>>  >>  28
>>>  >>
>>>  >>  The output is assigned to a variable: AA.
>>>  >>
>>>  >>  Then as a child to this request, I create a BeanShell Assertion,
>>> which
>>>  >>  reads:
>>>  >>
>>>  >>  If vars.get("AA_1") < 30 Then {
>>>  >>  Failure=true }
>>>  >>
>>>  >>  I get the following error:
>>>  >>
>>>  >>  Assertion failure message: org.apache.jorphan.util.JMeterException:
>>>  >> Error
>>>  >>  invoking bsh method: eval       Parse error at line 1, column 8.
>>>  >> Encountered: .
>>>  >>
>>>  >>  Why?
>>>  >>
>>>  >
>>>  > The phrase "Parse error" means that the code is not valid Java
>>> syntax.
>>>  >
>>>  > Compare your code with the following example from the link I
>>> provided:
>>>  >
>>>  >          if (arr != null && arr.length != 25218)
>>>  >          {
>>>  >              Failure= true ;
>>>  >              FailureMessage = "The response data size was not as
>>> expected"
>>>  > ;
>>>  >           }
>>>  >
>>>  > If you look carefully you will see that the general form of an "if"
>>>  > statement is:
>>>  >
>>>  > if (condition) {
>>>  > }
>>>  >
>>>  > Try fixing your code accordingly.
>>>  >
>>>  >>
>>>  >>
>>>  >>  sebb-2-2 wrote:
>>>  >>  >
>>>  >>  > On 17/08/2009, Andrey Simonov <aurum@bk.ru> wrote:
>>>  >>  >>
>>>  >>  >>  > I already explained how to generate a sample and how
to use
>>> BSH to
>>>  >>  >>  > generate an Assertion:
>>>  >>  >>
>>>  >>  >>
>>>  >>  >> No, you didn't. The reference to generic help you gave me
does
>>> not
>>>  >>  >> contain
>>>  >>  >>  this.
>>>  >>  >>
>>>  >>  >>  I need a sample BSF/BSH Assetion script that evaluates a
>>> variable,
>>>  >>  >> please.
>>>  >>  >
>>>  >>  > http://jakarta.apache.org/jmeter/demos/BeanShellAssertion.bsh
>>>  >>  >
>>>  >>  >>  Say, "If variable > 5 Then Failed, Else Passed"
>>>  >>  >>
>>>  >>  >>
>>>  >>  >>
>>>  >>  >> sebb-2-2 wrote:
>>>  >>  >>  >
>>>  >>  >>  > On 17/08/2009, Andrey Simonov <aurum@bk.ru> wrote:
>>>  >>  >>  >>
>>>  >>  >>  >>  sebb
>>>  >>  >>  >>
>>>  >>  >>  >>  You are not answering my question. You are confusing
me
>>> with
>>>  >> people
>>>  >>  >> who
>>>  >>  >>  >> do
>>>  >>  >>  >>  not read manuals before asking questions.
>>>  >>  >>  >>
>>>  >>  >>  >>  I have read all the help files and I did not find
an answer
>>> to
>>>  >> my
>>>  >>  >>  >> question!
>>>  >>  >>  >>
>>>  >>  >>  >>  Could you please be more specific in your answers,
in case
>>> you
>>>  >>  >> really
>>>  >>  >>  >> know
>>>  >>  >>  >>  how this assertion works, of course.
>>>  >>  >>  >>
>>>  >>  >>  >>  I need a sample BSF/BSH script that evaluates
a variable
>>> and
>>>  >> send a
>>>  >>  >>  >> message
>>>  >>  >>  >>  to some listener.
>>>  >>  >>  >
>>>  >>  >>  > As I wrote before, Listeners only process samples and
>>> Assertions;
>>>  >> I
>>>  >>  >>  > already explained how to generate a sample and how
to use BSH
>>> to
>>>  >>  >>  > generate an Assertion:
>>>  >>  >>  >
>>>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>  >>  >>  sebb-2-2 wrote:
>>>  >>  >>  >>  >
>>>  >>  >>  >>  > On 17/08/2009, Andrey Simonov <aurum@bk.ru>
wrote:
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  Yes, but please can you give me an example?
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  I have spent half a day of Friday trying
to do
>>> something
>>>  >> with
>>>  >>  >>  >> variables
>>>  >>  >>  >>  >> in
>>>  >>  >>  >>  >>  BSF and BSH assertions and listeners
and no luck!
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  All I need to do is to be able to evaluate
variable and
>>> send
>>>  >>  >> some
>>>  >>  >>  >>  >> message to
>>>  >>  >>  >>  >>  some listener :)
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  An example will be greatly appreciated.
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >
>>>  >>  >>  >>  > Read the following:
>>>  >>  >>  >>  >
>>>  >>  >>  >>  >
>>>  >>  >>  >>
>>>  >>  >>
>>>  >>
>>> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_Assertion
>>>  >>  >>  >>  >
>>>  >>  >>  >>  > It includes sample code.
>>>  >>  >>  >>  >
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >> sebb-2-2 wrote:
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  > On 17/08/2009, Andrey Simonov <aurum@bk.ru>
wrote:
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  That's not what I meant. I
meant is there an
>>> assertion
>>>  >> that
>>>  >>  >> can
>>>  >>  >>  >>  >>  >> conveniently
>>>  >>  >>  >>  >>  >>  parse SQL results?
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  E.g. my results are: table
headers and 4 values.
>>> How do
>>>  >> I
>>>  >>  >> check
>>>  >>  >>  >> that
>>>  >>  >>  >>  >>  >> e.g.
>>>  >>  >>  >>  >>  >>  "Average" is < 30?
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  > JDBC can save results as variables.
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  > The Size Assertion is similar to
what you want,
>>>  >> unfortunately
>>>  >>  >> it
>>>  >>  >>  >> only
>>>  >>  >>  >>  >>  > checks size... perhaps that should
be extended to
>>> check a
>>>  >>  >>  >> variable.
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  > Meanwhile, use a BSF or BSH Assertion
to check the
>>>  >> variable.
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  sebb-2-2 wrote:
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>  > On 17/08/2009, Andrey
Simonov <aurum@bk.ru>
>>> wrote:
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >>  Hi!
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >>  Is there any sort
of response assertion for
>>> JDBC
>>>  >>  >> requests?
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>  > All the Assertions can
be used with JDBC.
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>  >>  Or it's RegExp Extractor
only?
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >>  If there is a way
(maybe via BSF request),
>>> please
>>>  >>  >> provide an
>>>  >>  >>  >>  >> example
>>>  >>  >>  >>  >>  >> :)
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >> --
>>>  >>  >>  >>  >>  >>  >>  View this message
in context:
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>  >>
>>>  >>
>>> http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25002488.html
>>>  >>  >>  >>  >>  >>  >>  Sent from the JMeter
- User mailing list
>>> archive at
>>>  >>  >>  >> Nabble.com.
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  >>  >>  >>  >>  To unsubscribe,
e-mail:
>>>  >>  >>  >>  >> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  >>  >>  >>  >>  For additional commands,
e-mail:
>>>  >>  >>  >>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>
>>>  >>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  >>  >>  >>  > To unsubscribe, e-mail:
>>>  >>  >>  >> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  >>  >>  >>  > For additional commands,
e-mail:
>>>  >>  >>  >>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >> --
>>>  >>  >>  >>  >>  >>  View this message in context:
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>  >>
>>>  >>
>>> http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25005147.html
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >> Sent from the JMeter - User
mailing list archive at
>>>  >>  >> Nabble.com.
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>
>>>  >>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  >>  >>  >>  To unsubscribe, e-mail:
>>>  >>  >>  >> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  >>  >>  >>  For additional commands, e-mail:
>>>  >>  >>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>
>>>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  >>  >>  > To unsubscribe, e-mail:
>>>  >>  >> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  >>  >>  > For additional commands, e-mail:
>>>  >>  >>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>  >
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>  --
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >> View this message in context:
>>>  >>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>  >>
>>>  >>
>>> http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25005283.html
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >> Sent from the JMeter - User mailing list
archive at
>>>  >> Nabble.com.
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  >>  >>  To unsubscribe, e-mail:
>>>  >>  >> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  >>  >>  For additional commands, e-mail:
>>>  >>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >>
>>>  >>  >>  >>  >
>>>  >>  >>  >>  >
>>>  >>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  >>  > To unsubscribe, e-mail:
>>>  >> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  >>  > For additional commands, e-mail:
>>>  >>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >>  >
>>>  >>  >>  >>  >
>>>  >>  >>  >>  >
>>>  >>  >>  >>
>>>  >>  >>  >>  --
>>>  >>  >>  >>
>>>  >>  >>  >> View this message in context:
>>>  >>  >>  >>
>>>  >>  >>
>>>  >>
>>> http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25005482.html
>>>  >>  >>  >>
>>>  >>  >>  >> Sent from the JMeter - User mailing list archive
at
>>> Nabble.com.
>>>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  >>  To unsubscribe, e-mail:
>>>  >> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  >>  For additional commands, e-mail:
>>>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >>
>>>  >>  >>  >>
>>>  >>  >>  >
>>>  >>  >>  >
>>>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  > To unsubscribe, e-mail:
>>> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  > For additional commands, e-mail:
>>>  >> jmeter-user-help@jakarta.apache.org
>>>  >>  >>  >
>>>  >>  >>  >
>>>  >>  >>  >
>>>  >>  >>
>>>  >>  >>  --
>>>  >>  >>
>>>  >>  >> View this message in context:
>>>  >>  >>
>>>  >>
>>> http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25005738.html
>>>  >>  >>
>>>  >>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>>>  >>  >>
>>>  >>  >>
>>>  >>  >>
>>>  >>
>>> ---------------------------------------------------------------------
>>>  >>  >>  To unsubscribe, e-mail:
>>> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  >>  For additional commands, e-mail:
>>> jmeter-user-help@jakarta.apache.org
>>>  >>  >>
>>>  >>  >>
>>>  >>  >
>>>  >>  >
>>> ---------------------------------------------------------------------
>>>  >>  > To unsubscribe, e-mail:
>>> jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  > For additional commands, e-mail:
>>> jmeter-user-help@jakarta.apache.org
>>>  >>  >
>>>  >>  >
>>>  >>  >
>>>  >>
>>>  >>  --
>>>  >>
>>>  >> View this message in context:
>>>  >>
>>> http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25006196.html
>>>  >>
>>>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>>>  >>
>>>  >>
>>>  >> 
>>> ---------------------------------------------------------------------
>>>  >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>>  >>  For additional commands, e-mail:
>>> jmeter-user-help@jakarta.apache.org
>>>  >>
>>>  >>
>>>  >
>>>  > ---------------------------------------------------------------------
>>>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>>  >
>>>  >
>>>  >
>>>
>>>  --
>>>
>>> View this message in context:
>>> http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25006598.html
>>>
>>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>>
>>>
>>>  ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>>
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JDBC-Response-Assertion-tp25002488p25007241.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Mime
View raw message