|
@@ -3,11 +3,10 @@
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
*/
|
|
|
|
|
|
-package io.opentelemetry.smoketest;
|
|
|
+package io.opentelemetry.spring.smoketest;
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
-import io.opentelemetry.api.OpenTelemetry;
|
|
|
import io.opentelemetry.api.common.AttributeKey;
|
|
|
import io.opentelemetry.api.common.Attributes;
|
|
|
import io.opentelemetry.api.trace.SpanKind;
|
|
@@ -26,20 +25,13 @@ import io.opentelemetry.semconv.UrlAttributes;
|
|
|
import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes;
|
|
|
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
|
import io.opentelemetry.semconv.incubating.ServiceIncubatingAttributes;
|
|
|
-import io.opentelemetry.spring.smoketest.AbstractSpringStarterSmokeTest;
|
|
|
-import io.opentelemetry.spring.smoketest.OtelSpringStarterSmokeTestApplication;
|
|
|
-import io.opentelemetry.spring.smoketest.OtelSpringStarterSmokeTestController;
|
|
|
-import io.opentelemetry.spring.smoketest.SpringSmokeOtelConfiguration;
|
|
|
-import io.opentelemetry.spring.smoketest.SpringSmokeTestRunner;
|
|
|
import java.util.Collections;
|
|
|
import org.assertj.core.api.AbstractCharSequenceAssert;
|
|
|
import org.assertj.core.api.AbstractIterableAssert;
|
|
|
-import org.junit.jupiter.api.BeforeEach;
|
|
|
import org.junit.jupiter.api.MethodOrderer;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.junit.jupiter.api.TestMethodOrder;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
@@ -49,23 +41,9 @@ import org.springframework.core.env.Environment;
|
|
|
/**
|
|
|
* This test class enforces the order of the tests to make sure that {@link #shouldSendTelemetry()},
|
|
|
* which asserts the telemetry data from the application startup, is executed first.
|
|
|
- *
|
|
|
- * <p>The exporters are not reset using {@link org.junit.jupiter.api.BeforeEach}, because it would
|
|
|
- * prevent the telemetry data from the application startup to be asserted.
|
|
|
*/
|
|
|
-@SpringBootTest(
|
|
|
- classes = {
|
|
|
- OtelSpringStarterSmokeTestApplication.class,
|
|
|
- OtelSpringStarterSmokeTest.TestConfiguration.class,
|
|
|
- SpringSmokeOtelConfiguration.class
|
|
|
- },
|
|
|
- webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
|
|
- properties = {
|
|
|
- // The headers are simply set here to make sure that headers can be parsed
|
|
|
- "otel.exporter.otlp.headers.c=3"
|
|
|
- })
|
|
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
|
-class OtelSpringStarterSmokeTest extends AbstractSpringStarterSmokeTest {
|
|
|
+class AbstractOtelSpringStarterSmokeTest extends AbstractSpringStarterSmokeTest {
|
|
|
|
|
|
@Autowired private TestRestTemplate testRestTemplate;
|
|
|
|
|
@@ -74,13 +52,6 @@ class OtelSpringStarterSmokeTest extends AbstractSpringStarterSmokeTest {
|
|
|
@Autowired private OtelResourceProperties otelResourceProperties;
|
|
|
@Autowired private OtlpExporterProperties otlpExporterProperties;
|
|
|
|
|
|
- @Autowired OpenTelemetry openTelemetry;
|
|
|
-
|
|
|
- @BeforeEach
|
|
|
- void initOpenTelemetry() {
|
|
|
- testing = new SpringSmokeTestRunner(openTelemetry);
|
|
|
- }
|
|
|
-
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
static class TestConfiguration {
|
|
|
|
|
@@ -188,12 +159,7 @@ class OtelSpringStarterSmokeTest extends AbstractSpringStarterSmokeTest {
|
|
|
assertClient(OtelSpringStarterSmokeTestController.REST_TEMPLATE);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
- void restClient() {
|
|
|
- assertClient(OtelSpringStarterSmokeTestController.REST_CLIENT);
|
|
|
- }
|
|
|
-
|
|
|
- private void assertClient(String url) {
|
|
|
+ protected void assertClient(String url) {
|
|
|
testing.clearAllExportedData();
|
|
|
|
|
|
testRestTemplate.getForObject(url, String.class);
|