diff options
Diffstat (limited to 'src/test')
5 files changed, 0 insertions, 234 deletions
diff --git a/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala b/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala deleted file mode 100644 index 1a0e509f..00000000 --- a/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala +++ /dev/null @@ -1,43 +0,0 @@ -package akka.instrumentation - -import org.scalatest.{Matchers, WordSpec} -import akka.actor.{Actor, Props, ActorSystem} -import kamon.metric.Metrics._ -import scala.collection.JavaConverters._ -import akka.testkit.TestActorRef - - -class ActorInstrumentationSpec extends WordSpec with Matchers { - implicit val system = ActorSystem() - import system._ - - val echoRef = actorOf(Props(new EchoActor), "Echo-Actor") - val meterForEchoActor = "meter-for-akka://default/user/Echo-Actor" - val totalMessages = 1000 - - "an instrumented Actor" should { - "send a message and record a metric on the Metrics Registry with the number of sent messages" in { - - val echoActor = TestActorRef[EchoActor] - - - - (1 to totalMessages).foreach {x:Int => - echoActor ! s"Message ${x}" - } - - //val messages = registry.getMeters.asScala.get(meterForEchoActor).get.getCount - - //messages should equal(totalMessages) - } - } - -} - -class EchoActor extends Actor { - def receive = { - case msg ⇒ sender ! msg - } -} - - diff --git a/src/test/scala/kamon/instrumentation/ActorSystemInstrumentationSpec.scala b/src/test/scala/kamon/instrumentation/ActorSystemInstrumentationSpec.scala deleted file mode 100644 index 1eab6355..00000000 --- a/src/test/scala/kamon/instrumentation/ActorSystemInstrumentationSpec.scala +++ /dev/null @@ -1,22 +0,0 @@ -package kamon.instrumentation - -import org.scalatest.{Matchers, WordSpec} -import akka.actor.ActorSystem -import kamon.Kamon - -class ActorSystemInstrumentationSpec extends WordSpec with Matchers { - - // TODO: Selection filters to exclude unwanted actor systems. Read from configuration. - - "the actor system instrumentation" should { - "register all actor systems created" in { - val as1 = ActorSystem("as1") - val as2 = ActorSystem("as2") - - - Kamon.Metric.actorSystem("as1") should not be (None) - Kamon.Metric.actorSystem("as2") should not be (None) - Kamon.Metric.actorSystem("unknown") should be (None) - } - } -} diff --git a/src/test/scala/kamon/instrumentation/DispatcherInstrumentationSpec.scala b/src/test/scala/kamon/instrumentation/DispatcherInstrumentationSpec.scala deleted file mode 100644 index 89ef61f3..00000000 --- a/src/test/scala/kamon/instrumentation/DispatcherInstrumentationSpec.scala +++ /dev/null @@ -1,34 +0,0 @@ -package kamon.instrumentation - -import org.scalatest.{Matchers, WordSpec} -import akka.actor.{Actor, Props, ActorSystem} -import kamon.metric.MetricDirectory -import kamon.Kamon - -class DispatcherInstrumentationSpec extends WordSpec with Matchers{ - - - "the dispatcher instrumentation" should { - "instrument a dispatcher that belongs to a non-filtered actor system" in new SingleDispatcherActorSystem { - val x = Kamon.Metric.actorSystem("single-dispatcher").get.dispatchers - (1 to 10).foreach(actor ! _) - - val active = x.get("akka.actor.default-dispatcher").get.activeThreadCount.snapshot - println("Active max: "+active.max) - println("Active min: "+active.min) - - } - } - - - trait SingleDispatcherActorSystem { - val actorSystem = ActorSystem("single-dispatcher") - val actor = actorSystem.actorOf(Props(new Actor { - def receive = { - case a => sender ! a; - } - })) - - } -} - diff --git a/src/test/scala/kamon/instrumentation/MessageQueueInstrumentationSpec.scala b/src/test/scala/kamon/instrumentation/MessageQueueInstrumentationSpec.scala deleted file mode 100644 index cc55ec92..00000000 --- a/src/test/scala/kamon/instrumentation/MessageQueueInstrumentationSpec.scala +++ /dev/null @@ -1,53 +0,0 @@ -package kamon.instrumentation - -import org.scalatest.WordSpec -import com.codahale.metrics.{ExponentiallyDecayingReservoir, Histogram} -import java.util.concurrent.ConcurrentLinkedQueue -import akka.dispatch.{UnboundedMessageQueueSemantics, QueueBasedMessageQueue, Envelope} -import java.util.Queue -import akka.actor.{ActorSystem, Actor} - -class MessageQueueInstrumentationSpec(val actorSystem: ActorSystem) extends WordSpec { - def this() = this(ActorSystem("MessageQueueInstrumentationSpec")) - - - /*"A MonitoredMessageQueue" should { - "update the related histogram when a message is enqueued" in { - new PopulatedMessageQueueFixture { - - assert(histogram.getSnapshot.getMax === 0) - - for(i <- 1 to 3) { enqueueDummyMessage } - - assert(histogram.getCount === 3) - assert(histogram.getSnapshot.getMax === 3) - assert(histogram.getSnapshot.getMin === 1) - } - } - - "update the related histogram when a message is dequeued" in { - new PopulatedMessageQueueFixture { - for(i <- 1 to 3) { enqueueDummyMessage } - assert(histogram.getSnapshot.getMax === 3) - - messageQueue.dequeue() - messageQueue.dequeue() - - assert(histogram.getCount === 5) - assert(histogram.getSnapshot.getMax === 3) - assert(histogram.getSnapshot.getMin === 1) - } - } - } - - trait PopulatedMessageQueueFixture { - - val histogram = new Histogram(new ExponentiallyDecayingReservoir()) -/* val delegate = new ConcurrentLinkedQueue[Envelope]() with QueueBasedMessageQueue with UnboundedMessageQueueSemantics { - final def queue: Queue[Envelope] = this - }*/ - val messageQueue = new MonitoredMessageQueue(delegate, histogram) - - def enqueueDummyMessage = messageQueue.enqueue(Actor.noSender, Envelope("", Actor.noSender, actorSystem)) - }*/ -} diff --git a/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala b/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala deleted file mode 100644 index de65aaca..00000000 --- a/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala +++ /dev/null @@ -1,82 +0,0 @@ -package kamon.instrumentation - -import scala.concurrent.{Await, Promise, Future} -import org.scalatest.{Matchers, OptionValues, WordSpec} -import org.scalatest.concurrent.{ScalaFutures, PatienceConfiguration} -import kamon.{Kamon, TraceContext} -import java.util.UUID -import scala.util.Success -import scala.concurrent.duration._ -import java.util.concurrent.TimeUnit -import akka.actor.ActorSystem - - -class RunnableInstrumentationSpec extends WordSpec with Matchers with ScalaFutures with PatienceConfiguration with OptionValues { - - "a instrumented runnable" when { - "created in a thread that does have a TraceContext" must { - "preserve the TraceContext" which { - "should be available during the run method execution" in { new FutureWithContextFixture { - - whenReady(futureWithContext) { result => - result.value should equal(testContext) - } - }} - - "should be available during the execution of onComplete callbacks" in { new FutureWithContextFixture { - val onCompleteContext = Promise[TraceContext]() - - futureWithContext.onComplete({ - case _ => onCompleteContext.complete(Success(Kamon.context.get)) - }) - - whenReady(onCompleteContext.future) { result => - result should equal(testContext) - } - }} - } - } - - "created in a thread that doest have a TraceContext" must { - "not capture any TraceContext for the body execution" in { new FutureWithoutContextFixture{ - - whenReady(futureWithoutContext) { result => - result should equal(None) - } - }} - - "not make any TraceContext available during the onComplete callback" in { new FutureWithoutContextFixture { - val onCompleteContext = Promise[Option[TraceContext]]() - - futureWithoutContext.onComplete({ - case _ => onCompleteContext.complete(Success(Kamon.context)) - }) - - whenReady(onCompleteContext.future) { result => - result should equal(None) - } - }} - } - } - - - /** - * We are using Futures for the test since they exercise Runnables in the back and also resemble the real use case we have. - */ - implicit val testActorSystem = ActorSystem("test-actorsystem") - implicit val execContext = testActorSystem.dispatcher - - class FutureWithContextFixture { - val testContext = TraceContext() - Kamon.set(testContext) - - val futureWithContext = Future { Kamon.context} - } - - trait FutureWithoutContextFixture { - Kamon.clear // Make sure no TraceContext is available - val futureWithoutContext = Future { Kamon.context } - } -} - - |