From 9154ad3ed588112bb63bd5145b2b66cdbc29af1b Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko Date: Fri, 13 Dec 2024 14:57:49 +0100 Subject: [PATCH] Fix tracing JUnit5 tests in Maven projects with multiple forks --- .../civisibility/CiVisibilitySystem.java | 3 + .../trace/civisibility/ProcessHierarchy.java | 8 +- .../events/NoOpTestEventsHandler.java | 136 ++++++ .../datadog/smoketest/MavenSmokeTest.groovy | 2 + .../coverages.ftl | 12 + .../events.ftl | 405 ++++++++++++++++++ .../pom.xml | 65 +++ .../main/java/datadog/smoke/Calculator.java | 11 + .../test/java/datadog/smoke/TestSucceed.java | 18 + 9 files changed, 659 insertions(+), 1 deletion(-) create mode 100644 dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java create mode 100644 dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/coverages.ftl create mode 100644 dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/events.ftl create mode 100644 dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/pom.xml create mode 100644 dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/main/java/datadog/smoke/Calculator.java create mode 100644 dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/test/java/datadog/smoke/TestSucceed.java diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilitySystem.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilitySystem.java index d8d6f2f9c00..688f19f9892 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilitySystem.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilitySystem.java @@ -28,6 +28,7 @@ import datadog.trace.civisibility.domain.headless.HeadlessTestSession; import datadog.trace.civisibility.domain.manualapi.ManualApiTestSession; import datadog.trace.civisibility.events.BuildEventsHandlerImpl; +import datadog.trace.civisibility.events.NoOpTestEventsHandler; import datadog.trace.civisibility.events.TestEventsHandlerImpl; import datadog.trace.civisibility.ipc.SignalServer; import datadog.trace.civisibility.source.index.RepoIndex; @@ -102,6 +103,8 @@ public static void start(Instrumentation inst, SharedCommunicationObjects sco) { new TestEventsHandlerFactory( services, repoServices, coverageServices, executionSettings)); CoveragePerTestBridge.registerCoverageStoreRegistry(coverageServices.coverageStoreFactory); + } else { + InstrumentationBridge.registerTestEventsHandlerFactory(new NoOpTestEventsHandler.Factory()); } } diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java index a8265815bb0..240164f2e23 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java @@ -62,12 +62,18 @@ private boolean isParent() { * process that is not a build system, and not a JVM that runs tests. */ private boolean isWrapper() { + // Maven Wrapper runs in the same JVM as Maven itself, + // so it is not included here return isGradleLauncher(); } private boolean isMavenParent() { return System.getProperty("maven.home") != null - && System.getProperty("classworlds.conf") != null; + && System.getProperty("classworlds.conf") != null + // when using Maven Wrapper + || ClassLoader.getSystemClassLoader() + .getResource("org/apache/maven/wrapper/WrapperExecutor.class") + != null; } private boolean isGradleDaemon() { diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java new file mode 100644 index 00000000000..b4696da4e69 --- /dev/null +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java @@ -0,0 +1,136 @@ +package datadog.trace.civisibility.events; + +import datadog.trace.api.civisibility.DDTest; +import datadog.trace.api.civisibility.DDTestSuite; +import datadog.trace.api.civisibility.config.TestIdentifier; +import datadog.trace.api.civisibility.events.TestEventsHandler; +import datadog.trace.api.civisibility.retry.TestRetryPolicy; +import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; +import datadog.trace.bootstrap.ContextStore; +import datadog.trace.civisibility.retry.NeverRetry; +import java.lang.reflect.Method; +import java.util.Collection; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class NoOpTestEventsHandler + implements TestEventsHandler { + + @Override + public void onTestSuiteStart( + SuiteKey descriptor, + String testSuiteName, + @Nullable String testFramework, + @Nullable String testFrameworkVersion, + @Nullable Class testClass, + @Nullable Collection categories, + boolean parallelized, + TestFrameworkInstrumentation instrumentation) { + // do nothing + } + + @Override + public void onTestSuiteSkip(SuiteKey descriptor, @Nullable String reason) { + // do nothing + } + + @Override + public void onTestSuiteFailure(SuiteKey descriptor, @Nullable Throwable throwable) { + // do nothing + } + + @Override + public void onTestSuiteFinish(SuiteKey descriptor) { + // do nothing + } + + @Override + public void onTestStart( + SuiteKey suiteDescriptor, + TestKey descriptor, + String testSuiteName, + String testName, + @Nullable String testFramework, + @Nullable String testFrameworkVersion, + @Nullable String testParameters, + @Nullable Collection categories, + @Nullable Class testClass, + @Nullable String testMethodName, + @Nullable Method testMethod, + boolean isRetry) { + // do nothing + } + + @Override + public void onTestSkip(TestKey descriptor, @Nullable String reason) { + // do nothing + } + + @Override + public void onTestFailure(TestKey descriptor, @Nullable Throwable throwable) { + // do nothing + } + + @Override + public void onTestFinish(TestKey descriptor) { + // do nothing + } + + @Override + public void onTestIgnore( + SuiteKey suiteDescriptor, + TestKey testDescriptor, + String testSuiteName, + String testName, + @Nullable String testFramework, + @Nullable String testFrameworkVersion, + @Nullable String testParameters, + @Nullable Collection categories, + @Nullable Class testClass, + @Nullable String testMethodName, + @Nullable Method testMethod, + @Nullable String reason) { + // do nothing + } + + @Override + public boolean skip(TestIdentifier test) { + return false; + } + + @Override + public boolean shouldBeSkipped(TestIdentifier test) { + return false; + } + + @NotNull + @Override + public TestRetryPolicy retryPolicy(TestIdentifier test) { + return NeverRetry.INSTANCE; + } + + @Override + public boolean isNew(TestIdentifier test) { + return false; + } + + @Override + public boolean isFlaky(TestIdentifier test) { + return false; + } + + @Override + public void close() { + // do nothing + } + + public static final class Factory implements TestEventsHandler.Factory { + @Override + public TestEventsHandler create( + String component, + @Nullable ContextStore suiteStore, + @Nullable ContextStore testStore) { + return new NoOpTestEventsHandler<>(); + } + } +} diff --git a/dd-smoke-tests/maven/src/test/groovy/datadog/smoketest/MavenSmokeTest.groovy b/dd-smoke-tests/maven/src/test/groovy/datadog/smoketest/MavenSmokeTest.groovy index 8df06e14f25..02fe0cb022e 100644 --- a/dd-smoke-tests/maven/src/test/groovy/datadog/smoketest/MavenSmokeTest.groovy +++ b/dd-smoke-tests/maven/src/test/groovy/datadog/smoketest/MavenSmokeTest.groovy @@ -99,6 +99,8 @@ class MavenSmokeTest extends CiVisibilitySmokeTest { "test_failed_maven_run_flaky_retries" | "3.9.9" | 8 | 5 | false | false | true | true | [] | 8 "test_successful_maven_run_junit_platform_runner" | "3.9.9" | 4 | 0 | true | false | false | false | [] | 8 "test_successful_maven_run_with_arg_line_property" | "3.9.9" | 4 | 0 | true | false | false | false | ["-DargLine='-Dmy-custom-property=provided-via-command-line'"] | 8 + "test_successful_maven_run_multiple_forks" | "3.9.9" | 5 | 1 | true | true | false | true | [] | 8 + "test_successful_maven_run_multiple_forks" | LATEST_MAVEN_VERSION | 5 | 1 | true | true | false | true | [] | 17 } private void givenWrapperPropertiesFile(String mavenVersion) { diff --git a/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/coverages.ftl b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/coverages.ftl new file mode 100644 index 00000000000..9f24089dfe3 --- /dev/null +++ b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/coverages.ftl @@ -0,0 +1,12 @@ +[ { + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "span_id" : ${content_span_id_6}, + "files" : [ { + "filename" : "src/test/java/datadog/smoke/TestSucceed.java", + "bitmap" : "ABg=" + }, { + "filename" : "src/main/java/datadog/smoke/Calculator.java", + "bitmap" : "IA==" + } ] +} ] \ No newline at end of file diff --git a/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/events.ftl b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/events.ftl new file mode 100644 index 00000000000..23935a51419 --- /dev/null +++ b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/events.ftl @@ -0,0 +1,405 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "test-maven-service", + "name" : "maven.test_session", + "resource" : "Maven Smoke Tests Project", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "test.itr.tests_skipping.count" : 1, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.code_coverage.lines_pct" : 67 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "pass", + "_dd.ci.itr.tests_skipped" : "true", + "ci.workspace_path" : ${content_meta_ci_workspace_path}, + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.code_coverage.backfilled" : "true", + "test.itr.tests_skipping.enabled" : "true", + "test.type" : "test", + "test_session.name" : "mvn -B test", + "env" : "integration-test", + "component" : "maven", + "test.code_coverage.enabled" : "true", + "test.toolchain" : ${content_meta_test_toolchain}, + "test.itr.tests_skipping.type" : "test", + "test.command" : "mvn -B test", + "test.framework_version" : "5.9.2", + "test.framework" : "junit5", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "test-maven-service", + "name" : "maven.test_module", + "resource" : "Maven Smoke Tests Project maven-surefire-plugin default-test", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}, + "test.itr.tests_skipping.count" : 1, + "test.code_coverage.lines_pct" : 67 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "Maven Smoke Tests Project maven-surefire-plugin default-test", + "test.status" : "pass", + "_dd.ci.itr.tests_skipped" : "true", + "test_session.name" : "mvn -B test", + "ci.workspace_path" : ${content_meta_ci_workspace_path}, + "env" : "integration-test", + "library_version" : ${content_meta_library_version}, + "component" : "maven", + "test.code_coverage.enabled" : "true", + "span.kind" : "test_module_end", + "test.execution" : "maven-surefire-plugin:test:default-test", + "test.itr.tests_skipping.type" : "test", + "test.command" : "mvn -B test", + "test.code_coverage.backfilled" : "true", + "test.framework_version" : "5.9.2", + "test.framework" : "junit5", + "test.itr.tests_skipping.enabled" : "true", + "runtime-id" : ${content_meta_runtime_id}, + "language" : "jvm", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_test_session_id}, + "service" : "test-maven-service", + "name" : "Maven_Smoke_Tests_Project_jacoco_maven_plugin_default", + "resource" : "Maven_Smoke_Tests_Project_jacoco_maven_plugin_default", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "execution" : "default", + "project" : "Maven Smoke Tests Project", + "library_version" : ${content_meta_library_version}, + "env" : "integration-test", + "plugin" : "jacoco-maven-plugin", + "runtime-id" : ${content_meta_runtime_id}, + "language" : "jvm", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_test_session_id}, + "service" : "test-maven-service", + "name" : "Maven_Smoke_Tests_Project_maven_compiler_plugin_default_compile", + "resource" : "Maven_Smoke_Tests_Project_maven_compiler_plugin_default_compile", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "execution" : "default-compile", + "project" : "Maven Smoke Tests Project", + "library_version" : ${content_meta_library_version}, + "env" : "integration-test", + "plugin" : "maven-compiler-plugin", + "runtime-id" : ${content_meta_runtime_id}, + "language" : "jvm", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_test_session_id}, + "service" : "test-maven-service", + "name" : "Maven_Smoke_Tests_Project_maven_compiler_plugin_default_testCompile", + "resource" : "Maven_Smoke_Tests_Project_maven_compiler_plugin_default_testCompile", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "execution" : "default-testCompile", + "project" : "Maven Smoke Tests Project", + "library_version" : ${content_meta_library_version}, + "env" : "integration-test", + "plugin" : "maven-compiler-plugin", + "runtime-id" : ${content_meta_runtime_id}, + "language" : "jvm", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_4}, + "parent_id" : ${content_test_session_id}, + "service" : "test-maven-service", + "name" : "Maven_Smoke_Tests_Project_maven_resources_plugin_default_resources", + "resource" : "Maven_Smoke_Tests_Project_maven_resources_plugin_default_resources", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_6}, + "execution" : "default-resources", + "project" : "Maven Smoke Tests Project", + "library_version" : ${content_meta_library_version}, + "env" : "integration-test", + "plugin" : "maven-resources-plugin", + "runtime-id" : ${content_meta_runtime_id}, + "language" : "jvm", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_5}, + "parent_id" : ${content_test_session_id}, + "service" : "test-maven-service", + "name" : "Maven_Smoke_Tests_Project_maven_resources_plugin_default_testResources", + "resource" : "Maven_Smoke_Tests_Project_maven_resources_plugin_default_testResources", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_7}, + "execution" : "default-testResources", + "project" : "Maven Smoke Tests Project", + "library_version" : ${content_meta_library_version}, + "env" : "integration-test", + "plugin" : "maven-resources-plugin", + "runtime-id" : ${content_meta_runtime_id}, + "language" : "jvm", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "test-maven-service", + "name" : "junit.test_suite", + "resource" : "datadog.smoke.TestSucceed", + "start" : ${content_start_8}, + "duration" : ${content_duration_8}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id_2}, + "_dd.profiling.enabled" : 0, + "test.source.end" : 18, + "_dd.trace_span_attribute_schema" : 0, + "test.source.start" : 7 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_8}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "src/test/java/datadog/smoke/TestSucceed.java", + "test.module" : "Maven Smoke Tests Project maven-surefire-plugin default-test", + "test.status" : "pass", + "test_session.name" : "mvn -B test", + "ci.workspace_path" : ${content_meta_ci_workspace_path}, + "language" : "jvm", + "env" : "integration-test", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "datadog.smoke.TestSucceed", + "runtime-id" : ${content_meta_runtime_id_2}, + "test.framework_version" : "5.9.2", + "test.framework" : "junit5", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_6}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "test-maven-service", + "name" : "junit.test", + "resource" : "datadog.smoke.TestSucceed.test_succeed", + "start" : ${content_start_9}, + "duration" : ${content_duration_9}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4}, + "test.source.end" : 12, + "test.source.start" : 9 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_9}, + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "src/test/java/datadog/smoke/TestSucceed.java", + "test.source.method" : "test_succeed()V", + "test.module" : "Maven Smoke Tests Project maven-surefire-plugin default-test", + "test.status" : "pass", + "ci.workspace_path" : ${content_meta_ci_workspace_path}, + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "test.name" : "test_succeed", + "span.kind" : "test", + "test.suite" : "datadog.smoke.TestSucceed", + "runtime-id" : ${content_meta_runtime_id_2}, + "test.type" : "test", + "test_session.name" : "mvn -B test", + "env" : "integration-test", + "component" : "junit", + "test.framework_version" : "5.9.2", + "test.framework" : "junit5", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_7}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "test-maven-service", + "name" : "junit.test", + "resource" : "datadog.smoke.TestSucceed.test_to_skip_with_itr", + "start" : ${content_start_10}, + "duration" : ${content_duration_10}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_5}, + "test.source.end" : 17, + "test.source.start" : 14 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_10}, + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "src/test/java/datadog/smoke/TestSucceed.java", + "test.source.method" : "test_to_skip_with_itr()V", + "test.module" : "Maven Smoke Tests Project maven-surefire-plugin default-test", + "test.status" : "skip", + "ci.workspace_path" : ${content_meta_ci_workspace_path}, + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "test.name" : "test_to_skip_with_itr", + "span.kind" : "test", + "test.suite" : "datadog.smoke.TestSucceed", + "runtime-id" : ${content_meta_runtime_id_2}, + "test.type" : "test", + "test.skip_reason" : "Skipped by Datadog Intelligent Test Runner", + "test_session.name" : "mvn -B test", + "env" : "integration-test", + "component" : "junit", + "test.skipped_by_itr" : "true", + "test.framework_version" : "5.9.2", + "test.framework" : "junit5", + "runtime.name" : ${content_meta_runtime_name}, + "runtime.vendor" : ${content_meta_runtime_vendor}, + "runtime.version" : ${content_meta_runtime_version}, + "os.architecture" : ${content_meta_os_architecture}, + "os.platform" : ${content_meta_os_platform}, + "os.version" : ${content_meta_os_version} + } + } +} ] \ No newline at end of file diff --git a/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/pom.xml b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/pom.xml new file mode 100644 index 00000000000..f9689fbdbfa --- /dev/null +++ b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + com.datadog.ci.test + maven-smoke-test + 1.0-SNAPSHOT + Maven Smoke Tests Project + + + 8 + 8 + UTF-8 + + + + + + + false + + central + Central Repository + https://repo.maven.apache.org/maven2 + + + + + + never + + + false + + central + Central Repository + https://repo.maven.apache.org/maven2 + + + + + + org.junit.jupiter + junit-jupiter-engine + 5.9.2 + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0 + + 2 + + + + + + diff --git a/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/main/java/datadog/smoke/Calculator.java b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/main/java/datadog/smoke/Calculator.java new file mode 100644 index 00000000000..2f4461a279d --- /dev/null +++ b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/main/java/datadog/smoke/Calculator.java @@ -0,0 +1,11 @@ +package datadog.smoke; + +public class Calculator { + public static int add(int a, int b) { + return a + b; + } + + public static int subtract(int a, int b) { + return a - b; + } +} diff --git a/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/test/java/datadog/smoke/TestSucceed.java b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/test/java/datadog/smoke/TestSucceed.java new file mode 100644 index 00000000000..ba7ab0f56fc --- /dev/null +++ b/dd-smoke-tests/maven/src/test/resources/test_successful_maven_run_multiple_forks/src/test/java/datadog/smoke/TestSucceed.java @@ -0,0 +1,18 @@ +package datadog.smoke; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +public class TestSucceed { + + @Test + public void test_succeed() { + assertTrue(Calculator.add(2, 2) == 4); + } + + @Test + public void test_to_skip_with_itr() { + assertTrue(Calculator.subtract(3, 2) == 1); + } +}