diff options
author | Diego <diegolparra@gmail.com> | 2014-05-07 22:45:34 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-05-07 22:45:34 -0300 |
commit | 1704a8515a73a806e594e980bfeee25ce36d3bae (patch) | |
tree | 5cf9d3f7da0a63e1ee232c30692e6d0e2a2c1521 /kamon-core/src/test/scala/kamon | |
parent | f08cb7395f1b18cd473d876fa862bfdebe61788c (diff) | |
download | Kamon-1704a8515a73a806e594e980bfeee25ce36d3bae.tar.gz Kamon-1704a8515a73a806e594e980bfeee25ce36d3bae.tar.bz2 Kamon-1704a8515a73a806e594e980bfeee25ce36d3bae.zip |
= core: fixed ActorMetricsSpec
Diffstat (limited to 'kamon-core/src/test/scala/kamon')
-rw-r--r-- | kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala b/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala index 2144bd55..0f0bb475 100644 --- a/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala @@ -15,9 +15,9 @@ package kamon.metrics -import org.scalatest.{ WordSpecLike, Matchers } -import akka.testkit.{ TestProbe, TestKitBase } -import akka.actor.{ ActorRef, Actor, Props, ActorSystem } +import org.scalatest.{WordSpecLike, Matchers} +import akka.testkit.{TestProbe, TestKitBase} +import akka.actor.{ActorRef, Actor, Props, ActorSystem} import com.typesafe.config.ConfigFactory import scala.concurrent.duration._ import kamon.Kamon @@ -87,9 +87,10 @@ class ActorMetricsSpec extends TestKitBase with WordSpecLike with Matchers { // process the tick in which the actor is stalled. val stalledTickMetrics = expectActorMetrics("user/tracked-mailbox-size-queueing-up", metricsListener, 2 seconds) - stalledTickMetrics.mailboxSize.numberOfMeasurements should equal(1) + stalledTickMetrics.mailboxSize.numberOfMeasurements should equal(31) // only the automatic last-value recording should be taken, and includes the message being currently processed. - stalledTickMetrics.mailboxSize.measurements should contain only (Measurement(10, 1)) + stalledTickMetrics.mailboxSize.measurements should contain only (Measurement(0, 10), Measurement(10, 21)) + stalledTickMetrics.mailboxSize.min should equal(0) stalledTickMetrics.mailboxSize.max should equal(10) stalledTickMetrics.processingTime.numberOfMeasurements should be(0L) stalledTickMetrics.timeInMailbox.numberOfMeasurements should be(0L) @@ -101,19 +102,20 @@ class ActorMetricsSpec extends TestKitBase with WordSpecLike with Matchers { afterStallTickMetrics.processingTime.max should be(2500.milliseconds.toNanos +- 100.milliseconds.toNanos) afterStallTickMetrics.timeInMailbox.max should be(2500.milliseconds.toNanos +- 100.milliseconds.toNanos) } - } - "track the number of errors" in new ErrorActorFixture { - val (error, metricsListener) = failedActor("tracked-errors") + "track the number of errors" in new ErrorActorFixture { + val (error, metricsListener) = failedActor("tracked-errors") - for (_ ← 1 to 5) { - error ! Error - } + for (_ ← 1 to 5) { + error ! Error + } - val actorMetrics = expectActorMetrics("user/tracked-errors", metricsListener, 3 seconds) - actorMetrics.errorCounter.numberOfMeasurements should be(5L) + val actorMetrics = expectActorMetrics("user/tracked-errors", metricsListener, 3 seconds) + actorMetrics.errorCounter.numberOfMeasurements should be(5L) + } } + def expectActorMetrics(actorPath: String, listener: TestProbe, waitTime: FiniteDuration): ActorMetricSnapshot = { val tickSnapshot = within(waitTime) { listener.expectMsgType[TickMetricSnapshot] @@ -148,21 +150,25 @@ class ActorMetricsSpec extends TestKitBase with WordSpecLike with Matchers { (actor, metricsListener) } } + } class DelayableActor extends Actor { def receive = { case Delay(time) ⇒ Thread.sleep(time.toMillis) - case Discard ⇒ + case Discard ⇒ } } class FailedActor extends Actor { def receive = { - case Error ⇒ 1 / 0 + case Error ⇒ 1 / 0 case Discard ⇒ } } + case object Discard + case class Delay(time: FiniteDuration) + case class Error() |