Skip to content

Commit

Permalink
add edge case for error seen in wild even though this version handles it
Browse files Browse the repository at this point in the history
  • Loading branch information
caoilte committed Sep 14, 2015
1 parent e919aa3 commit ded5992
Showing 1 changed file with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ class LogAccessRoutingTests extends FlatSpec with ScalaFutures {
}
}

behavior of "An HTTP Server that doesn't complete within 100 times the request timeout"
behavior of "An HTTP Server that doesn't complete within 100 times the request timeout to a TXT request"

it should "'Log Access' with a 500 response and an Access Time equal to the configured Request Timeout time " +
"and then 'Access already logged' with a 500 response an Access Time more than the Request Timeout time and an " +
"and then 'Access already logged' with a 500 response and Access Time more than the Request Timeout time and an " +
"appropriate error message" in {
aTestLogAccessRoutingActor(
requestTimeoutMillis = 10,
Expand Down Expand Up @@ -164,6 +164,41 @@ class LogAccessRoutingTests extends FlatSpec with ScalaFutures {
}
}

behavior of "An HTTP Server that doesn't complete within 100 times the request timeout to a JSON request"

it should "'Log Access' with a 406 response and an Access Time equal to the configured Request Timeout time " +
"and then 'Access already logged' with a 500 response and Access Time more than the Request Timeout time and an " +
"appropriate error message" in {

aTestLogAccessRoutingActor(
requestTimeoutMillis = 10,
httpServiceActorFactory = DelayedResponseServiceActor.factory(DelayedResponse(2000), PATH)) { testKit =>
import testKit._


whenReady(makeHttpCall(MediaTypes.`application/json`), timeout(Span(2, Seconds))) { s =>
assert(s.status.intValue == 406) // because Spray Server 500 timeout response re-maps to 406
}

expectMsgPF(3 seconds, "Expected normal log access access event with timeout properties") {
case LogEvent(
HttpRequest(HttpMethods.GET,URI, _, _, _),
HttpResponse(StatusCodes.NotAcceptable, _, _, _), 10, LogAccess
) => true
}

expectMsgPF(3 seconds, "Expected access already logged error event") {
case LogEvent(
HttpRequest(HttpMethods.GET,URI, _, _, _),
HttpResponse(StatusCodes.InternalServerError, entity, _, _), time, AccessAlreadyLogged
) if
time >= (10 * 100) &&
entity.asString.contains("The RequestAccessLogger timed out waiting for the request to complete")
=> true
}
}
}


behavior of "An HTTP Server that handles a JSON request with a TXT response within the request timeout"

Expand Down

0 comments on commit ded5992

Please sign in to comment.