jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: JMeter BeanShell: Hit All Web Instances
Date Thu, 20 Sep 2007 19:10:05 GMT
On 20/09/2007, Nikolaos Giannopoulos <nikolaos@brightminds.org> wrote:
> Sebb,
>
> sebb wrote:
> > On 20/09/2007, Nikolaos Giannopoulos <nikolaos@brightminds.org> wrote:
> >
> >> Sebb,
> >>
> >> Appreciate your help.  I had the HTTP sampler and added the following:
> >>
> >> 1. Regular Expression Extractor
> >>     Response Field to check:  Body
> >>     Reference Name:  portalInstance
> >>     Regular Expression:  \>(8[012])\<
> >>
> >
> > I don't think you need to escape the < and >
> >
> > The RE will match only
> >> 80<
> >> 81<
> >> 82<
> >>
> ok.  no problem.  I removed the escapes and it made no difference
>
> >>     Template:  $1$
> >>     Match No.:  0
> >>
> >
> > Do you really want to choose a random match?
> >
> No.  I had it at 1 before as I want the 1st match but that didn't work.
> Set to 1.  Still doesn't work.
>
> >>     Default Value:  none
> >>
> >
> > If "none" means no value entered, then I suggest you replace with
> > NOTFOUND or similar until the RE has been debugged. That makes it
> > easier to see if the variable(s) are being used correctly.
> >
> Are you saying that "NOTFOUND" is easier to see than "none".  A Java
> String variable that has no value should be assigned the ref null and in
> printing will result in "null".  I think it isn't hard to discern
> between "none" and "null" but sure I switched this to "NOTFOUND".

No, I was saying that no value is not suitable, as the RE won't set
the variable if it does not match. Using any text means that the
variable will be set to something, even if the RE does not match.

> >> 2. BeanShell PostProcessor
> >> String piPort0 = vars.get("portalInstance");
> >> String piPort1 = vars.get("portalInstance_g");
> >> String piPort2 = vars.get("portalInstance_g0");
> >> String piPort3 = vars.get("portalInstance_g1");
> >>
> > OK
> >
> So - if I set the RE's Match No to 1 then I should expect that
> piPort3="81".  Right?

The match number is not relevant so long as a match is found.

> Well - that is not what I am observing - in the following line I get a
> popup button with contents:
>
> null|null|null|null
>
> That is the issue that I can't resolve at the moment
>
> >> JButton button = new JButton( piPort0 + "|" + piPort1 + "|" + piPort2 +
> >> "|" + piPort3);
> >> JFrame frame = new JFrame( "My Frame" );
> >> frame.getContentPane().add( button, "Center" );
> >> frame.pack();
> >> frame.setVisible(true);
> >>
> >
> > You could just use
> >
> > print(vars.get("varname"));
> >
> > to show the value in the console window.
> >
> Ok.  Once again your showing me alternatives that shouldn't make a
> difference.  If I can't get the RE extracted string into a button label
> surely it doesn't matter if I print it to console.  In any event, I
> added the code:
>
> print(vars.get("portalInstance"));
> print(vars.get("portalInstance_g"));
> print(vars.get("portalInstance_g0"));
> print(vars.get("portalInstance_g1"));
>
> and got in the console:
> null
> null
> null
> null

Which means that the variables are not being set.

Either the RE is not being run at all, or it is not matching (and
there is no default) or there was a failure in the processing: check
jmeter.log.

> Something tells me something else is the problem :-)
>
> >> Problem:  The resulting button is "null|null|null|null"
> >>
> >> Of course I don't expect all of these to have values as there is only 1
> >> match in the HTTP response data and it looks as follows:
> >>
> >>        <td width="20%" align="right" bgcolor="#F6F6F6"><font
> >> color="#777777" size="2">81</font></td>
> >>
> >
> > Should match - but are there any spaces around the "81" perhaps?
> >
> Nope.  It's just like you see it there.
>
> >>        <td width="20%" align="right" bgcolor="#F6F6F6"><font
> >> color="#777777" size="2">portal2</font></td>
> >>
> >> I must be reading the RE Extracted value wrong.  Can you help please?
> >>
> >
> > Another simple way to display a variable is to use it in a Java Request Sampler.
> >
> SO displaying the variable is not the issue.  The issue is getting the
> RE Extractor to work.
>
> Do you see anything that might be wrong.  I keep hitting the same wall.
> THis is driving me nuts!!!!
>
> Appreciate your responses.
>
> --Nikolaos
>
> >> --Nikolaos
> >>
> >>
> >> sebb wrote:
> >>
> >>> On 20/09/2007, Nikolaos Giannopoulos <nikolaos@brightminds.org> wrote:
> >>>
> >>>
> >>>> Hi,
> >>>>
> >>>> We have a JMeter plan that hits a JSP on site that has 9 web instances
> >>>> behind a load balancer.  The JSP presents information on the instance
> >>>> hit e.g. "Server 3 instance 2" as well as other diagnostic information.
> >>>>
> >>>> Currently, in order to ensure that all instances are running after a
> >>>> deployment we run JMeter and look at all the JSP pages manually until
we
> >>>> see that we have hit all 9 web instances.  This is not only very manual
> >>>> but also tedious because of non-RR LB algorithms there may be some
> >>>> instances that aren't hit that often.
> >>>>
> >>>> I was thinking of writing some BeanShell scripts to automate this process.
> >>>>
> >>>> Essentially, what I need is:
> >>>>
> >>>> 1. a way to obtain the HTTP response of a particular JSP,
> >>>>
> >>>>
> >>> Use the HTTP Sampler.
> >>>
> >>>
> >>>
> >>>> 2. extract the strings that represent the instance hit and track that
> >>>> against a "global" list
> >>>> 3. once all instances are hit in the "global" list - simply stop the
test
> >>>> 4. print a message on the screen saying something like "All 9 instances
> >>>> running" once test stopped
> >>>>
> >>>>
> >>> The rest can be done with the BeanShell Post-Processor.
> >>> Possibly easier to use the RE Post-Processor to extract the string.
> >>>
> >>> The BSH script can then mark the string as seen, e.g. using a Hash and
> >>> counting when there are nine entries.
> >>>
> >>>
> >>>
> >>>> How hard is this to do.  Any tips / pointers / examples / help would
be
> >>>> appreciated.
> >>>>
> >>>>
> >>> If you are competent in Java, then it should not be too hard.
> >>>
> >>> Read the mailing list for BSH examples.
> >>>
> >>>
> >>>
> >>>> Thanks,
> >>>>
> >>>> --Nikolaos
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >>>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >> --
> >> Nikolaos Giannopoulos
> >> Director, BrightMinds Software Inc.
> >> e. nikolaos@brightminds.org
> >> w. www.brightminds.org
> >> t. 1.613.822.1700
> >> f. 1.613.822.1915
> >> c. 1.613.797.0036
> >>
> >>
> >>
> >
> >
> >
>
>
> --
> Nikolaos Giannopoulos
> Director, BrightMinds Software Inc.
> e. nikolaos@brightminds.org
> w. www.brightminds.org
> t. 1.613.822.1700
> f. 1.613.822.1915
> c. 1.613.797.0036
>
>

---------------------------------------------------------------------
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