Sebb

Thank you for your perceptive answer.  Yes, I was wrong to say the
BEAN SHELL ASSERTION script was being skipped.

I have:

Thread Group (1/0/1)
+ HTTP Cache Manager (clear cache)
+ HTTP Cookie Manager (clear cookies)
+ Simple Controller
++ HTTP Request
+++HTTP Header Manager (host, accept, useragent, etc)
++Bean Shell Assertion
++ Assertion Results
+ View Results Tree
+ Mailer Visualizer

The BEAN SHELL ASSERTION now contains only:

   print("Start of script 27b");
   print(vars.get("JMeterThread.last_sample_ok"));
   print( ResponseCode);

With a valid tested server port:

  Start of script 27b
  true
  200

and we have success.

When changing the HTTP request to an invalid port (just to fake the test):

  Start of script 27b
  true
  Non HTTP response code: java.net.SocketTimeoutException

and the Mailer Visualizer sees an error (failure).  The sampler result is:

   Thread Name: *************
   Sample Start: 2012-04-08 03:40:54 BST
   Load time: 5005
   Latency: 0
   Size in bytes: 1577
   Sample Count: 1
   Error Count: 1
   Response code: Non HTTP response code: java.net.SocketTimeoutException
   Response message: Non HTTP response message: connect timed out

  Response headers:

   HTTPSampleResult fields:
   ContentType:
   DataEncoding: null

So, I suppose my simpler question is, how would I conditionally branch
on the HTTP Request sampler error, and only do other assertion tests
and email if a non null status code is returned?  I'm happy to do this
in the Bean Shell script, if it isn't possible with the standard
Jmeter components.

Adam


On 27 January 2011 12:02, sebb <[email protected]> wrote:
> On 27 January 2011 11:44, Adam Ploverall <[email protected]> 
> wrote:
>> Hello
>>
>> I have been trying to build some conditional logic into my tests, and
>> have been trying the IF CONTROLLER, RESPONSE ASSERTION and BEAN SHELL
>> ASSERTIONs.  Sometimes, my HTTP SAMPLER gets a timeout response like:
>>
>>   java.net.SocketTimeoutException: connect timed out
>>
>>   or
>>
>>   java.net.SocketTimeoutException: Read timed out
>>
>> These might be due to lack of resources, or the tested site being
>> down.  But it seems the HTTP SAMPLER is setting these:
>>
>>   Error Count: 1
>>   Response code: Non HTTP response code: java.net.SocketTimeoutException
>>
>> and I can't work out how to suppress this, and say skip a subsequent
>> MAILER VISUALIZER.
>>
>> In a BEAN SHELL ASSERTION, I have tried:
>>
>>   if (ResponseCode.equals(null)==false && ResponseCode.equals("Non
>> HTTP response code: java.net.SocketTimeoutException")==false)  {
>>
>>   ...
>>
>>   }
>>
>> but the sampler seems to be skipped due to the HTTP SAMPLER error.  If
>
> Do you mean the assertion is skipped?
> Are you sure? Try adding a print("message") call to the start of BSH 
> Assertion.
>
> Also print out the values of critical variables in the script.
>
> And check jmeter log file for script errors.
>
>> I use a RESPONSE ASSERTION, I can ignore the status code (checkbox),
>> but then have little control about what happens next.
>>
>> My aim is to do something like this:
>>
>> 1. Do an HTTP request
>> 1a) 5 min timer delay (Constant Timer)
>>
>> 2. If the response has a status code and content (else skip to 3.):
>> 2a) do some other response assertion tests on the headers and content
>> 2b) use the mailer visualiser to alert on any failure (0/0 setting)
>> 2c) Skip to 4.
>>
>> 3. If a java.net.SocketTimeoutException occurs
>> 3a) use the mailer visualiser to alert on two failures (1/0 setting)
>> 3b) reset the failure count to 0 if we haven't had another failure in X 
>> minutes
>> 3c) Continue to 4
>>
>> 4. Continue indefinite loop
>>
>> In other words, treat the 3s with less priority.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to