You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Kim Wan <ki...@oracle.com> on 2004/12/03 01:16:15 UTC

While loop executing regardless of true or false state

Hi all,

I am setting up a testplan that executes reports by sending http 
requests. Some of these requests take a few minutes to execute so I've 
added a while loop and a cookie manager to continually access the state 
of a query within any one session. The while loop checks the html being 
returned - if the title is "Executing Query" (extracted from the server 
response) then it continues until the correct title is returned (the 
report has finished executing).

This is the basic setup:

Thread Group
       HTTP Cookie Manager
       Simple Controller
               Http Request
               Regular Expression (Reference name: Title; Regular 
Expression: <title>(.*)</title>)
               While Controller ("${title}" == "Executing Query")
                       Http Request

The While loop seems to execute regardless however I've tried placing 
the same conditions in an If loop and it works fine. I've also tried 
placing "Executing Query" in a user defined variable (named 
Executing_Query) but the behaviour is still the same. Even when placing 
2!=2 or "${Executing_Query}" != "${Executing_Query}", still the loop 
executes!  The title is being extracted correctly so I've run out of ideas.

Am I going about this incorrectly? Any ideas would be much appreciated!

Kim



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


Re: While loop executing regardless of true or false state

Posted by sebb <se...@gmail.com>.
On Mon, 06 Dec 2004 03:40:14 +1100, Kim Wan <ki...@oracle.com> wrote:
> Thanks Seb, that helped a lot.
> Using assertions is a good idea, however some instances of the report
> executions will not throw up an Executing Query response and are still
> valid.
> 
> What I've done is place a __regex function in the while controller:
> 
> ${__regexFunction(title>(Executing Query),true,1,,false,)}
> 
> The issue that I'm now having with this is when it doesn't match, the
> loop still executes once. I take it this remains from the implementation
> you mentioned in October?
> (http://nagoya.apache.org/eyebrowse/ReadMsg?listName=jmeter-user@jakarta.apache.org&msgId=1917811)
> 

Yes.

I had lots of problems trying to fix this, which is why I ended up
with the current implementation.

You could try using LAST  instead - make sure that the sample just
before the while loop *fails* the assertion if it should not enter the
loop at all.

> Thanks :)
> Kim
> 
> 
> 
> 
> sebb wrote:
> 
> >On Fri, 03 Dec 2004 11:16:15 +1100, Kim Wan <ki...@oracle.com> wrote:
> >
> >
> >>Hi all,
> >>
> >>I am setting up a testplan that executes reports by sending http
> >>requests. Some of these requests take a few minutes to execute so I've
> >>added a while loop and a cookie manager to continually access the state
> >>of a query within any one session. The while loop checks the html being
> >>returned - if the title is "Executing Query" (extracted from the server
> >>response) then it continues until the correct title is returned (the
> >>report has finished executing).
> >>
> >>This is the basic setup:
> >>
> >>Thread Group
> >>       HTTP Cookie Manager
> >>       Simple Controller
> >>               Http Request
> >>               Regular Expression (Reference name: Title; Regular
> >>Expression: <title>(.*)</title>)
> >>               While Controller ("${title}" == "Executing Query")
> >>
> >>
> >
> >This is not a valid condition.
> >[I'm assuming you are using version 2.0.2. An earlier nightly build
> >did assume the condition was javascript, but this is no longer the
> >case - see the docs.]
> >
> >The while controller requires one of the following:
> >- blank
> >- LAST
> >- function/variable
> >
> >
> >
> >>                       Http Request
> >>
> >>
> >
> >How is the value of the "title" variable going to get updated?
> >
> >
> >
> >>The While loop seems to execute regardless however I've tried placing
> >>
> >>
> >
> >Yes, because it is not "false"
> >
> >
> >
> >>the same conditions in an If loop and it works fine. I've also tried
> >>
> >>
> >
> >The If controller assumes JavaScript.
> >
> >
> >
> >>placing "Executing Query" in a user defined variable (named
> >>Executing_Query) but the behaviour is still the same. Even when placing
> >>2!=2 or "${Executing_Query}" != "${Executing_Query}", still the loop
> >>executes!  The title is being extracted correctly so I've run out of ideas.
> >>
> >>
> >
> >This is because the condition is not being evaluated as "false".
> >
> >
> >
> >>Am I going about this incorrectly?
> >>
> >>
> >
> >Yes, see above!
> >
> >
> >
> >>Any ideas would be much appreciated!
> >>
> >>
> >
> >It would be easier to set the condition to blank, and add an assertion
> >for the nested HTTP Request that fails when the title is NOT
> >"Executing Query" - i.e. move the Regex into the loop, and set the NOT
> >checkbox.
> >
> >
> >
> >>Kim
> >>
> >>---------------------------------------------------------------------
> >>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: While loop executing regardless of true or false state

Posted by Kim Wan <ki...@oracle.com>.
Thanks Seb, that helped a lot.
Using assertions is a good idea, however some instances of the report 
executions will not throw up an Executing Query response and are still 
valid.

What I've done is place a __regex function in the while controller:

${__regexFunction(title>(Executing Query),true,1,,false,)}

The issue that I'm now having with this is when it doesn't match, the 
loop still executes once. I take it this remains from the implementation 
you mentioned in October? 
(http://nagoya.apache.org/eyebrowse/ReadMsg?listName=jmeter-user@jakarta.apache.org&msgId=1917811)

Thanks :)
Kim



sebb wrote:

>On Fri, 03 Dec 2004 11:16:15 +1100, Kim Wan <ki...@oracle.com> wrote:
>  
>
>>Hi all,
>>
>>I am setting up a testplan that executes reports by sending http
>>requests. Some of these requests take a few minutes to execute so I've
>>added a while loop and a cookie manager to continually access the state
>>of a query within any one session. The while loop checks the html being
>>returned - if the title is "Executing Query" (extracted from the server
>>response) then it continues until the correct title is returned (the
>>report has finished executing).
>>
>>This is the basic setup:
>>
>>Thread Group
>>       HTTP Cookie Manager
>>       Simple Controller
>>               Http Request
>>               Regular Expression (Reference name: Title; Regular
>>Expression: <title>(.*)</title>)
>>               While Controller ("${title}" == "Executing Query")
>>    
>>
>
>This is not a valid condition.
>[I'm assuming you are using version 2.0.2. An earlier nightly build
>did assume the condition was javascript, but this is no longer the
>case - see the docs.]
>
>The while controller requires one of the following:
>- blank
>- LAST
>- function/variable
>
>  
>
>>                       Http Request
>>    
>>
>
>How is the value of the "title" variable going to get updated?
>
>  
>
>>The While loop seems to execute regardless however I've tried placing
>>    
>>
>
>Yes, because it is not "false"
>
>  
>
>>the same conditions in an If loop and it works fine. I've also tried
>>    
>>
>
>The If controller assumes JavaScript.
>
>  
>
>>placing "Executing Query" in a user defined variable (named
>>Executing_Query) but the behaviour is still the same. Even when placing
>>2!=2 or "${Executing_Query}" != "${Executing_Query}", still the loop
>>executes!  The title is being extracted correctly so I've run out of ideas.
>>    
>>
> 
>This is because the condition is not being evaluated as "false".
>
>  
>
>>Am I going about this incorrectly?
>>    
>>
> 
>Yes, see above!
>
>  
>
>>Any ideas would be much appreciated!
>>    
>>
>
>It would be easier to set the condition to blank, and add an assertion
>for the nested HTTP Request that fails when the title is NOT
>"Executing Query" - i.e. move the Regex into the loop, and set the NOT
>checkbox.
>
>  
>
>>Kim
>>
>>---------------------------------------------------------------------
>>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: While loop executing regardless of true or false state

Posted by sebb <se...@gmail.com>.
On Fri, 03 Dec 2004 11:16:15 +1100, Kim Wan <ki...@oracle.com> wrote:
> Hi all,
> 
> I am setting up a testplan that executes reports by sending http
> requests. Some of these requests take a few minutes to execute so I've
> added a while loop and a cookie manager to continually access the state
> of a query within any one session. The while loop checks the html being
> returned - if the title is "Executing Query" (extracted from the server
> response) then it continues until the correct title is returned (the
> report has finished executing).
> 
> This is the basic setup:
> 
> Thread Group
>        HTTP Cookie Manager
>        Simple Controller
>                Http Request
>                Regular Expression (Reference name: Title; Regular
> Expression: <title>(.*)</title>)
>                While Controller ("${title}" == "Executing Query")

This is not a valid condition.
[I'm assuming you are using version 2.0.2. An earlier nightly build
did assume the condition was javascript, but this is no longer the
case - see the docs.]

The while controller requires one of the following:
- blank
- LAST
- function/variable

>                        Http Request

How is the value of the "title" variable going to get updated?

> 
> The While loop seems to execute regardless however I've tried placing

Yes, because it is not "false"

> the same conditions in an If loop and it works fine. I've also tried

The If controller assumes JavaScript.

> placing "Executing Query" in a user defined variable (named
> Executing_Query) but the behaviour is still the same. Even when placing
> 2!=2 or "${Executing_Query}" != "${Executing_Query}", still the loop
> executes!  The title is being extracted correctly so I've run out of ideas.
 
This is because the condition is not being evaluated as "false".

> Am I going about this incorrectly?
 
Yes, see above!

> Any ideas would be much appreciated!

It would be easier to set the condition to blank, and add an assertion
for the nested HTTP Request that fails when the title is NOT
"Executing Query" - i.e. move the Regex into the loop, and set the NOT
checkbox.

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