-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migrate Guava tests to Java * Update instrumentation/guava-10.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/guava/ListenableFutureTest.java Co-authored-by: Lauri Tulmin <[email protected]> * Workaround inline mock issue Co-authored-by: Trask Stalnaker <[email protected]> Co-authored-by: Lauri Tulmin <[email protected]>
- Loading branch information
1 parent
7a46953
commit 14372ad
Showing
32 changed files
with
461 additions
and
559 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
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
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
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
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
129 changes: 0 additions & 129 deletions
129
instrumentation/guava-10.0/javaagent/src/test/groovy/GuavaWithSpanInstrumentationTest.groovy
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
instrumentation/guava-10.0/javaagent/src/test/groovy/ListenableFutureTest.groovy
This file was deleted.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
...va/io/opentelemetry/javaagent/instrumentation/guava/GuavaWithSpanInstrumentationTest.java
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,106 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.guava; | ||
|
||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.attributeEntry; | ||
|
||
import com.google.common.util.concurrent.Futures; | ||
import com.google.common.util.concurrent.SettableFuture; | ||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.trace.SpanKind; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import io.opentelemetry.sdk.trace.data.StatusData; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class GuavaWithSpanInstrumentationTest { | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
@Test | ||
void success() { | ||
SettableFuture<String> future = SettableFuture.create(); | ||
new TracedWithSpan().listenableFuture(future); | ||
future.set("Value"); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("TracedWithSpan.listenableFuture") | ||
.hasKind(SpanKind.INTERNAL) | ||
.hasNoParent() | ||
.hasAttributes(Attributes.empty()))); | ||
} | ||
|
||
@Test | ||
void failure() { | ||
IllegalArgumentException error = new IllegalArgumentException("Boom"); | ||
SettableFuture<String> future = SettableFuture.create(); | ||
new TracedWithSpan().listenableFuture(future); | ||
future.setException(error); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("TracedWithSpan.listenableFuture") | ||
.hasKind(SpanKind.INTERNAL) | ||
.hasNoParent() | ||
.hasStatus(StatusData.error()) | ||
.hasException(error) | ||
.hasAttributes(Attributes.empty()))); | ||
} | ||
|
||
@Test | ||
void canceled() { | ||
SettableFuture<String> future = SettableFuture.create(); | ||
new TracedWithSpan().listenableFuture(future); | ||
future.cancel(true); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("TracedWithSpan.listenableFuture") | ||
.hasKind(SpanKind.INTERNAL) | ||
.hasNoParent() | ||
.hasAttributes(attributeEntry("guava.canceled", true)))); | ||
} | ||
|
||
@Test | ||
void immediateSuccess() { | ||
new TracedWithSpan().listenableFuture(Futures.immediateFuture("Value")); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("TracedWithSpan.listenableFuture") | ||
.hasKind(SpanKind.INTERNAL) | ||
.hasNoParent() | ||
.hasAttributes(Attributes.empty()))); | ||
} | ||
|
||
@Test | ||
void immediateFailure() { | ||
IllegalArgumentException error = new IllegalArgumentException("Boom"); | ||
new TracedWithSpan().listenableFuture(Futures.immediateFailedFuture(error)); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("TracedWithSpan.listenableFuture") | ||
.hasKind(SpanKind.INTERNAL) | ||
.hasNoParent() | ||
.hasStatus(StatusData.error()) | ||
.hasException(error) | ||
.hasAttributes(Attributes.empty()))); | ||
} | ||
} |
Oops, something went wrong.