You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Hiro Protagonist <hi...@googlemail.com> on 2008/11/28 13:55:35 UTC

Re: Using while and for_each controllers to emulate javascript ajax calls

On Fri, 2008-11-28 at 12:13 +0000, sebb wrote:
> On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
> > Hi All,
> >
> >  I am currently stuck with the following:
> >  I have a web application that uses AJAX to display information coming
> >  from a database in portlets (graphical representation). These portlets
> >  each trigger a set of SQL queries in a database, and while the database
> >  is getting the query result, an animated GIF is displayed, and
> >  Javascript causes the browser to poll every 5 seconds or so, until the
> >  'real' information can be displayed, at which point the polls stop.
> >  This is an isue with JMeter, because as far as JMeter is concerned, the
> >  request that was sent has been answered, and it moves on to the next
> >  request.
> >  However, what I need is essentially a loop that keeps checking what the
> >  contents of the response is, and repeat the http request until the word
> >  'Sarching' does not appear anymore (meaning in received data to be
> >  displayed in the portlet).
> >  There are a number of different portlets on each page, identified by a
> >  unique string in the previous http response, which is used in the
> >  'polling request' that is sent back to the server.
> >  I have managed to get this far:
> >
> >  - set up a regex that extracts the unique ID for each portlet
> >  - set up a for_each loop that goes through all of these IDs and sends
> >  requests
> >  - set up a regex that extracts the response from the polled request
> >
> >  However, the problem I have is that the while loop, which is nested
> >  inside the for_each loop, never moves on to the second value after the
> >  first response has finished and found the response.
> >
> >  Here is my test plan:
> >
> >
> >  *** (various login and authentication requests)
> >  |
> >  @Regex called 'searching' with default value of 'NOTFINISHED'
> >  |
> >  *Request to move to page containing portlets (regex 'searching')
> >  |
> >  #For Each Controller (iterates all values for request/response above)
> >  \
> >   \
> >   #While controller (loop while regex defaults to 'NOTFINISHED')
> >    |
> >    * Request for portlet
> >     \
> >      @Regex searching looking for 'searching' in response.
> >       If not found, default value is NOTFINISHED
> >
> >  Everything works, except that I get stuck in the while loop after the
> >  first portlet comes back without 'searching' - effectively having found
> >  the information and it should then set the regex to something else.
> >  What is wrong with this setup ?
> 
> Difficult to say, as you don't show what the While Condition is.

I have set the while condition to:
${__javaScript( ${SEARCHING}=="NOTFINISHED",dummy)}

sebb, also I believe there may be a problem with variable scope here. To
enter the loop, the while controller needs the variable SEARCHING to
exist before (which it does). The regex attached to the HTTP request
inside the while loop re-references this name (SEARCHING), but sets a
default value of "FINISHED" if the string was not found. It seems that
this setting never actually takes place - I have placed a debug sampler
inside the loop and even though the value of SEARCHING is set to
'FINISHED' after the regex term was not found, it keeps looping.

> 
> Try adding Debug Sampler(s) and look at the variables in View Results Tree.
> 
> >  Should I be using a user-defined variable instead of a regex ?
> 
> I don't understand. The regex output is stored in a variable.
> 
> >  Thanks for your help !
> >  hiro
> >
> >
> >  ---------------------------------------------------------------------
> >  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
> 


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


Re: Using while and for_each controllers to emulate javascript ajax calls

Posted by sebb <se...@gmail.com>.
On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
>
>  On Fri, 2008-11-28 at 13:24 +0000, sebb wrote:
>  > On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
>  > >
>  > >  On Fri, 2008-11-28 at 12:13 +0000, sebb wrote:
>  > >  > On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
>  > >  > > Hi All,
>  > >  > >
>  > >  > >  I am currently stuck with the following:
>  > >  > >  I have a web application that uses AJAX to display information coming
>  > >  > >  from a database in portlets (graphical representation). These portlets
>  > >  > >  each trigger a set of SQL queries in a database, and while the database
>  > >  > >  is getting the query result, an animated GIF is displayed, and
>  > >  > >  Javascript causes the browser to poll every 5 seconds or so, until the
>  > >  > >  'real' information can be displayed, at which point the polls stop.
>  > >  > >  This is an isue with JMeter, because as far as JMeter is concerned, the
>  > >  > >  request that was sent has been answered, and it moves on to the next
>  > >  > >  request.
>  > >  > >  However, what I need is essentially a loop that keeps checking what the
>  > >  > >  contents of the response is, and repeat the http request until the word
>  > >  > >  'Sarching' does not appear anymore (meaning in received data to be
>  > >  > >  displayed in the portlet).
>  > >  > >  There are a number of different portlets on each page, identified by a
>  > >  > >  unique string in the previous http response, which is used in the
>  > >  > >  'polling request' that is sent back to the server.
>  > >  > >  I have managed to get this far:
>  > >  > >
>  > >  > >  - set up a regex that extracts the unique ID for each portlet
>  > >  > >  - set up a for_each loop that goes through all of these IDs and sends
>  > >  > >  requests
>  > >  > >  - set up a regex that extracts the response from the polled request
>  > >  > >
>  > >  > >  However, the problem I have is that the while loop, which is nested
>  > >  > >  inside the for_each loop, never moves on to the second value after the
>  > >  > >  first response has finished and found the response.
>  > >  > >
>  > >  > >  Here is my test plan:
>  > >  > >
>  > >  > >
>  > >  > >  *** (various login and authentication requests)
>  > >  > >  |
>  > >  > >  @Regex called 'searching' with default value of 'NOTFINISHED'
>  > >  > >  |
>  > >  > >  *Request to move to page containing portlets (regex 'searching')
>  > >  > >  |
>  > >  > >  #For Each Controller (iterates all values for request/response above)
>  > >  > >  \
>  > >  > >   \
>  > >  > >   #While controller (loop while regex defaults to 'NOTFINISHED')
>  > >  > >    |
>  > >  > >    * Request for portlet
>  > >  > >     \
>  > >  > >      @Regex searching looking for 'searching' in response.
>  > >  > >       If not found, default value is NOTFINISHED
>  > >  > >
>  > >  > >  Everything works, except that I get stuck in the while loop after the
>  > >  > >  first portlet comes back without 'searching' - effectively having found
>  > >  > >  the information and it should then set the regex to something else.
>  > >  > >  What is wrong with this setup ?
>  > >  >
>  > >  > Difficult to say, as you don't show what the While Condition is.
>  > >
>  > >
>  > > I have set the while condition to:
>  > >  ${__javaScript( ${SEARCHING}=="NOTFINISHED",dummy)}
>  >
>  > That is not valid Java script - it should be
>  >
>  > ${__javaScript("${SEARCHING}"=="NOTFINISHED",dummy)}
>  >
>  > >  sebb, also I believe there may be a problem with variable scope here. To
>  > >  enter the loop, the while controller needs the variable SEARCHING to
>  > >  exist before (which it does). The regex attached to the HTTP request
>  > >  inside the while loop re-references this name (SEARCHING), but sets a
>  > >  default value of "FINISHED" if the string was not found. It seems that
>  > >  this setting never actually takes place - I have placed a debug sampler
>  > >  inside the loop and even though the value of SEARCHING is set to
>  > >  'FINISHED' after the regex term was not found, it keeps looping.
>  > >
>  >
>  > Add a Debug Sampler after the Regex to show the value.
>
>
> sebb,
>
>  This is getting more bizarre by the minute: putting a 'dummy' request
>  into the while loop solved the issue of the for_each loop not continuing
>  after the value was found - now for the REALLY interesting part:
>  when I run the loop, the first time it runs, it includes the
>  fully-qualified hostname, and all headers that go with the post request.
>  On the second and all subsequent iterations, it a) drops the
>  fully-qualified hostname and only uses the machine name, and b) drops
>  all the headers !!
>
>  Here is what it includes on the first request (which gets a 200 OK
>  return code from the server):
>  POST
>  http://mymachine.mydomain.com:7777/analytics/saw.dll?ReloadDashboard&_scid=ZKTyTueGv54
>
>  POST data:
>  InFrameset=false&Caller=Dashboard&Embed=true&PortalPath=%2Fshared%
>  2FGeneral%2F_portal%2FIT
>  +Sales&Page=Sales&_scid=ZKTyTueGv54&ViewState=kbggovhl2p4jmsumpm601c6oc2&reloadTargets=d%3Adashboard%7Ep%3Atkgc4svqo71u0ro1%7Er%3Aev5eusng2vkmaa7k&ajaxType=iframe
>
>  Cookie Data:
>  nQuireID=klfj6u905h6au4pl7uumctcq74p1duqojhrscvqzOr07UFe9W00;
>  OHS-mymachine.mydomain.com-7777=CBA505AC82A141A993C7E0D444C563FDE53A0D7D98DFE8(etc. etc. etc.)
>
>  Here is the second iteration:
>
>  POST
>  http://mymachine:7778/analytics/saw.dll?ReloadDashboard&_scid=ZKTyTueGv54
>
>  POST data:
>
>
>  [no cookies]
>
>  Surely it should not behave this way ?!
>

Depends on how you set up the test.

I suggest you use plenty of Debug Samplers to follow how the variables
are being changed.

For each sample that is not working as expected, follow the trail of
the variables it uses.

>
>  >
>  > >  >
>  > >  > Try adding Debug Sampler(s) and look at the variables in View Results Tree.
>  > >  >
>  > >  > >  Should I be using a user-defined variable instead of a regex ?
>  > >  >
>  > >  > I don't understand. The regex output is stored in a variable.
>  > >  >
>  > >  > >  Thanks for your help !
>  > >  > >  hiro
>  > >  > >
>  > >  > >
>  > >  > >  ---------------------------------------------------------------------
>  > >  > >  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
>  > >  >
>  > >
>  > >
>  > >  ---------------------------------------------------------------------
>  > >  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
>  >
>
>
>  ---------------------------------------------------------------------
>  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


Re: Using while and for_each controllers to emulate javascript ajax calls

Posted by Hiro Protagonist <hi...@googlemail.com>.
On Fri, 2008-11-28 at 13:24 +0000, sebb wrote:
> On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
> >
> >  On Fri, 2008-11-28 at 12:13 +0000, sebb wrote:
> >  > On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
> >  > > Hi All,
> >  > >
> >  > >  I am currently stuck with the following:
> >  > >  I have a web application that uses AJAX to display information coming
> >  > >  from a database in portlets (graphical representation). These portlets
> >  > >  each trigger a set of SQL queries in a database, and while the database
> >  > >  is getting the query result, an animated GIF is displayed, and
> >  > >  Javascript causes the browser to poll every 5 seconds or so, until the
> >  > >  'real' information can be displayed, at which point the polls stop.
> >  > >  This is an isue with JMeter, because as far as JMeter is concerned, the
> >  > >  request that was sent has been answered, and it moves on to the next
> >  > >  request.
> >  > >  However, what I need is essentially a loop that keeps checking what the
> >  > >  contents of the response is, and repeat the http request until the word
> >  > >  'Sarching' does not appear anymore (meaning in received data to be
> >  > >  displayed in the portlet).
> >  > >  There are a number of different portlets on each page, identified by a
> >  > >  unique string in the previous http response, which is used in the
> >  > >  'polling request' that is sent back to the server.
> >  > >  I have managed to get this far:
> >  > >
> >  > >  - set up a regex that extracts the unique ID for each portlet
> >  > >  - set up a for_each loop that goes through all of these IDs and sends
> >  > >  requests
> >  > >  - set up a regex that extracts the response from the polled request
> >  > >
> >  > >  However, the problem I have is that the while loop, which is nested
> >  > >  inside the for_each loop, never moves on to the second value after the
> >  > >  first response has finished and found the response.
> >  > >
> >  > >  Here is my test plan:
> >  > >
> >  > >
> >  > >  *** (various login and authentication requests)
> >  > >  |
> >  > >  @Regex called 'searching' with default value of 'NOTFINISHED'
> >  > >  |
> >  > >  *Request to move to page containing portlets (regex 'searching')
> >  > >  |
> >  > >  #For Each Controller (iterates all values for request/response above)
> >  > >  \
> >  > >   \
> >  > >   #While controller (loop while regex defaults to 'NOTFINISHED')
> >  > >    |
> >  > >    * Request for portlet
> >  > >     \
> >  > >      @Regex searching looking for 'searching' in response.
> >  > >       If not found, default value is NOTFINISHED
> >  > >
> >  > >  Everything works, except that I get stuck in the while loop after the
> >  > >  first portlet comes back without 'searching' - effectively having found
> >  > >  the information and it should then set the regex to something else.
> >  > >  What is wrong with this setup ?
> >  >
> >  > Difficult to say, as you don't show what the While Condition is.
> >
> >
> > I have set the while condition to:
> >  ${__javaScript( ${SEARCHING}=="NOTFINISHED",dummy)}
> 
> That is not valid Java script - it should be
> 
> ${__javaScript("${SEARCHING}"=="NOTFINISHED",dummy)}
> 
> >  sebb, also I believe there may be a problem with variable scope here. To
> >  enter the loop, the while controller needs the variable SEARCHING to
> >  exist before (which it does). The regex attached to the HTTP request
> >  inside the while loop re-references this name (SEARCHING), but sets a
> >  default value of "FINISHED" if the string was not found. It seems that
> >  this setting never actually takes place - I have placed a debug sampler
> >  inside the loop and even though the value of SEARCHING is set to
> >  'FINISHED' after the regex term was not found, it keeps looping.
> >
> 
> Add a Debug Sampler after the Regex to show the value.

sebb,

This is getting more bizarre by the minute: putting a 'dummy' request
into the while loop solved the issue of the for_each loop not continuing
after the value was found - now for the REALLY interesting part:
when I run the loop, the first time it runs, it includes the
fully-qualified hostname, and all headers that go with the post request.
On the second and all subsequent iterations, it a) drops the
fully-qualified hostname and only uses the machine name, and b) drops
all the headers !!

Here is what it includes on the first request (which gets a 200 OK
return code from the server):
POST
http://mymachine.mydomain.com:7777/analytics/saw.dll?ReloadDashboard&_scid=ZKTyTueGv54

POST data:
InFrameset=false&Caller=Dashboard&Embed=true&PortalPath=%2Fshared%
2FGeneral%2F_portal%2FIT
+Sales&Page=Sales&_scid=ZKTyTueGv54&ViewState=kbggovhl2p4jmsumpm601c6oc2&reloadTargets=d%3Adashboard%7Ep%3Atkgc4svqo71u0ro1%7Er%3Aev5eusng2vkmaa7k&ajaxType=iframe

Cookie Data:
nQuireID=klfj6u905h6au4pl7uumctcq74p1duqojhrscvqzOr07UFe9W00;
OHS-mymachine.mydomain.com-7777=CBA505AC82A141A993C7E0D444C563FDE53A0D7D98DFE8(etc. etc. etc.)

Here is the second iteration:

POST
http://mymachine:7778/analytics/saw.dll?ReloadDashboard&_scid=ZKTyTueGv54

POST data:


[no cookies]

Surely it should not behave this way ?!

> 
> >  >
> >  > Try adding Debug Sampler(s) and look at the variables in View Results Tree.
> >  >
> >  > >  Should I be using a user-defined variable instead of a regex ?
> >  >
> >  > I don't understand. The regex output is stored in a variable.
> >  >
> >  > >  Thanks for your help !
> >  > >  hiro
> >  > >
> >  > >
> >  > >  ---------------------------------------------------------------------
> >  > >  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
> >  >
> >
> >
> >  ---------------------------------------------------------------------
> >  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
> 


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


Re: Using while and for_each controllers to emulate javascript ajax calls

Posted by sebb <se...@gmail.com>.
On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
>
>  On Fri, 2008-11-28 at 12:13 +0000, sebb wrote:
>  > On 28/11/2008, Hiro Protagonist <hi...@googlemail.com> wrote:
>  > > Hi All,
>  > >
>  > >  I am currently stuck with the following:
>  > >  I have a web application that uses AJAX to display information coming
>  > >  from a database in portlets (graphical representation). These portlets
>  > >  each trigger a set of SQL queries in a database, and while the database
>  > >  is getting the query result, an animated GIF is displayed, and
>  > >  Javascript causes the browser to poll every 5 seconds or so, until the
>  > >  'real' information can be displayed, at which point the polls stop.
>  > >  This is an isue with JMeter, because as far as JMeter is concerned, the
>  > >  request that was sent has been answered, and it moves on to the next
>  > >  request.
>  > >  However, what I need is essentially a loop that keeps checking what the
>  > >  contents of the response is, and repeat the http request until the word
>  > >  'Sarching' does not appear anymore (meaning in received data to be
>  > >  displayed in the portlet).
>  > >  There are a number of different portlets on each page, identified by a
>  > >  unique string in the previous http response, which is used in the
>  > >  'polling request' that is sent back to the server.
>  > >  I have managed to get this far:
>  > >
>  > >  - set up a regex that extracts the unique ID for each portlet
>  > >  - set up a for_each loop that goes through all of these IDs and sends
>  > >  requests
>  > >  - set up a regex that extracts the response from the polled request
>  > >
>  > >  However, the problem I have is that the while loop, which is nested
>  > >  inside the for_each loop, never moves on to the second value after the
>  > >  first response has finished and found the response.
>  > >
>  > >  Here is my test plan:
>  > >
>  > >
>  > >  *** (various login and authentication requests)
>  > >  |
>  > >  @Regex called 'searching' with default value of 'NOTFINISHED'
>  > >  |
>  > >  *Request to move to page containing portlets (regex 'searching')
>  > >  |
>  > >  #For Each Controller (iterates all values for request/response above)
>  > >  \
>  > >   \
>  > >   #While controller (loop while regex defaults to 'NOTFINISHED')
>  > >    |
>  > >    * Request for portlet
>  > >     \
>  > >      @Regex searching looking for 'searching' in response.
>  > >       If not found, default value is NOTFINISHED
>  > >
>  > >  Everything works, except that I get stuck in the while loop after the
>  > >  first portlet comes back without 'searching' - effectively having found
>  > >  the information and it should then set the regex to something else.
>  > >  What is wrong with this setup ?
>  >
>  > Difficult to say, as you don't show what the While Condition is.
>
>
> I have set the while condition to:
>  ${__javaScript( ${SEARCHING}=="NOTFINISHED",dummy)}

That is not valid Java script - it should be

${__javaScript("${SEARCHING}"=="NOTFINISHED",dummy)}

>  sebb, also I believe there may be a problem with variable scope here. To
>  enter the loop, the while controller needs the variable SEARCHING to
>  exist before (which it does). The regex attached to the HTTP request
>  inside the while loop re-references this name (SEARCHING), but sets a
>  default value of "FINISHED" if the string was not found. It seems that
>  this setting never actually takes place - I have placed a debug sampler
>  inside the loop and even though the value of SEARCHING is set to
>  'FINISHED' after the regex term was not found, it keeps looping.
>

Add a Debug Sampler after the Regex to show the value.

>  >
>  > Try adding Debug Sampler(s) and look at the variables in View Results Tree.
>  >
>  > >  Should I be using a user-defined variable instead of a regex ?
>  >
>  > I don't understand. The regex output is stored in a variable.
>  >
>  > >  Thanks for your help !
>  > >  hiro
>  > >
>  > >
>  > >  ---------------------------------------------------------------------
>  > >  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
>  >
>
>
>  ---------------------------------------------------------------------
>  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