diff options
author | Diego <diegolparra@gmail.com> | 2015-11-27 16:55:36 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2015-11-27 16:55:36 -0300 |
commit | e85d0b17e986ff282e542581235bdd13d14eeaeb (patch) | |
tree | 23c79bb5d9258e2effbad371369cd38893ecc045 /kamon-akka/src/test/scala | |
parent | 2893c93d24d3f658af39910ddaabd671ac8247dd (diff) | |
download | Kamon-e85d0b17e986ff282e542581235bdd13d14eeaeb.tar.gz Kamon-e85d0b17e986ff282e542581235bdd13d14eeaeb.tar.bz2 Kamon-e85d0b17e986ff282e542581235bdd13d14eeaeb.zip |
= all: bump up dependency versions and fix test
Diffstat (limited to 'kamon-akka/src/test/scala')
-rw-r--r-- | kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala | 78 | ||||
-rw-r--r-- | kamon-akka/src/test/scala/kamon/akka/dispatch/CustomDispatcherConfigurator.scala | 45 |
2 files changed, 2 insertions, 121 deletions
diff --git a/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala index 9a5ba101..05165ca5 100644 --- a/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala @@ -15,12 +15,12 @@ package kamon.akka -import akka.actor.{ ActorSystem, Props, ActorRef } +import akka.actor.{ ActorRef, Props } import akka.dispatch.MessageDispatcher import akka.routing.BalancingPool import akka.testkit.TestProbe import kamon.Kamon -import kamon.akka.RouterMetricsTestActor.{ Pong, Ping } +import kamon.akka.RouterMetricsTestActor.{ Ping, Pong } import kamon.metric.{ EntityRecorder, EntitySnapshot } import kamon.testkit.BaseKamonSpec import kamon.util.executors.{ ForkJoinPoolMetrics, ThreadPoolExecutorMetrics } @@ -34,15 +34,11 @@ class DispatcherMetricsSpec extends BaseKamonSpec("dispatcher-metrics-spec") { val defaultDispatcher = forceInit(system.dispatchers.lookup("akka.actor.default-dispatcher")) val fjpDispatcher = forceInit(system.dispatchers.lookup("tracked-fjp")) val tpeDispatcher = forceInit(system.dispatchers.lookup("tracked-tpe")) - val customForkJoinPoolBasedDispatcher = forceInit(system.dispatchers.lookup("custom-fjp-based-dispatcher")) - val customThreadPoolExecutorBasedDispatcher = forceInit(system.dispatchers.lookup("custom-tpe-based-dispatcher")) val excludedDispatcher = forceInit(system.dispatchers.lookup("explicitly-excluded")) findDispatcherRecorder(defaultDispatcher, "fork-join-pool") shouldNot be(empty) findDispatcherRecorder(fjpDispatcher, "fork-join-pool") shouldNot be(empty) findDispatcherRecorder(tpeDispatcher, "thread-pool-executor") shouldNot be(empty) - findDispatcherRecorder(customForkJoinPoolBasedDispatcher, "fork-join-pool") shouldNot be(empty) - findDispatcherRecorder(customThreadPoolExecutorBasedDispatcher, "thread-pool-executor") shouldNot be(empty) findDispatcherRecorder(excludedDispatcher, "fork-join-pool") should be(empty) } @@ -116,76 +112,6 @@ class DispatcherMetricsSpec extends BaseKamonSpec("dispatcher-metrics-spec") { findDispatcherRecorder("BalancingPool-/test-balancing-pool", "fork-join-pool") shouldNot be(empty) } - - "record metrics for a custom dispatcher with a based fork-join-executor" in { - implicit val fjpDispatcher = system.dispatchers.lookup("custom-fjp-based-dispatcher") - collectDispatcherMetrics(fjpDispatcher, "fork-join-pool") - - Await.result({ - Future.sequence { - for (_ ← 1 to 100) yield submit(fjpDispatcher) - } - }, 5 seconds) - - refreshDispatcherInstruments(fjpDispatcher, "fork-join-pool") - val snapshot = collectDispatcherMetrics(fjpDispatcher, "fork-join-pool") - - snapshot.minMaxCounter("parallelism").get.max should be(10) - snapshot.gauge("pool-size").get.min should be >= 0L - snapshot.gauge("pool-size").get.max should be <= 10L - snapshot.gauge("active-threads").get.max should be >= 0L - snapshot.gauge("running-threads").get.max should be >= 0L - snapshot.gauge("queued-task-count").get.max should be(0) - - } - - "record metrics for a custom dispatcher with a based thread-pool-executor" in { - implicit val tpeDispatcher = system.dispatchers.lookup("custom-tpe-based-dispatcher") - refreshDispatcherInstruments(tpeDispatcher, "thread-pool-executor") - collectDispatcherMetrics(tpeDispatcher, "thread-pool-executor") - - Await.result({ - Future.sequence { - for (_ ← 1 to 100) yield submit(tpeDispatcher) - } - }, 5 seconds) - - refreshDispatcherInstruments(tpeDispatcher, "thread-pool-executor") - val snapshot = collectDispatcherMetrics(tpeDispatcher, "thread-pool-executor") - - snapshot.gauge("active-threads") should not be empty - snapshot.gauge("pool-size").get.min should be >= 7L - snapshot.gauge("pool-size").get.max should be <= 21L - snapshot.gauge("max-pool-size").get.max should be(21) - snapshot.gauge("core-pool-size").get.max should be(21) - snapshot.gauge("processed-tasks").get.max should be(102L +- 5L) - - // The processed tasks should be reset to 0 if no more tasks are submitted. - val secondSnapshot = collectDispatcherMetrics(tpeDispatcher, "thread-pool-executor") - secondSnapshot.gauge("processed-tasks").get.max should be(0) - } - - "record metrics for a custom default dispatcher with a based fork-join-pool" in { - implicit val fjpDispatcher = ActorSystem("system-with-fjp-based-dispatcher", config.getConfig("actor-system-with-default-custom-fjp-based-dispatcher")).dispatcher.asInstanceOf[MessageDispatcher] - collectDispatcherMetrics(fjpDispatcher, "fork-join-pool") - - Await.result({ - Future.sequence { - for (_ ← 1 to 100) yield submit(fjpDispatcher) - } - }, 5 seconds) - - refreshDispatcherInstruments(fjpDispatcher, "fork-join-pool") - val snapshot = collectDispatcherMetrics(fjpDispatcher, "fork-join-pool") - - snapshot.minMaxCounter("parallelism").get.max should be(12) - snapshot.gauge("pool-size").get.min should be >= 0L - snapshot.gauge("pool-size").get.max should be <= 10L - snapshot.gauge("active-threads").get.max should be >= 0L - snapshot.gauge("running-threads").get.max should be >= 0L - snapshot.gauge("queued-task-count").get.max should be(0) - - } } def actorRecorderName(ref: ActorRef): String = ref.path.elements.mkString("/") diff --git a/kamon-akka/src/test/scala/kamon/akka/dispatch/CustomDispatcherConfigurator.scala b/kamon-akka/src/test/scala/kamon/akka/dispatch/CustomDispatcherConfigurator.scala deleted file mode 100644 index 8b7660d6..00000000 --- a/kamon-akka/src/test/scala/kamon/akka/dispatch/CustomDispatcherConfigurator.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* ========================================================================================= - * Copyright © 2013-2015 the kamon project <http://kamon.io/> - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - * ========================================================================================= - */ - -package kamon.akka.dispatch - -import java.util.concurrent.TimeUnit - -import akka.dispatch._ -import com.typesafe.config.Config -import scala.concurrent.duration.{ Duration, FiniteDuration } - -class CustomDispatcherConfigurator(config: Config, prerequisites: DispatcherPrerequisites) - extends MessageDispatcherConfigurator(config, prerequisites) { - - private val instance = new AwesomeDispatcher( - this, - config.getString("id"), - config.getInt("throughput"), - FiniteDuration(config.getDuration("throughput-deadline-time", TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS), - configureExecutor(), - FiniteDuration(config.getDuration("shutdown-timeout", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)) - - override def dispatcher(): MessageDispatcher = instance -} - -class AwesomeDispatcher(_configurator: MessageDispatcherConfigurator, - id: String, - throughput: Int, - throughputDeadlineTime: Duration, - executorServiceFactoryProvider: ExecutorServiceFactoryProvider, - shutdownTimeout: FiniteDuration) - extends Dispatcher(_configurator, id, throughput, throughputDeadlineTime, executorServiceFactoryProvider, shutdownTimeout) { -} |