-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate AkkaActorTest to scala (open-telemetry#5582)
- Loading branch information
Showing
6 changed files
with
141 additions
and
45 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
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
45 changes: 0 additions & 45 deletions
45
instrumentation/akka/akka-actor-2.5/javaagent/src/test/groovy/AkkaActorTest.groovy
This file was deleted.
Oops, something went wrong.
128 changes: 128 additions & 0 deletions
128
...5/javaagent/src/test/scala/io/opentelemetry/instrumentation/akkaactor/AkkaActorTest.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,128 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.akkaactor | ||
|
||
import collection.JavaConverters._ | ||
import io.opentelemetry.api.common.Attributes | ||
import io.opentelemetry.instrumentation.testing.junit.{ | ||
AgentInstrumentationExtension, | ||
InstrumentationExtension | ||
} | ||
import io.opentelemetry.sdk.testing.assertj.{SpanDataAssert, TraceAssert} | ||
import org.junit.jupiter.api.TestInstance | ||
import org.junit.jupiter.api.extension.RegisterExtension | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ValueSource | ||
import scala.compat.java8.FunctionConverters._ | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class AkkaActorTest { | ||
|
||
@RegisterExtension val testing: InstrumentationExtension = | ||
AgentInstrumentationExtension.create | ||
|
||
@ParameterizedTest | ||
@ValueSource(ints = Array(1, 150)) | ||
def basicTell(count: Int): Unit = { | ||
val tester = new AkkaActors | ||
(1 to count).foreach { _ => | ||
tester.basicTell() | ||
} | ||
|
||
val assertions = (1 to count) | ||
.map(_ => | ||
((trace: TraceAssert) => { | ||
trace.hasSpansSatisfyingExactly( | ||
((span: SpanDataAssert) => { | ||
span | ||
.hasName("parent") | ||
.hasAttributes(Attributes.empty()) | ||
() | ||
}).asJava, | ||
((span: SpanDataAssert) => { | ||
span | ||
.hasName("Howdy, Akka") | ||
.hasParent(trace.getSpan(0)) | ||
.hasAttributes(Attributes.empty()) | ||
() | ||
}).asJava | ||
) | ||
() | ||
}).asJava | ||
) | ||
.asJava | ||
|
||
testing.waitAndAssertTraces(assertions) | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(ints = Array(1, 150)) | ||
def basicAsk(count: Int): Unit = { | ||
val tester = new AkkaActors | ||
(1 to count).foreach { _ => | ||
tester.basicAsk() | ||
} | ||
|
||
val assertions = (1 to count) | ||
.map(_ => | ||
((trace: TraceAssert) => { | ||
trace.hasSpansSatisfyingExactly( | ||
((span: SpanDataAssert) => { | ||
span | ||
.hasName("parent") | ||
.hasAttributes(Attributes.empty()) | ||
() | ||
}).asJava, | ||
((span: SpanDataAssert) => { | ||
span | ||
.hasName("Howdy, Akka") | ||
.hasParent(trace.getSpan(0)) | ||
.hasAttributes(Attributes.empty()) | ||
() | ||
}).asJava | ||
) | ||
() | ||
}).asJava | ||
) | ||
.asJava | ||
|
||
testing.waitAndAssertTraces(assertions) | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(ints = Array(1, 150)) | ||
def basicForward(count: Int): Unit = { | ||
val tester = new AkkaActors | ||
(1 to count).foreach { _ => | ||
tester.basicForward() | ||
} | ||
|
||
val assertions = (1 to count) | ||
.map(_ => | ||
((trace: TraceAssert) => { | ||
trace.hasSpansSatisfyingExactly( | ||
((span: SpanDataAssert) => { | ||
span | ||
.hasName("parent") | ||
.hasAttributes(Attributes.empty()) | ||
() | ||
}).asJava, | ||
((span: SpanDataAssert) => { | ||
span | ||
.hasName("Hello, Akka") | ||
.hasParent(trace.getSpan(0)) | ||
.hasAttributes(Attributes.empty()) | ||
() | ||
}).asJava | ||
) | ||
() | ||
}).asJava | ||
) | ||
.asJava | ||
|
||
testing.waitAndAssertTraces(assertions) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...javaagent/src/test/scala/AkkaActors.scala → ...nstrumentation/akkaactor/AkkaActors.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
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