Hi Chris,
I use a series of HTTP::respond based iRules on a second LTM for testing server responses. I haven't done anything with percentage failures though. Here's a simple example which sets the server response code based on the URI:
when HTTP_REQUEST {
set data {Some data to send to the client. If you want to use variables in here, replace the curly braces with quotes.}
Look for a URI starting with a forward slash and then 3 digits (the first digit being 1-5)
If one is found, set it as the HTTP response code. Else, send back an HTTP 200
if {[string match {/[1-5][0-9][0-9]*} [HTTP::path]]}{
Send the response with the status code from the requested path and data
HTTP::respond [string range [HTTP::path] 1 3] content $data "a_header_name" "a_header_value"
log local0. "Sending [string range [HTTP::path] 1 3] response with $data"
} else {
Send a 200 response with data
HTTP::respond 200 content $data "a_header_name" "a_header_value"
log local0. "Sending default 200 response with $data"
}
}
You could expand on this to send a failure X percent of the time using rand:
Check if this should be a failure
if { rand() < [URI::query [HTTP::uri] "fail_rate" }
To add delay, you could use the after command:
http://devcentral.f5.com/wiki/iRules.after.ashx
http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/aff/5/afv/topic/aft/2159077/afc/2235282/Default.aspx
If you get something tested, it would make an interesting Codeshare example
🙂
Aaron