increase some test timeouts in http-core, #19965

This commit is contained in:
Patrik Nordwall 2016-03-22 12:17:44 +01:00
parent 7512c86ac9
commit fe6e58a4a7
5 changed files with 18 additions and 10 deletions

View file

@ -438,7 +438,7 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
override def afterAll() = system.terminate()
private class Test {
def awaitAtMost: FiniteDuration = 250.millis
def awaitAtMost: FiniteDuration = 3.seconds
var closeAfterResponseCompletion = Seq.empty[Boolean]
class StrictEqualHttpRequest(val req: HttpRequest) {

View file

@ -243,14 +243,16 @@ class ResponseParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
override def afterAll() = system.terminate()
private class Test {
def awaitAtMost: FiniteDuration = 3.seconds
var closeAfterResponseCompletion = Seq.empty[Boolean]
class StrictEqualHttpResponse(val resp: HttpResponse) {
override def equals(other: scala.Any): Boolean = other match {
case other: StrictEqualHttpResponse
this.resp.copy(entity = HttpEntity.Empty) == other.resp.copy(entity = HttpEntity.Empty) &&
Await.result(this.resp.entity.toStrict(250.millis), 250.millis) ==
Await.result(other.resp.entity.toStrict(250.millis), 250.millis)
Await.result(this.resp.entity.toStrict(awaitAtMost), awaitAtMost) ==
Await.result(other.resp.entity.toStrict(awaitAtMost), awaitAtMost)
}
override def toString = resp.toString
@ -319,7 +321,7 @@ class ResponseParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
private def compactEntity(entity: ResponseEntity): Future[ResponseEntity] =
entity match {
case x: HttpEntity.Chunked compactEntityChunks(x.chunks).fast.map(compacted x.copy(chunks = compacted))
case _ entity.toStrict(250.millis)
case _ entity.toStrict(awaitAtMost)
}
private def compactEntityChunks(data: Source[ChunkStreamPart, Any]): Future[Source[ChunkStreamPart, Any]] =

View file

@ -322,11 +322,13 @@ class RequestRendererSpec extends FreeSpec with Matchers with BeforeAndAfterAll
serverAddress: InetSocketAddress = new InetSocketAddress("test.com", 8080))
extends HttpRequestRendererFactory(userAgent, requestHeaderSizeHint = 64, NoLogging) {
def awaitAtMost: FiniteDuration = 3.seconds
def renderTo(expected: String): Matcher[HttpRequest] =
equal(expected.stripMarginWithNewline("\r\n")).matcher[String] compose { request
val byteStringSource = renderToSource(RequestRenderingContext(request, Host(serverAddress)))
val future = byteStringSource.limit(1000).runWith(Sink.seq).map(_.reduceLeft(_ ++ _).utf8String)
Await.result(future, 250.millis)
Await.result(future, awaitAtMost)
}
}

View file

@ -581,6 +581,8 @@ class ResponseRendererSpec extends FreeSpec with Matchers with BeforeAndAfterAll
class TestSetup(val serverHeader: Option[Server] = Some(Server("akka-http/1.0.0")))
extends HttpResponseRendererFactory(serverHeader, responseHeaderSizeHint = 64, NoLogging) {
def awaitAtMost: FiniteDuration = 3.seconds
def renderTo(expected: String): Matcher[HttpResponse] =
renderTo(expected, close = false) compose (ResponseRenderingContext(_))
@ -605,7 +607,7 @@ class ResponseRendererSpec extends FreeSpec with Matchers with BeforeAndAfterAll
} catch {
case NonFatal(_) false
}
Await.result(resultFuture, 250.millis).reduceLeft(_ ++ _).utf8String -> wasCompleted
Await.result(resultFuture, awaitAtMost).reduceLeft(_ ++ _).utf8String -> wasCompleted
}
override def currentTimeMillis() = DateTime(2011, 8, 25, 9, 10, 29).clicks // provide a stable date for testing

View file

@ -35,6 +35,8 @@ class HttpEntitySpec extends FreeSpec with MustMatchers with BeforeAndAfterAll {
implicit val materializer = ActorMaterializer()
override def afterAll() = system.terminate()
val awaitAtMost = 3.seconds
"HttpEntity" - {
"support dataBytes" - {
"Strict" in {
@ -90,7 +92,7 @@ class HttpEntitySpec extends FreeSpec with MustMatchers with BeforeAndAfterAll {
"Infinite data stream" in {
val neverCompleted = Promise[ByteString]()
intercept[TimeoutException] {
Await.result(Default(tpe, 42, Source.fromFuture(neverCompleted.future)).toStrict(100.millis), 150.millis)
Await.result(Default(tpe, 42, Source.fromFuture(neverCompleted.future)).toStrict(100.millis), awaitAtMost)
}.getMessage must be("HttpEntity.toStrict timed out after 100 milliseconds while still waiting for outstanding data")
}
}
@ -178,18 +180,18 @@ class HttpEntitySpec extends FreeSpec with MustMatchers with BeforeAndAfterAll {
def collectBytesTo(bytes: ByteString*): Matcher[HttpEntity] =
equal(bytes.toVector).matcher[Seq[ByteString]].compose { entity
val future = entity.dataBytes.limit(1000).runWith(Sink.seq)
Await.result(future, 250.millis)
Await.result(future, awaitAtMost)
}
def withReturnType[T](expr: T) = expr
def strictifyTo(strict: Strict): Matcher[HttpEntity] =
equal(strict).matcher[Strict].compose(x Await.result(x.toStrict(250.millis), 250.millis))
equal(strict).matcher[Strict].compose(x Await.result(x.toStrict(awaitAtMost), awaitAtMost))
def transformTo(strict: Strict): Matcher[HttpEntity] =
equal(strict).matcher[Strict].compose { x
val transformed = x.transformDataBytes(duplicateBytesTransformer)
Await.result(transformed.toStrict(250.millis), 250.millis)
Await.result(transformed.toStrict(awaitAtMost), awaitAtMost)
}
def renderStrictDataAs(dataRendering: String): Matcher[Strict] =