-
Notifications
You must be signed in to change notification settings - Fork 869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add prometheus smoke test #5417
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/PrometheusSmokeTest.groovy
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,56 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.smoketest | ||
|
||
import io.opentelemetry.testing.internal.armeria.client.WebClient | ||
import java.time.Duration | ||
import spock.lang.IgnoreIf | ||
|
||
import static io.opentelemetry.smoketest.TestContainerManager.useWindowsContainers | ||
|
||
@IgnoreIf({ useWindowsContainers() }) | ||
class PrometheusSmokeTest extends SmokeTest { | ||
private static final int PROMETHEUS_PORT = 9090 | ||
|
||
protected String getTargetImage(String jdk) { | ||
"ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-spring-boot:jdk$jdk-20211213.1570880324" | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getExtraEnv() { | ||
return Map.of("OTEL_METRICS_EXPORTER", "prometheus", "OTEL_EXPORTER_PROMETHEUS_PORT", PROMETHEUS_PORT.toString()) | ||
} | ||
|
||
@Override | ||
protected TargetWaitStrategy getWaitStrategy() { | ||
return new TargetWaitStrategy.Log(Duration.ofMinutes(1), ".*Started SpringbootApplication in.*") | ||
} | ||
|
||
protected List<ResourceMapping> getExtraPorts() { | ||
return [PROMETHEUS_PORT] | ||
} | ||
|
||
def "Should export metrics"(int jdk) { | ||
setup: | ||
startTarget(jdk) | ||
|
||
when: | ||
client().get("/greeting").aggregate().join() | ||
|
||
then: | ||
def prometheusClient = WebClient.of("h1c://localhost:${containerManager.getTargetMappedPort(9090)}") | ||
def prometheusData = prometheusClient.get("/").aggregate().join().contentUtf8() | ||
|
||
prometheusData.contains("runtime_jvm_memory_pool") | ||
|
||
cleanup: | ||
stopTarget() | ||
|
||
where: | ||
jdk << [8, 11, 17] | ||
} | ||
|
||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was the issue with passing it to
withExposedPorts()
below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also the
withPortBindings
part. I don't have an easy way to test on windows so I chose to leave it unimplemented instead of adding something that might not work. This test doesn't run on windows anyway.