Skip to content

Commit

Permalink
adjust test settings for poor travis-ci performance
Browse files Browse the repository at this point in the history
  • Loading branch information
levkhomich committed Mar 16, 2016
1 parent 0385a08 commit fc8ad34
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ trait MockCollector { this: Specification =>
var collector: TServer = startCollector()
val results = new ConcurrentLinkedQueue[thrift.LogEntry]()

val MaxAwaitTimeout = 20000
val MaxAwaitTimeout = 300000
val AwaitTimeout = 4000
val AwaitStep = 20
val AwaitStep = 100

def startCollector(): TServer = {
val handler = new thrift.Scribe.Iface {
override def Log(messages: util.List[LogEntry]): ResultCode = {
results.addAll(messages)
println(s"collector received ${messages.size} message${if (messages.size > 1) "s" else ""}")
println(System.currentTimeMillis() % 100000 + s" collector received ${messages.size} message${if (messages.size > 1) "s" else ""}")
thrift.ResultCode.OK
}
}
Expand Down Expand Up @@ -95,6 +95,7 @@ trait MockCollector { this: Specification =>
while (results.size < 1 && System.currentTimeMillis - start < MaxAwaitTimeout) {
Thread.sleep(AwaitStep)
}
println(System.currentTimeMillis() % 100000 + " waited for " + (System.currentTimeMillis - start) + " ms, got " + results.size() + " spans")
val spans = results.map(e => decodeSpan(e.message))
results.clear()
spans.size mustEqual 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,63 +78,84 @@ class PlayTracingSpec extends PlaySpecification with TracingTestCommons with Moc
}

"use play application name as the default end point name" in new WithApplication(fakeApplication) {
println(System.currentTimeMillis() % 100000 + " before call 1")
val result = route(FakeRequest("GET", TestPath)).map(Await.result(_, defaultAwaitTimeout.duration))
println(System.currentTimeMillis() % 100000 + " before receive span 1")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 1")
span.annotations.map(_.get_host().get_service_name()) must beEqualTo(_root_.play.libs.Akka.system.name).forall
}

"enable overriding the service name for the end point name" in new WithApplication(overriddenApplication(overriddenServiceName = "test service")) {
println(System.currentTimeMillis() % 100000 + " before call 2")
val result = route(FakeRequest("GET", TestPath)).map(Await.result(_, defaultAwaitTimeout.duration))
println(System.currentTimeMillis() % 100000 + " before receive span 2")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 2")
span.annotations.map(_.get_host().get_service_name()) must beEqualTo("test service").forall
}

"not allow to use RequestHeaders as child of other request" in new WithApplication(fakeApplication) {
println(System.currentTimeMillis() % 100000 + " before call 3")
val parent = new TracingSupport {}
val request = FakeRequest("GET", TestPath)
println(System.currentTimeMillis() % 100000 + " before receive span 3")
new PlayControllerTracing {
request.asChildOf(parent)
} must throwA[IllegalStateException]
}

"annotate sampled requests (general)" in new WithApplication(fakeApplication) {
println(System.currentTimeMillis() % 100000 + " before call 4")
val result = route(FakeRequest("GET", TestPath)).map(Await.result(_, defaultAwaitTimeout.duration))
println(System.currentTimeMillis() % 100000 + " before receive span 4")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 4")
checkBinaryAnnotation(span, "request.path", TestPath)
checkBinaryAnnotation(span, "request.method", "GET")
checkBinaryAnnotation(span, "request.secure", false)
checkBinaryAnnotation(span, "request.proto", "HTTP/1.1")
}

"annotate sampled requests (query params, headers)" in new WithApplication(fakeApplication) {
println(System.currentTimeMillis() % 100000 + " before call 5")
val result = route(FakeRequest("GET", TestPath + "?key=value",
FakeHeaders(Seq("Content-Type" -> Seq("text/plain"))), AnyContentAsEmpty)).map(Await.result(_, defaultAwaitTimeout.duration))
println(System.currentTimeMillis() % 100000 + " before receive span 5")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 5")
checkBinaryAnnotation(span, "request.headers.Content-Type", "text/plain")
checkBinaryAnnotation(span, "request.query.key", "value")
}

"exclude specific query values from annotations when configured" in new WithApplication(overriddenApplication(queryParams = Set("excludedParam"))) {
println(System.currentTimeMillis() % 100000 + " before call 6")
val result = route(FakeRequest("GET", TestPath + "?key=value&excludedParam=value",
FakeHeaders(Seq("Content-Type" -> Seq("text/plain"))), AnyContentAsEmpty)).map(Await.result(_, defaultAwaitTimeout.duration))
println(System.currentTimeMillis() % 100000 + " before receive span 6")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 6")
checkBinaryAnnotation(span, "request.query.key", "value")
checkAbsentBinaryAnnotation(span, "request.query.excludedParam")
}

"exclude specific header fields from annotations when configured" in new WithApplication(overriddenApplication(headerKeys = Set("Excluded"))) {
println(System.currentTimeMillis() % 100000 + " before call 7")
val result = route(FakeRequest("GET", TestPath,
FakeHeaders(Seq(
"Content-Type" -> Seq("text/plain"),
"Excluded" -> Seq("test"),
"Included" -> Seq("value")
)), AnyContentAsEmpty)).map(Await.result(_, defaultAwaitTimeout.duration))
println(System.currentTimeMillis() % 100000 + " before receive span 7")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 7")
checkBinaryAnnotation(span, "request.headers.Included", "value")
checkAbsentBinaryAnnotation(span, "request.headers.Excluded")
}

"propagate tracing headers" in new WithApplication(fakeApplication) {
println(System.currentTimeMillis() % 100000 + " before call 8")
val spanId = Random.nextLong
val parentId = Random.nextLong

Expand All @@ -144,14 +165,19 @@ class PlayTracingSpec extends PlaySpecification with TracingTestCommons with Moc
TracingHeaders.ParentSpanId -> Seq(SpanMetadata.idToString(parentId))
)), AnyContentAsEmpty)).map(Await.result(_, defaultAwaitTimeout.duration))

println(System.currentTimeMillis() % 100000 + " before receive span 8")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 8")
checkBinaryAnnotation(span, "request.headers." + TracingHeaders.TraceId, SpanMetadata.idToString(spanId))
checkBinaryAnnotation(span, "request.headers." + TracingHeaders.ParentSpanId, SpanMetadata.idToString(parentId))
}

"record server errors to traces" in new WithApplication(fakeApplication) {
println(System.currentTimeMillis() % 100000 + " before call 9")
val result = route(FakeRequest("GET", TestErrorPath)).map(Await.result(_, defaultAwaitTimeout.duration))
println(System.currentTimeMillis() % 100000 + " before receive span 9")
val span = receiveSpan()
println(System.currentTimeMillis() % 100000 + " after receive span 9")
checkAnnotation(span, TracingExtension.getStackTrace(npe))
}

Expand Down
2 changes: 2 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ object AkkaTracingBuild extends Build {
// TODO: check why %% doesn't work
previousArtifact := Some(organization.value % (moduleName.value + '_' + scalaBinaryVersion.value) % "0.4"),
scalacOptions in Test ++= Seq("-Yrangepos"),
parallelExecution in ThisBuild := false,
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
testOptions in Test := Seq(Tests.Filter(!"true".equals(System.getenv("CI")) || !_.contains("Performance")))
)

Expand Down

0 comments on commit fc8ad34

Please sign in to comment.