diff options
author | Diego <diegolparra@gmail.com> | 2016-12-04 15:37:51 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2016-12-04 15:37:51 -0300 |
commit | 56039ef037d42cb817d0bc6d5a5891bc87e633c3 (patch) | |
tree | 711d36b49d69f7321ea75172d9d4969e318d7afe /kamon-core/src/test/scala | |
parent | e02d137ab960676cb89ff597bc33915f8b83a4d2 (diff) | |
download | Kamon-56039ef037d42cb817d0bc6d5a5891bc87e633c3.tar.gz Kamon-56039ef037d42cb817d0bc6d5a5891bc87e633c3.tar.bz2 Kamon-56039ef037d42cb817d0bc6d5a5891bc87e633c3.zip |
wip
Diffstat (limited to 'kamon-core/src/test/scala')
16 files changed, 78 insertions, 60 deletions
diff --git a/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala b/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala index 902102cd..d3d0f4fb 100644 --- a/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala @@ -18,7 +18,7 @@ package kamon.metric import kamon.Kamon import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot -import kamon.metric.instrument.{ InstrumentFactory, Memory, Time, UnitOfMeasurement } +import kamon.metric.instrument.{InstrumentFactory, Memory, Time, UnitOfMeasurement} import kamon.testkit.BaseKamonSpec import kamon.util.MilliTimestamp import org.scalatest.OptionValues._ @@ -28,7 +28,8 @@ class MetricScaleDecoratorSpec extends BaseKamonSpec("metrics-scale-decorator-sp "receives a snapshot" which { val scaleDecorator = system.actorOf(MetricScaleDecorator.props( - Some(Time.Milliseconds), Some(Memory.KiloBytes), testActor)) + Some(Time.Milliseconds), Some(Memory.KiloBytes), testActor + )) "is empty" should { "do nothing for empty snapshots" in { scaleDecorator ! emptySnapshot @@ -94,7 +95,8 @@ trait SnapshotFixtures { recorder.kbyteMemory.increment(100L) val nonEmptySnapshot = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map( - (testEntity -> recorder.collect(collectionContext)))) + (testEntity → recorder.collect(collectionContext)) + )) } diff --git a/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala b/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala index b8131f6e..36cc62c3 100644 --- a/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala @@ -17,7 +17,7 @@ package kamon.metric import akka.actor._ -import akka.testkit.{ TestProbe, ImplicitSender } +import akka.testkit.{TestProbe, ImplicitSender} import com.typesafe.config.ConfigFactory import kamon.Kamon import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot @@ -31,10 +31,11 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp |kamon.metric { | tick-interval = 1 hour |} - """.stripMargin) + """.stripMargin + ) lazy val metricsModule = Kamon.metrics - import metricsModule.{ entity, subscribe, unsubscribe } + import metricsModule.{entity, subscribe, unsubscribe} "the Subscriptions messaging protocol" should { "allow subscribing for a single tick" in { diff --git a/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala b/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala index 97bf0e2c..6172a9e0 100644 --- a/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala @@ -65,7 +65,8 @@ class TickMetricSnapshotBufferSpec extends BaseKamonSpec("trace-metrics-spec") w MutableRecord(10, 3), MutableRecord(20, 1), MutableRecord(30, 1), - MutableRecord(300, 1)) + MutableRecord(300, 1) + ) } } @@ -83,12 +84,14 @@ class TickMetricSnapshotBufferSpec extends BaseKamonSpec("trace-metrics-spec") w traceRecorder.elapsedTime.record(20L) traceRecorder.elapsedTime.record(30L) val firstNonEmpty = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map( - (testTraceIdentity -> traceRecorder.collect(collectionContext)))) + (testTraceIdentity → traceRecorder.collect(collectionContext)) + )) traceRecorder.elapsedTime.record(10L) traceRecorder.elapsedTime.record(10L) traceRecorder.elapsedTime.record(300L) val secondNonEmpty = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map( - (testTraceIdentity -> traceRecorder.collect(collectionContext)))) + (testTraceIdentity → traceRecorder.collect(collectionContext)) + )) } } diff --git a/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala b/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala index 7678991e..4c44dc07 100644 --- a/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala @@ -47,9 +47,10 @@ class TraceMetricsSpec extends BaseKamonSpec("trace-metrics-spec") with Implicit val snapshot = takeSnapshotOf("test-segment", "trace-segment", tags = Map( - "trace" -> "trace-with-segments", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "trace-with-segments", + "category" → "test-category", + "library" → "test-library" + )) snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) } @@ -69,18 +70,20 @@ class TraceMetricsSpec extends BaseKamonSpec("trace-metrics-spec") with Implicit takeSnapshotOf("test-segment", "trace-segment", tags = Map( - "trace" -> "closing-segment-after-trace", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "closing-segment-after-trace", + "category" → "test-category", + "library" → "test-library" + )) } segment.finish() val afterFinishSegmentSnapshot = takeSnapshotOf("test-segment", "trace-segment", tags = Map( - "trace" -> "closing-segment-after-trace", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "closing-segment-after-trace", + "category" → "test-category", + "library" → "test-library" + )) afterFinishSegmentSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) } @@ -106,9 +109,10 @@ class TraceMetricsSpec extends BaseKamonSpec("trace-metrics-spec") with Implicit val snapshot = takeSnapshotOf("test-segment-with-error", "trace-segment", tags = Map( - "trace" -> "trace-with-segments", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "trace-with-segments", + "category" → "test-category", + "library" → "test-library" + )) snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) snapshot.counter("errors").get.count should be(1) diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala index 850200d4..d5d651e5 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala @@ -18,7 +18,7 @@ package kamon.metric.instrument import java.nio.LongBuffer -import org.scalatest.{ Matchers, WordSpec } +import org.scalatest.{Matchers, WordSpec} class CounterSpec extends WordSpec with Matchers { diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala index dd60fee1..9551c6ea 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala @@ -19,7 +19,7 @@ package kamon.metric.instrument import java.nio.LongBuffer import kamon.metric.instrument.Histogram.DynamicRange -import org.scalatest.{ Matchers, WordSpec } +import org.scalatest.{Matchers, WordSpec} import scala.util.Random @@ -62,12 +62,12 @@ class HistogramSpec extends WordSpec with Matchers { snapshot.sum should be(41300) snapshot.numberOfMeasurements should be(203) - val records = snapshot.recordsIterator.map(r ⇒ r.level -> r.count).toSeq + val records = snapshot.recordsIterator.map(r ⇒ r.level → r.count).toSeq records.size should be(4) - records(0) should be(100 -> 1) - records(1) should be(200 -> 200) - records(2) should be(300 -> 1) - records(3) should be(900 -> 1) + records(0) should be(100 → 1) + records(1) should be(200 → 200) + records(2) should be(300 → 1) + records(3) should be(900 → 1) } "can be scaled" in new HistogramFixture { @@ -86,12 +86,12 @@ class HistogramSpec extends WordSpec with Matchers { snapshot.sum should be(41300000) snapshot.numberOfMeasurements should be(203) - val records = snapshot.recordsIterator.map(r ⇒ r.level -> r.count).toSeq + val records = snapshot.recordsIterator.map(r ⇒ r.level → r.count).toSeq records.size should be(4) - records(0) should be(100000 -> 1) - records(1) should be(200000 -> 200) - records(2) should be(300000 -> 1) - records(3) should be(900000 -> 1) + records(0) should be(100000 → 1) + records(1) should be(200000 → 200) + records(2) should be(300000 → 1) + records(3) should be(900000 → 1) } "can be merged with another snapshot" in new MultipleHistogramFixture { diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala index 7acfc229..d007d4cd 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala @@ -20,7 +20,7 @@ import java.nio.LongBuffer import akka.actor._ import akka.testkit.TestProbe import kamon.Kamon -import kamon.metric.instrument.Histogram.{ DynamicRange, MutableRecord } +import kamon.metric.instrument.Histogram.{DynamicRange, MutableRecord} import kamon.testkit.BaseKamonSpec import scala.concurrent.duration._ @@ -38,7 +38,8 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { snapshot.max should be(5) snapshot.recordsIterator.toStream should contain allOf ( MutableRecord(0, 1), // min - MutableRecord(5, 2)) // max and current + MutableRecord(5, 2) + ) // max and current } "track descending tendencies" in new MinMaxCounterFixture { @@ -53,7 +54,8 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { snapshot.max should be(5) snapshot.recordsIterator.toStream should contain allOf ( MutableRecord(0, 2), // min and current - MutableRecord(5, 1)) // max + MutableRecord(5, 1) + ) // max } "reset the min and max to the current value after taking a snapshot" in new MinMaxCounterFixture { @@ -67,14 +69,16 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { firstSnapshot.recordsIterator.toStream should contain allOf ( MutableRecord(0, 1), // min MutableRecord(2, 1), // current - MutableRecord(5, 1)) // max + MutableRecord(5, 1) + ) // max val secondSnapshot = collectCounterSnapshot() secondSnapshot.min should be(2) secondSnapshot.max should be(2) secondSnapshot.recordsIterator.toStream should contain( - MutableRecord(2, 3)) // min, max and current + MutableRecord(2, 3) + ) // min, max and current } "report zero as the min and current values if the current value fell bellow zero" in new MinMaxCounterFixture { @@ -85,7 +89,8 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { snapshot.min should be(0) snapshot.max should be(0) snapshot.recordsIterator.toStream should contain( - MutableRecord(0, 3)) // min, max and current (even while current really is -3 + MutableRecord(0, 3) + ) // min, max and current (even while current really is -3 } "never record values bellow zero in very busy situations" in new MinMaxCounterFixture { diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala index 10604fe5..7133579e 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala @@ -17,7 +17,7 @@ package kamon.metric.instrument import kamon.metric.instrument.UnitOfMeasurement.Unknown -import org.scalatest.{ Matchers, WordSpec } +import org.scalatest.{Matchers, WordSpec} class UnitOfMeasurementSpec extends WordSpec with Matchers { diff --git a/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala b/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala index 78c8607b..d2e569ad 100644 --- a/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala +++ b/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala @@ -17,13 +17,13 @@ package kamon.testkit import akka.actor.ActorSystem -import akka.testkit.{ ImplicitSender, TestKitBase } +import akka.testkit.{ImplicitSender, TestKitBase} import com.typesafe.config.Config import kamon.Kamon -import kamon.metric.{ Entity, EntitySnapshot, SubscriptionsDispatcher } +import kamon.metric.{Entity, EntitySnapshot, SubscriptionsDispatcher} import kamon.trace.TraceContext import kamon.util.LazyActorRef -import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpecLike } +import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} abstract class BaseKamonSpec(actorSystemName: String) extends TestKitBase with WordSpecLike with Matchers with ImplicitSender with BeforeAndAfterAll { lazy val collectionContext = Kamon.metrics.buildDefaultCollectionContext diff --git a/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala b/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala index f408ad93..faf127c1 100644 --- a/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala @@ -88,9 +88,9 @@ class SimpleTraceSpec extends BaseKamonSpec("simple-trace-spec") { "send a TraceInfo when the trace has finished and all segments are finished and both contains tags" in { Kamon.tracer.subscribe(testActor) - Tracer.withContext(newContext("simple-trace-without-segments", "awesome-token", Map("environment" -> "production"))) { - Tracer.currentContext.startSegment("segment-one", "test-segment", "test", Map("segment-one-info" -> "info")).finish() - Tracer.currentContext.startSegment("segment-two", "test-segment", "test", Map("segment-two-info" -> "info")).finish() + Tracer.withContext(newContext("simple-trace-without-segments", "awesome-token", Map("environment" → "production"))) { + Tracer.currentContext.startSegment("segment-one", "test-segment", "test", Map("segment-one-info" → "info")).finish() + Tracer.currentContext.startSegment("segment-two", "test-segment", "test", Map("segment-two-info" → "info")).finish() Tracer.currentContext.finish() } @@ -98,14 +98,14 @@ class SimpleTraceSpec extends BaseKamonSpec("simple-trace-spec") { Kamon.tracer.unsubscribe(testActor) traceInfo.name should be("simple-trace-without-segments") - traceInfo.tags should be(Map("environment" -> "production")) + traceInfo.tags should be(Map("environment" → "production")) traceInfo.segments.size should be(2) val segmentOne = traceInfo.segments.find(_.name == "segment-one") val segmentTwo = traceInfo.segments.find(_.name == "segment-two") - segmentOne.get.tags should be(Map("segment-one-info" -> "info")) - segmentTwo.get.tags should be(Map("segment-two-info" -> "info")) + segmentOne.get.tags should be(Map("segment-one-info" → "info")) + segmentTwo.get.tags should be(Map("segment-two-info" → "info")) } "incubate the tracing context if there are open segments after finishing" in { diff --git a/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala b/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala index 58b51a73..d817186a 100644 --- a/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala @@ -70,7 +70,7 @@ class TraceContextManipulationSpec extends BaseKamonSpec("trace-metrics-spec") { } Tracer.currentContext shouldBe empty - createdContext.tags shouldBe Map("trace-tag" -> "tag-1") + createdContext.tags shouldBe Map("trace-tag" → "tag-1") createdContext.removeTag("trace-tag", "tag-1") @@ -103,7 +103,7 @@ class TraceContextManipulationSpec extends BaseKamonSpec("trace-metrics-spec") { segment.tags should be(Map.empty) segment.addTag("segment-tag", "tag-1") - segment.tags should be(Map("segment-tag" -> "tag-1")) + segment.tags should be(Map("segment-tag" → "tag-1")) segment.removeTag("segment-tag", "tag-1") segment.tags should be(Map.empty) diff --git a/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala b/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala index 6193f028..39374e79 100644 --- a/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala @@ -1,7 +1,7 @@ package kamon.trace.logging import kamon.testkit.BaseKamonSpec -import kamon.trace.{ EmptyTraceContext, Tracer } +import kamon.trace.{EmptyTraceContext, Tracer} import org.slf4j.MDC class MdcKeysSupportSpec extends BaseKamonSpec("mdc-keys-support-spec") { diff --git a/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala b/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala index ab98d0ac..7d585087 100644 --- a/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala @@ -16,7 +16,7 @@ package kamon.util -import org.scalatest.{ Matchers, WordSpecLike } +import org.scalatest.{Matchers, WordSpecLike} class GlobPathFilterSpec extends WordSpecLike with Matchers { "The GlobPathFilter" should { diff --git a/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala b/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala index a53451b6..cba6ad98 100644 --- a/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala @@ -17,8 +17,8 @@ package kamon.util import com.typesafe.config.ConfigFactory -import kamon.metric.instrument.{ Memory, Time } -import org.scalatest.{ Matchers, WordSpec } +import kamon.metric.instrument.{Memory, Time} +import org.scalatest.{Matchers, WordSpec} class NeedToScaleSpec extends WordSpec with Matchers { @@ -27,7 +27,8 @@ class NeedToScaleSpec extends WordSpec with Matchers { val config = ConfigFactory.parseString( """ |time-units = "ms" - """.stripMargin) + """.stripMargin + ) config match { case NeedToScale(timeUnits, memoryUnits) ⇒ @@ -39,7 +40,8 @@ class NeedToScaleSpec extends WordSpec with Matchers { val config = ConfigFactory.parseString( """ |memory-units = "kb" - """.stripMargin) + """.stripMargin + ) config match { case NeedToScale(timeUnits, memoryUnits) ⇒ @@ -51,7 +53,8 @@ class NeedToScaleSpec extends WordSpec with Matchers { val config = ConfigFactory.parseString( """ |some-other-key = "value" - """.stripMargin) + """.stripMargin + ) config match { case NeedToScale(timeUnits, memoryUnits) ⇒ diff --git a/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala b/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala index edbf14b3..a2cc8629 100644 --- a/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala @@ -16,7 +16,7 @@ package kamon.util -import org.scalatest.{ Matchers, WordSpecLike } +import org.scalatest.{Matchers, WordSpecLike} class RegexPathFilterSpec extends WordSpecLike with Matchers { "The RegexPathFilter" should { diff --git a/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala b/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala index a0275b33..4e5394f8 100644 --- a/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala @@ -19,7 +19,7 @@ package kamon.util.executors import java.util.concurrent.Executors import kamon.Kamon -import kamon.metric.{ Entity, EntityRecorder } +import kamon.metric.{Entity, EntityRecorder} import kamon.testkit.BaseKamonSpec class ExecutorServiceMetricsSpec extends BaseKamonSpec("executor-service-metrics-spec") { |