From 0e6f725881296e6533050c65a461ebf0570a80d6 Mon Sep 17 00:00:00 2001 From: Helen <56097766+heyams@users.noreply.github.com> Date: Wed, 22 Feb 2023 10:56:08 -0800 Subject: [PATCH] Add a test for InProc dependency (#2905) based on [#7760](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/7760) --- .../smoketestapp/TestController.java | 11 +++++++++++ .../smoketest/SpringSchedulingTest.java | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java b/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java index 62bd220c782..902c473c6bc 100644 --- a/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java +++ b/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java @@ -3,12 +3,17 @@ package com.microsoft.applicationinsights.smoketestapp; +import java.time.Instant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.TaskScheduler; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { + @Autowired private TaskScheduler taskScheduler; + @GetMapping("/") public String root() { return "OK"; @@ -18,4 +23,10 @@ public String root() { public String scheduler() { return "OK!"; } + + @GetMapping("/should-ignore") + public String shouldIgnoreTest() throws Exception { + taskScheduler.schedule(() -> System.out.println("here i am"), Instant.now()); + return "OK!"; + } } diff --git a/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java b/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java index 9b028e42bdc..267b80aff75 100644 --- a/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java +++ b/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java @@ -12,6 +12,7 @@ import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9; import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8; import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9; +import static org.assertj.core.api.Assertions.assertThat; import com.microsoft.applicationinsights.smoketest.schemav2.Data; import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; @@ -24,7 +25,19 @@ @UseAgent abstract class SpringSchedulingTest { - @RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); + @RegisterExtension + static final SmokeTestExtension testing = + SmokeTestExtension.builder() + .setSelfDiagnosticsLevel("debug") + .build(); // SmokeTestExtension.create(); + + @Test + @TargetUri("/should-ignore") + void shouldIgnoreTest() throws Exception { + // sleep a bit to make sure no dependencies are reported + Thread.sleep(5000); + assertThat(testing.mockedIngestion.getCountForType("RemoteDependencyData")).isZero(); + } @Test @TargetUri("/scheduler")