</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>original</id>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <so.log.level>DEBUG</so.log.level>
- </systemPropertyVariables>
- <rerunFailingTestsCount>2</rerunFailingTestsCount>
- <parallel>suites</parallel>
- <useUnlimitedThreads>false</useUnlimitedThreads>
- <threadCount>1</threadCount>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <excludes>
- <exclude>**/*.p12</exclude>
- <exclude>**/*.jks</exclude>
- </excludes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <includes>
- <include>**/*.p12</include>
- <include>**/*.jks</include>
- </includes>
- </resource>
- </resources>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>original</id>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <so.log.level>DEBUG</so.log.level>
+ </systemPropertyVariables>
+ <rerunFailingTestsCount>2</rerunFailingTestsCount>
+ <parallel>suites</parallel>
+ <useUnlimitedThreads>false</useUnlimitedThreads>
+ <threadCount>1</threadCount>
+ </configuration>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <excludes>
+ <exclude>**/*.p12</exclude>
+ <exclude>**/*.jks</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*.p12</include>
+ <include>**/*.jks</include>
+ </includes>
+ </resource>
+ </resources>
</build>
<dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.aai.schema-service</groupId>
- <artifactId>aai-schema</artifactId>
- <version>1.9.2</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.aai.schema-service</groupId>
+ <artifactId>aai-schema</artifactId>
+ <version>1.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-dependencies</artifactId>
+ <version>Hoxton.SR12</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-sleuth</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-sleuth-zipkin</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
+ <version>2.2.8.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
enabled: false
spring:
+ application:
+ name: so-cnf-adapter
+ main:
+ allow-bean-definition-overriding: true
security:
usercredentials:
- username: ${ACTUATOR_USERNAME}
password: ${ACTUATOR_PASSWORD}
role: ACTUATOR
+ sleuth:
+ enabled: ${TRACING_ENABLED:false}
+ trace-id128: true
+ sampler:
+ probability: ${TRACING_SAMPLING_PROBABILITY:1.0}
+ supports-join: false
+ propagation:
+ type: w3c,bc
+ web:
+ skip-pattern: ${TRACING_SKIP_PATTERN}
# jpa:
# show-sql: false
#management:
# security:
# enabled: false
- # basic:
\ No newline at end of file
+ # basic:
--- /dev/null
+/*
+ * Copyright © 2025 Deutsche Telekom
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.so.adapters.cnf.rest;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
+import org.springframework.cloud.sleuth.zipkin2.ZipkinAutoConfiguration;
+import org.springframework.http.HttpStatus;
+import org.springframework.test.context.DynamicPropertyRegistry;
+import org.springframework.test.context.DynamicPropertySource;
+import org.springframework.util.SocketUtils;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.DefaultUriBuilderFactory;
+
+import com.github.tomakehurst.wiremock.client.WireMock;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+
+import lombok.SneakyThrows;
+
+@Ignore
+@EnableAutoConfiguration
+@ImportAutoConfiguration(classes = { TraceAutoConfiguration.class, ZipkinAutoConfiguration.class })
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
+ "spring.sleuth.enabled=true",
+ "spring.sleuth.sampler.probability=1.0"
+})
+public class TracingTest {
+
+ private static int wireMockPort = SocketUtils.findAvailableTcpPort();
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(wireMockPort));
+
+ @LocalServerPort
+ private int port;
+
+ RestTemplate restTemplate;
+
+ @Before
+ public void setup() {
+ this.restTemplate = new RestTemplate();
+ restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory("http://localhost:" + port));
+ }
+
+ @DynamicPropertySource
+ static void configureProperties(DynamicPropertyRegistry registry) {
+ registry.add("spring.sleuth.enabled", () -> "true");
+ registry.add("spring.zipkin.baseUrl", () -> "http://localhost:" + wireMockPort);
+ registry.add("spring.sleuth.sampler.probability", () -> "1.0");
+ }
+
+ @Test
+ @SneakyThrows
+ public void thatTracesAreExported() throws InterruptedException {
+ WireMock.stubFor(WireMock.post(WireMock.urlEqualTo("/api/v2/spans"))
+ .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value())));
+
+ try {
+ restTemplate.getForObject("http://localhost:" + port + "/foo", String.class);
+ } catch (RestClientException e) {
+ // this provokes a 404. For the test it's not important what is returned here
+ }
+
+ Thread.sleep(1000);
+ WireMock.verify(WireMock.postRequestedFor(WireMock.urlEqualTo("/api/v2/spans")));
+ }
+}
+++ /dev/null
-aai.enabled=true
-aai.endpoint=http://localhost:8443
-aai.auth=5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
-mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7
-spring.main.allow-bean-definition-overriding=true
\ No newline at end of file
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
+ <version>2.2.8.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-sleuth</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>