-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Two simple tests for the ServerResponsetime Hadoop jobs
Author: @johanoskarsson Pull Request: #28 URL: #28
- Loading branch information
1 parent
73105fd
commit 741c3c9
Showing
2 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
zipkin-hadoop/src/main/test/com/twitter/zipkin/hadoop/ServerResponsetimeSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.twitter.zipkin.hadoop | ||
|
||
import org.specs.Specification | ||
import com.twitter.zipkin.gen | ||
import com.twitter.scalding._ | ||
import sources.SpanSource | ||
import scala.collection.JavaConverters._ | ||
|
||
class ServerResponsetimeSpec extends Specification with TupleConversions { | ||
noDetailedDiffs() | ||
|
||
implicit val dateRange = DateRange(RichDate(123), RichDate(321)) | ||
|
||
val endpoint = new gen.Endpoint(123, 666, "service") | ||
val span = new gen.Span(12345, "methodcall", 666, | ||
List(new gen.Annotation(1000, "sr").setHost(endpoint), new gen.Annotation(2000, "ss").setHost(endpoint)).asJava, | ||
List[gen.BinaryAnnotation]().asJava) | ||
|
||
|
||
"ServerResponsetime" should { | ||
"have no output if input is < 100 entries" in { | ||
JobTest("com.twitter.zipkin.hadoop.ServerResponsetime"). | ||
arg("input", "inputFile"). | ||
arg("output", "outputFile"). | ||
arg("date", "2012-01-01T01:00"). | ||
source(SpanSource(), List(span -> 0)). | ||
sink[(String, Int)](Tsv("outputFile")) { | ||
outputBuffer => outputBuffer.toMap mustEqual Map() | ||
}.run.finish | ||
} | ||
"return one entry with avg 1 ms" in { | ||
JobTest("com.twitter.zipkin.hadoop.ServerResponsetime"). | ||
arg("input", "inputFile"). | ||
arg("output", "outputFile"). | ||
arg("date", "2012-01-01T01:00"). | ||
source(SpanSource(), repeatSpan(span, 101)). | ||
sink[(String, String, Double, Double, Double)](Tsv("outputFile")) { | ||
outputBuffer => outputBuffer foreach { e => | ||
e mustEqual ("0.0.0.123", "service", 102d, 1d, 0d) | ||
} | ||
}.run.finish | ||
} | ||
|
||
} | ||
|
||
def repeatSpan(span: gen.Span, count: Int): List[(gen.Span, Int)] = { | ||
((0 to count).toSeq map { i: Int => span.deepCopy().setId(i) -> i }).toList | ||
} | ||
} |