From 7e1c476fe466e0c8b795955aa7ed4b84d0924bc4 Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko Date: Mon, 3 Mar 2025 17:51:23 +0100 Subject: [PATCH 1/6] Add support for skip-EFD tagging --- .../domain/TestFrameworkModule.java | 4 +- .../domain/buildsystem/ProxyTestModule.java | 5 +- .../domain/headless/HeadlessTestModule.java | 6 +- .../events/NoOpTestEventsHandler.java | 3 +- .../events/TestEventsHandlerImpl.java | 9 +- .../civisibility/test/ExecutionStrategy.java | 14 +- .../buildsystem/ProxyTestModuleTest.groovy | 6 +- .../headless/HeadlessTestModuleTest.groovy | 6 +- .../CiVisibilityInstrumentationTest.groovy | 33 ++-- .../civisibility/CiVisibilitySmokeTest.groovy | 11 +- .../junit4/CucumberTracingListener.java | 8 +- .../instrumentation/junit4/CucumberUtils.java | 37 ++++ .../JUnit4CucumberSkipInstrumentation.java | 4 +- .../Cucumber4ExecutionInstrumentation.java | 4 +- .../src/test/groovy/CucumberTest.groovy | 19 +- .../basic_arithmetic_skip_efd.feature | 10 ++ .../test-efd-skip-new-test/coverages.ftl | 8 + .../test-efd-skip-new-test/events.ftl | 145 +++++++++++++++ .../junit4/MUnitTracingListener.java | 24 +-- .../instrumentation/junit4/MUnitUtils.java | 15 ++ .../MUnitExecutionInstrumentation.java | 4 +- .../src/test/groovy/MUnitTest.groovy | 10 +- .../test-efd-skip-new-test/coverages.ftl | 1 + .../test-efd-skip-new-test/events.ftl | 151 ++++++++++++++++ .../org/example/TestSucceedMUnitSkipEfd.scala | 9 + .../junit4/JUnit4SkipInstrumentation.java | 4 +- .../JUnit4ExecutionInstrumentation.java | 5 +- .../src/test/groovy/JUnit4Test.groovy | 1 + .../java/org/example/TestSucceedSkipEfd.java | 17 ++ .../test-efd-skip-new-test/coverages.ftl | 1 + .../test-efd-skip-new-test/events.ftl | 154 ++++++++++++++++ .../junit5/CucumberTracingListener.java | 3 +- .../JUnit5CucumberSkipInstrumentation.java | 4 +- .../src/test/groovy/CucumberTest.groovy | 19 +- .../basic_arithmetic_skip_efd.feature | 9 + .../test-efd-skip-new-test/coverages.ftl | 8 + .../test-efd-skip-new-test/events.ftl | 145 +++++++++++++++ .../junit5/SpockTracingListener.java | 3 +- .../instrumentation/junit5/SpockUtils.java | 4 +- .../src/test/groovy/SpockTest.groovy | 2 + .../example/TestSucceedSpockSkipEfd.groovy | 14 ++ .../TestSucceedSpockUnskippable.groovy | 4 +- .../TestSucceedSpockUnskippableSuite.groovy | 4 +- .../test-efd-skip-new-test/coverages.ftl | 1 + .../test-efd-skip-new-test/events.ftl | 154 ++++++++++++++++ .../junit5/JUnit5SkipInstrumentation.java | 4 +- .../junit5/JUnitPlatformUtils.java | 6 + .../junit5/TracingListener.java | 3 +- .../JUnit5ExecutionInstrumentation.java | 4 +- .../src/test/groovy/JUnit5Test.groovy | 2 + .../java/org/example/TestSucceedSkipEfd.java | 17 ++ .../org/example/TestSucceedUnskippable.java | 4 +- .../example/TestSucceedUnskippableSuite.java | 4 +- .../test-efd-skip-new-test/coverages.ftl | 1 + .../test-efd-skip-new-test/events.ftl | 154 ++++++++++++++++ .../karate/ExecutionContext.java | 4 +- .../karate/KarateTracingHook.java | 4 +- .../karate/src/test/groovy/KarateTest.groovy | 1 + .../org/example/TestSucceedKarateSkipEfd.java | 11 ++ .../org/example/test_succeed_skip_efd.feature | 6 + .../test-efd-skip-new-test/coverages.ftl | 1 + .../test-efd-skip-new-test/events.ftl | 170 ++++++++++++++++++ .../scalatest/DatadogReporter.java | 4 +- .../instrumentation/scalatest/RunContext.java | 71 +++++--- .../ScalatestSkipInstrumentation.java | 11 +- .../ScalatestExecutionInstrumentation.java | 3 +- .../src/test/groovy/ScalatestTest.groovy | 2 + .../test-efd-skip-new-test/coverages.ftl | 1 + .../test-efd-skip-new-test/events.ftl | 150 ++++++++++++++++ .../org/example/TestSucceedSkipEfd.scala | 14 ++ .../org/example/TestSucceedUnskippable.scala | 5 +- .../testng/TestNGSkipInstrumentation.java | 4 +- .../testng/execution/RetryAnalyzer.java | 4 +- .../instrumentation/testng/TestNGTest.groovy | 7 +- .../java/org/example/TestSucceedSkipEfd.java | 14 ++ .../org/example/TestSucceedUnskippable.java | 4 +- .../test-efd-skip-new-test/coverages.ftl | 1 + .../test-efd-skip-new-test/events.ftl | 154 ++++++++++++++++ .../trace/api/civisibility/CIConstants.java | 6 + .../civisibility/InstrumentationBridge.java | 2 - .../events/TestEventsHandler.java | 3 +- 81 files changed, 1792 insertions(+), 166 deletions(-) create mode 100644 dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature create mode 100644 dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature create mode 100644 dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy create mode 100644 dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java create mode 100644 dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/karate/src/test/java/org/example/TestSucceedKarateSkipEfd.java create mode 100644 dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature create mode 100644 dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/events.ftl create mode 100644 dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala create mode 100644 dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java create mode 100644 dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/coverages.ftl create mode 100644 dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestFrameworkModule.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestFrameworkModule.java index ff07f324cf0..37b0c649588 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestFrameworkModule.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestFrameworkModule.java @@ -5,6 +5,7 @@ import datadog.trace.api.civisibility.execution.TestExecutionPolicy; import datadog.trace.api.civisibility.telemetry.tag.SkipReason; import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; +import java.util.Collection; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -47,7 +48,8 @@ TestSuiteImpl testSuiteStart( SkipReason skipReason(TestIdentifier test); @Nonnull - TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData testSource); + TestExecutionPolicy executionPolicy( + TestIdentifier test, TestSourceData testSource, Collection testTags); /** * Returns the priority of the test execution that can be used for ordering tests. The higher the diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java index aa05502ffe9..d51dee9a34f 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java @@ -127,8 +127,9 @@ public SkipReason skipReason(TestIdentifier test) { @Override @Nonnull - public TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData testSource) { - return executionStrategy.executionPolicy(test, testSource); + public TestExecutionPolicy executionPolicy( + TestIdentifier test, TestSourceData testSource, Collection testTags) { + return executionStrategy.executionPolicy(test, testSource, testTags); } @Override diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java index f9aa26314b8..4e8b98403e5 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java @@ -27,6 +27,7 @@ import datadog.trace.civisibility.test.ExecutionResults; import datadog.trace.civisibility.test.ExecutionStrategy; import datadog.trace.civisibility.utils.SpanUtils; +import java.util.Collection; import java.util.function.Consumer; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -112,8 +113,9 @@ public SkipReason skipReason(TestIdentifier test) { @Override @Nonnull - public TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData testSource) { - return executionStrategy.executionPolicy(test, testSource); + public TestExecutionPolicy executionPolicy( + TestIdentifier test, TestSourceData testSource, Collection testTags) { + return executionStrategy.executionPolicy(test, testSource, testTags); } @Override 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 index 024d25049f1..9052e1b5a50 100644 --- 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 @@ -100,7 +100,8 @@ public SkipReason skipReason(TestIdentifier test) { @NotNull @Override - public TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData source) { + public TestExecutionPolicy executionPolicy( + TestIdentifier test, TestSourceData source, Collection testTags) { return Regular.INSTANCE; } diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java index 22a1ccf84ee..4a93eab7600 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java @@ -2,9 +2,9 @@ import datadog.json.JsonWriter; import datadog.trace.api.DisableTestTrace; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.DDTest; import datadog.trace.api.civisibility.DDTestSuite; -import datadog.trace.api.civisibility.InstrumentationBridge; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.config.TestSourceData; import datadog.trace.api.civisibility.events.TestEventsHandler; @@ -206,7 +206,7 @@ public void onTestStart( test.setTag(Tags.TEST_TRAITS, getTestTraits(categories)); for (String category : categories) { - if (category.endsWith(InstrumentationBridge.ITR_UNSKIPPABLE_TAG)) { + if (category.endsWith(CIConstants.Tags.ITR_UNSKIPPABLE_TAG)) { test.setTag(Tags.TEST_ITR_UNSKIPPABLE, true); metricCollector.add(CiVisibilityCountMetric.ITR_UNSKIPPABLE, 1, EventType.TEST); @@ -295,8 +295,9 @@ public void onTestIgnore( @Override @Nonnull - public TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData testSource) { - return testModule.executionPolicy(test, testSource); + public TestExecutionPolicy executionPolicy( + TestIdentifier test, TestSourceData testSource, Collection testTags) { + return testModule.executionPolicy(test, testSource, testTags); } @Override diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java index 334428e6c59..097e000cd46 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java @@ -1,6 +1,7 @@ package datadog.trace.civisibility.test; import datadog.trace.api.Config; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.config.TestMetadata; import datadog.trace.api.civisibility.config.TestSourceData; @@ -18,6 +19,7 @@ import datadog.trace.civisibility.source.LinesResolver; import datadog.trace.civisibility.source.SourcePathResolver; import java.lang.reflect.Method; +import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import javax.annotation.Nonnull; @@ -117,7 +119,8 @@ public SkipReason skipReason(TestIdentifier test) { } @Nonnull - public TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData testSource) { + public TestExecutionPolicy executionPolicy( + TestIdentifier test, TestSourceData testSource, Collection testTags) { if (test == null) { return Regular.INSTANCE; } @@ -129,7 +132,7 @@ public TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData t RetryReason.attemptToFix); } - if (isEFDApplicable(test, testSource)) { + if (isEFDApplicable(test, testSource, testTags)) { // check-then-act with "earlyFlakeDetectionsUsed" is not atomic here, // but we don't care if we go "a bit" over the limit, it does not have to be precise earlyFlakeDetectionsUsed.incrementAndGet(); @@ -163,11 +166,14 @@ private boolean isAutoRetryApplicable(TestIdentifier test) { && autoRetriesUsed.get() < config.getCiVisibilityTotalFlakyRetryCount(); } - private boolean isEFDApplicable(@Nonnull TestIdentifier test, TestSourceData testSource) { + private boolean isEFDApplicable( + @Nonnull TestIdentifier test, TestSourceData testSource, Collection testTags) { EarlyFlakeDetectionSettings efdSettings = executionSettings.getEarlyFlakeDetectionSettings(); return efdSettings.isEnabled() && !isEFDLimitReached() - && (isNew(test) || isModified(testSource)); + && (isNew(test) || isModified(testSource)) + // endsWith matching is needed for JUnit4-based frameworks, where tags are classes + && testTags.stream().noneMatch(t -> t.endsWith(CIConstants.Tags.SKIP_EFD_TAG)); } public boolean isEFDLimitReached() { diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy index c4cc84ccfa6..086699b155d 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy @@ -55,21 +55,21 @@ class ProxyTestModuleTest extends DDSpecification { ) when: - def retryPolicy1 = proxyTestModule.executionPolicy(new TestIdentifier("suite", "test-1", null), TestSourceData.UNKNOWN) + def retryPolicy1 = proxyTestModule.executionPolicy(new TestIdentifier("suite", "test-1", null), TestSourceData.UNKNOWN, []) then: retryPolicy1.retry(false, 1L) // 2nd test execution, 1st retry globally !retryPolicy1.retry(false, 1L) // asking for 3rd test execution - local limit reached when: - def retryPolicy2 = proxyTestModule.executionPolicy(new TestIdentifier("suite", "test-2", null), TestSourceData.UNKNOWN) + def retryPolicy2 = proxyTestModule.executionPolicy(new TestIdentifier("suite", "test-2", null), TestSourceData.UNKNOWN, []) then: retryPolicy2.retry(false, 1L) // 2nd test execution, 2nd retry globally (since previous test was retried too) !retryPolicy2.retry(false, 1L) // asking for 3rd test execution - local limit reached when: - def retryPolicy3 = proxyTestModule.executionPolicy(new TestIdentifier("suite", "test-3", null), TestSourceData.UNKNOWN) + def retryPolicy3 = proxyTestModule.executionPolicy(new TestIdentifier("suite", "test-3", null), TestSourceData.UNKNOWN, []) then: !retryPolicy3.retry(false, 1L) // asking for 3rd retry globally - global limit reached diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy index b941591ba8c..cea3e91cad6 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy @@ -21,21 +21,21 @@ class HeadlessTestModuleTest extends SpanWriterTest { def headlessTestModule = givenAHeadlessTestModule() when: - def retryPolicy1 = headlessTestModule.executionPolicy(new TestIdentifier("suite", "test-1", null), TestSourceData.UNKNOWN) + def retryPolicy1 = headlessTestModule.executionPolicy(new TestIdentifier("suite", "test-1", null), TestSourceData.UNKNOWN, []) then: retryPolicy1.retry(false, 1L) // 2nd test execution, 1st retry globally !retryPolicy1.retry(false, 1L) // asking for 3rd test execution - local limit reached when: - def retryPolicy2 = headlessTestModule.executionPolicy(new TestIdentifier("suite", "test-2", null), TestSourceData.UNKNOWN) + def retryPolicy2 = headlessTestModule.executionPolicy(new TestIdentifier("suite", "test-2", null), TestSourceData.UNKNOWN, []) then: retryPolicy2.retry(false, 1L) // 2nd test execution, 2nd retry globally (since previous test was retried too) !retryPolicy2.retry(false, 1L) // asking for 3rd test execution - local limit reached when: - def retryPolicy3 = headlessTestModule.executionPolicy(new TestIdentifier("suite", "test-3", null), TestSourceData.UNKNOWN) + def retryPolicy3 = headlessTestModule.executionPolicy(new TestIdentifier("suite", "test-3", null), TestSourceData.UNKNOWN, []) then: !retryPolicy3.retry(false, 1L) // asking for 3rd retry globally - global limit reached diff --git a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy index 4d43300118e..a311f7568e8 100644 --- a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy @@ -354,18 +354,27 @@ abstract class CiVisibilityInstrumentationTest extends AgentTestRunner { "content.meta.['test.toolchain']" : "${instrumentedLibraryName()}:${instrumentedLibraryVersion()}" ] + replacements - // uncomment to generate expected data templates - // def clazz = this.getClass() - // def resourceName = "/" + clazz.name.replace('.', '/') + ".class" - // def classfilePath = clazz.getResource(resourceName).toURI().schemeSpecificPart - // def searchIndex = classfilePath.indexOf("/build/classes/groovy") - // def modulePath = classfilePath.substring(0, searchIndex) - // def submoduleName = classfilePath.substring(searchIndex + "/build/classes/groovy".length()).split("/")[1] - // def baseTemplatesPath = modulePath + "/src/" + submoduleName + "/resources/" + testcaseName - // CiVisibilityTestUtils.generateTemplates(baseTemplatesPath, events, coverages, additionalReplacements) - // return [:] - - return CiVisibilityTestUtils.assertData(testcaseName, events, coverages, additionalReplacements) + if (System.getenv().get("DD_GENERATE_TEST_FIXTURES") != null) { + return generateTestFixtures(testcaseName, events, coverages, additionalReplacements) + } else { + return CiVisibilityTestUtils.assertData(testcaseName, events, coverages, additionalReplacements) + } + } + + def generateTestFixtures(testcaseName, events, coverages, additionalReplacements) { + def clazz = this.getClass() + def resourceName = "/" + clazz.name.replace('.', '/') + ".class" + def classfilePath = clazz.getResource(resourceName).toURI().schemeSpecificPart + def searchIndex = classfilePath.indexOf("/build/classes/groovy") + def modulePath = classfilePath.substring(0, searchIndex) + def submoduleName = classfilePath.substring(searchIndex + "/build/classes/groovy".length()).split("/")[1] + if (!Files.exists(Paths.get(modulePath + "/src/" + submoduleName + "/resources/"))) { + // probably running a "latestDepTest" that uses fixtures from "test" + submoduleName = "test" + } + def baseTemplatesPath = modulePath + "/src/" + submoduleName + "/resources/" + testcaseName + CiVisibilityTestUtils.generateTemplates(baseTemplatesPath, events, coverages, additionalReplacements) + return [:] } def assertTestsOrder(List expectedOrder) { diff --git a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy index 645cc1965d9..77caec6dada 100644 --- a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy @@ -8,11 +8,12 @@ abstract class CiVisibilitySmokeTest extends Specification { protected verifyEventsAndCoverages(String projectName, String toolchain, String toolchainVersion, List> events, List> coverages) { def additionalReplacements = ["content.meta.['test.toolchain']": "$toolchain:$toolchainVersion"] - // uncomment to generate expected data templates - // def baseTemplatesPath = CiVisibilitySmokeTest.classLoader.getResource(projectName).toURI().schemeSpecificPart.replace('build/resources/test', 'src/test/resources') - // CiVisibilityTestUtils.generateTemplates(baseTemplatesPath, events, coverages, additionalReplacements) - - CiVisibilityTestUtils.assertData(projectName, events, coverages, additionalReplacements) + if (System.getenv().get("DD_GENERATE_TEST_FIXTURES") != null) { + def baseTemplatesPath = CiVisibilitySmokeTest.classLoader.getResource(projectName).toURI().schemeSpecificPart.replace('build/resources/test', 'src/test/resources') + CiVisibilityTestUtils.generateTemplates(baseTemplatesPath, events, coverages, additionalReplacements) + } else { + CiVisibilityTestUtils.assertData(projectName, events, coverages, additionalReplacements) + } } /** diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java index 28b94f42360..ed1e175f5e1 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java @@ -9,7 +9,6 @@ import datadog.trace.bootstrap.ContextStore; import io.cucumber.core.gherkin.Pickle; import java.net.URI; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -206,11 +205,6 @@ private static boolean isFeature(final Description description) { private List getCategories(Description description) { Pickle pickle = pickleById.get(JUnit4Utils.getUniqueId(description)); - List pickleTags = pickle.getTags(); - List categories = new ArrayList<>(pickleTags.size()); - for (String tag : pickleTags) { - categories.add(tag.substring(1)); // remove leading "@" - } - return categories; + return CucumberUtils.getCategories(pickle); } } diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberUtils.java b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberUtils.java index 12b77e363fa..985f777ff13 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberUtils.java +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberUtils.java @@ -12,6 +12,8 @@ import java.io.InputStream; import java.lang.invoke.MethodHandle; import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,6 +45,11 @@ public static String getVersion() { return "unknown"; } + private static final String NO_STEP_PICKLE_RUNNER_CLASSNAME = + "io.cucumber.junit.PickleRunners$NoStepDescriptions"; + private static final String WITH_STEP_PICKLE_RUNNER_CLASSNAME = + "io.cucumber.junit.PickleRunners$WithStepDescriptions"; + private static final MethodHandles REFLECTION = new MethodHandles(CUCUMBER_CLASS_LOADER); private static final MethodHandle FEATURE_GETTER = REFLECTION.privateFieldGetter("io.cucumber.junit.FeatureRunner", "feature"); @@ -54,6 +61,10 @@ public static String getVersion() { REFLECTION.privateFieldGetter("io.cucumber.junit.PickleRunners$PickleId", "pickleLine"); private static final MethodHandle PICKLE_RUNNER_GET_DESCRIPTION = REFLECTION.method("io.cucumber.junit.PickleRunners$PickleRunner", "getDescription"); + private static final MethodHandle PICKLE_RUNNER_NO_STEP_GET_PICKLE = + REFLECTION.privateFieldGetter(NO_STEP_PICKLE_RUNNER_CLASSNAME, "pickle"); + private static final MethodHandle PICKLE_RUNNER_WITH_STEP_GET_PICKLE = + REFLECTION.privateFieldGetter(WITH_STEP_PICKLE_RUNNER_CLASSNAME, "pickle"); private CucumberUtils() {} @@ -178,6 +189,32 @@ public static TestSuiteDescriptor toSuiteDescriptor(Description description) { return new TestSuiteDescriptor(testSuiteName, null); } + public static Collection getPickleRunnerTags(Object pickleRunner) { + Pickle pickle = getPickle(pickleRunner); + return getCategories(pickle); + } + + private static Pickle getPickle(Object pickleRunner) { + try { + if (pickleRunner.getClass().getName().equals(NO_STEP_PICKLE_RUNNER_CLASSNAME)) { + return REFLECTION.invoke(PICKLE_RUNNER_NO_STEP_GET_PICKLE, pickleRunner); + } else { + return REFLECTION.invoke(PICKLE_RUNNER_WITH_STEP_GET_PICKLE, pickleRunner); + } + } catch (Exception e) { + return null; + } + } + + public static List getCategories(Pickle pickle) { + List pickleTags = pickle.getTags(); + List categories = new ArrayList<>(pickleTags.size()); + for (String tag : pickleTags) { + categories.add(tag.substring(1)); // remove leading "@" + } + return categories; + } + public static final class MuzzleHelper { public static Reference[] additionalMuzzleReferences() { return new Reference[] { diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/JUnit4CucumberSkipInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/JUnit4CucumberSkipInstrumentation.java index cb54018c5c8..be878a1c397 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/JUnit4CucumberSkipInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/JUnit4CucumberSkipInstrumentation.java @@ -9,7 +9,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.agent.tooling.muzzle.Reference; import datadog.trace.api.Config; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.telemetry.tag.SkipReason; import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; @@ -95,7 +95,7 @@ public static Boolean run( if (skipReason == SkipReason.ITR) { List tags = pickle.getTags(); for (String tag : tags) { - if (tag.endsWith(InstrumentationBridge.ITR_UNSKIPPABLE_TAG)) { + if (tag.endsWith(CIConstants.Tags.ITR_UNSKIPPABLE_TAG)) { return null; } } diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/Cucumber4ExecutionInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/Cucumber4ExecutionInstrumentation.java index 11bd3ec9040..4f738e274b2 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/Cucumber4ExecutionInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/Cucumber4ExecutionInstrumentation.java @@ -20,6 +20,7 @@ import datadog.trace.util.Strings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.lang.invoke.MethodHandle; +import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -97,10 +98,11 @@ public static Boolean execute( Description description = CucumberUtils.getPickleRunnerDescription(pickleRunner); TestIdentifier testIdentifier = CucumberUtils.toTestIdentifier(description); + Collection testTags = CucumberUtils.getPickleRunnerTags(pickleRunner); TestExecutionPolicy executionPolicy = TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.CUCUMBER) - .executionPolicy(testIdentifier, TestSourceData.UNKNOWN); + .executionPolicy(testIdentifier, TestSourceData.UNKNOWN, testTags); if (!executionPolicy.applicable()) { // retries not applicable, run original method return null; diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/groovy/CucumberTest.groovy b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/groovy/CucumberTest.groovy index 1d16617beaf..89023b1abaf 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/groovy/CucumberTest.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/groovy/CucumberTest.groovy @@ -89,6 +89,7 @@ class CucumberTest extends CiVisibilityInstrumentationTest { "test-efd-new-test" | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [] "test-efd-new-scenario-outline-${version()}" | ["org/example/cucumber/calculator/basic_arithmetic_with_examples.feature"] | [] "test-efd-new-slow-test" | ["org/example/cucumber/calculator/basic_arithmetic_slow.feature"] | [] + "test-efd-skip-new-test" | ["org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature"] | [] } def "test quarantined #testcaseName"() { @@ -172,31 +173,31 @@ class CucumberTest extends CiVisibilityInstrumentationTest { assertSpansData(testcaseName) where: - testcaseName | success | features | attemptToFix | quarantined | disabled + testcaseName | success | features | attemptToFix | quarantined | disabled "test-attempt-to-fix-failed" | false | ["org/example/cucumber/calculator/basic_arithmetic_failed.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [] | [] + ] | [] | [] "test-attempt-to-fix-succeeded" | true | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [] | [] + ] | [] | [] "test-attempt-to-fix-quarantined-failed" | true | ["org/example/cucumber/calculator/basic_arithmetic_failed.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [ + ] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [] + ] | [] "test-attempt-to-fix-quarantined-succeeded" | true | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [ + ] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [] + ] | [] "test-attempt-to-fix-disabled-failed" | true | ["org/example/cucumber/calculator/basic_arithmetic_failed.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [] | [ + ] | [] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") ] "test-attempt-to-fix-disabled-succeeded" | true | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [] | [ + ] | [] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") ] } diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature new file mode 100644 index 00000000000..24922fb146e --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature @@ -0,0 +1,10 @@ +Feature: Basic Arithmetic + + Background: A Calculator + Given a calculator I just turned on + + @datadog_skip_efd + Scenario: Addition + # Try to change one of the values below to provoke a failure + When I add 4 and 5 + Then the result is 9 diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..e2fdd4883ea --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1,8 @@ +[ { + "files" : [ { + "filename" : "org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature" + } ], + "span_id" : ${content_span_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..6045db2592b --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,145 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "cucumber-junit-4", + "test.status" : "pass", + "test.suite" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count} + }, + "name" : "cucumber.test_suite", + "resource" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "cucumber-junit-4", + "test.name" : "Addition", + "test.status" : "pass", + "test.suite" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", + "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "cucumber.test", + "parent_id" : ${content_parent_id}, + "resource" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic.Addition", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "cucumber-junit-4", + "test.early_flake.enabled" : "true", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "cucumber.test_session", + "resource" : "cucumber-junit-4", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "cucumber-junit-4", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "name" : "cucumber.test_module", + "resource" : "cucumber-junit-4", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java index d89f32a8bb1..3c56443de34 100644 --- a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java @@ -10,11 +10,8 @@ import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.util.Strings; -import java.lang.annotation.Annotation; -import java.util.ArrayList; import java.util.List; import munit.Suite; -import munit.Tag; import org.junit.runner.Description; import org.junit.runner.notification.Failure; @@ -44,7 +41,7 @@ public void testSuiteStarted(final Description description) { TestSuiteDescriptor suiteDescriptor = MUnitUtils.toSuiteDescriptor(description); Class testClass = description.getTestClass(); String testSuiteName = description.getClassName(); - List categories = getCategories(description); + List categories = MUnitUtils.getCategories(description); TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.MUNIT) .onTestSuiteStart( @@ -78,7 +75,7 @@ public void testStarted(final Description description) { TestSuiteDescriptor suiteDescriptor = MUnitUtils.toSuiteDescriptor(description); TestDescriptor testDescriptor = MUnitUtils.toTestDescriptor(description); String testName = description.getMethodName(); - List categories = getCategories(description); + List categories = MUnitUtils.getCategories(description); TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.MUNIT) .onTestStart( @@ -165,7 +162,7 @@ public void testIgnored(final Description description) { // earlier versions of MUnit (e.g. 0.7.28) trigger "testStarted" event for ignored tests, // while newer versions don't TestSuiteDescriptor suiteDescriptor = MUnitUtils.toSuiteDescriptor(description); - List categories = getCategories(description); + List categories = MUnitUtils.getCategories(description); TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.MUNIT) .onTestStart( @@ -194,7 +191,7 @@ public void testIgnored(final Description description) { if (!suiteStarted) { // there is a bug in MUnit 1.0.1+: start/finish events are not fired for skipped suites String testSuiteName = description.getClassName(); - List categories = getCategories(description); + List categories = MUnitUtils.getCategories(description); TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.MUNIT) .onTestSuiteStart( @@ -237,7 +234,7 @@ private void testCaseIgnored(final Description description) { TestSuiteDescriptor suiteDescriptor = MUnitUtils.toSuiteDescriptor(description); TestDescriptor testDescriptor = MUnitUtils.toTestDescriptor(description); String testName = description.getMethodName(); - List categories = getCategories(description); + List categories = MUnitUtils.getCategories(description); TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.MUNIT) .onTestIgnore( @@ -264,15 +261,4 @@ private static boolean isSuiteContainingChildren(final Description description) } return false; } - - private static List getCategories(Description description) { - List categories = new ArrayList<>(); - for (Annotation annotation : description.getAnnotations()) { - if (annotation.annotationType() == Tag.class) { - Tag tag = (Tag) annotation; - categories.add(tag.value()); - } - } - return categories; - } } diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitUtils.java b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitUtils.java index 1f2bad85589..09b952f0bdb 100644 --- a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitUtils.java +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitUtils.java @@ -3,8 +3,12 @@ import datadog.trace.api.civisibility.events.TestDescriptor; import datadog.trace.api.civisibility.events.TestSuiteDescriptor; import datadog.trace.util.MethodHandles; +import java.lang.annotation.Annotation; import java.lang.invoke.MethodHandle; +import java.util.ArrayList; +import java.util.List; import munit.MUnitRunner; +import munit.Tag; import org.junit.runner.Description; public abstract class MUnitUtils { @@ -34,4 +38,15 @@ public static TestSuiteDescriptor toSuiteDescriptor(Description description) { String testSuiteName = description.getClassName(); return new TestSuiteDescriptor(testSuiteName, testClass); } + + public static List getCategories(Description description) { + List categories = new ArrayList<>(); + for (Annotation annotation : description.getAnnotations()) { + if (annotation.annotationType() == Tag.class) { + Tag tag = (Tag) annotation; + categories.add(tag.value()); + } + } + return categories; + } } diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/MUnitExecutionInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/MUnitExecutionInstrumentation.java index de6288d8fb8..29dfb8e3874 100644 --- a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/MUnitExecutionInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/execution/MUnitExecutionInstrumentation.java @@ -19,6 +19,7 @@ import datadog.trace.util.Strings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.lang.reflect.Method; +import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -90,11 +91,12 @@ public static Future apply( Description description = MUnitUtils.createDescription(runner, test); TestIdentifier testIdentifier = JUnit4Utils.toTestIdentifier(description); TestSourceData testSourceData = JUnit4Utils.toTestSourceData(description); + Collection testTags = MUnitUtils.getCategories(description); TestExecutionPolicy executionPolicy = TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.MUNIT) - .executionPolicy(testIdentifier, testSourceData); + .executionPolicy(testIdentifier, testSourceData, testTags); if (!executionPolicy.applicable()) { // retries not applicable, run original method return null; diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/groovy/MUnitTest.groovy b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/groovy/MUnitTest.groovy index 19eb74ae243..4a2427a7b76 100644 --- a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/groovy/MUnitTest.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/groovy/MUnitTest.groovy @@ -12,6 +12,7 @@ import org.example.TestFailedThenSucceedMUnit import org.example.TestSkippedMUnit import org.example.TestSkippedSuiteMUnit import org.example.TestSucceedMUnit +import org.example.TestSucceedMUnitSkipEfd import org.example.TestSucceedMUnitSlow import org.junit.runner.JUnitCore @@ -57,10 +58,11 @@ class MUnitTest extends CiVisibilityInstrumentationTest { assertSpansData(testcaseName) where: - testcaseName | tests | knownTestsList - "test-efd-known-test" | [TestSucceedMUnit] | [new TestFQN("org.example.TestSucceedMUnit", "Calculator.add")] - "test-efd-new-test" | [TestSucceedMUnit] | [] - "test-efd-new-slow-test" | [TestSucceedMUnitSlow] | [] // is executed only twice + testcaseName | tests | knownTestsList + "test-efd-known-test" | [TestSucceedMUnit] | [new TestFQN("org.example.TestSucceedMUnit", "Calculator.add")] + "test-efd-new-test" | [TestSucceedMUnit] | [] + "test-efd-new-slow-test" | [TestSucceedMUnitSlow] | [] // is executed only twice + "test-efd-skip-new-test" | [TestSucceedMUnitSkipEfd] | [] } def "test impacted tests detection #testcaseName"() { diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..fe7e4d11f99 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,151 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "munit", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "munit-junit-4", + "test.early_flake.enabled" : "true", + "test.framework" : "munit", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "munit.test_session", + "resource" : "munit-junit-4", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "component" : "munit", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "munit", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "munit-junit-4", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "name" : "munit.test_module", + "resource" : "munit-junit-4", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "munit", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "munit", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "munit-junit-4", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedMUnitSkipEfd", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "name" : "munit.test_suite", + "resource" : "org.example.TestSucceedMUnitSkipEfd", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "munit", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "munit", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "munit-junit-4", + "test.name" : "Calculator.add", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedMUnitSkipEfd", + "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "munit.test", + "parent_id" : ${content_parent_id}, + "resource" : "org.example.TestSucceedMUnitSkipEfd.Calculator.add", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala new file mode 100644 index 00000000000..73d6742039b --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala @@ -0,0 +1,9 @@ +package org.example + +import munit.FunSuite + +class TestSucceedMUnitSkipEfd extends FunSuite { + test("Calculator.add".tag(new munit.Tag("datadog_skip_efd"))) { + assertEquals(1 + 2, 3) + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4SkipInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4SkipInstrumentation.java index c0dddc72226..fce0e9f2774 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4SkipInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4SkipInstrumentation.java @@ -10,7 +10,7 @@ import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.api.Config; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.telemetry.tag.SkipReason; import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; @@ -107,7 +107,7 @@ public static Boolean runChild( Method testMethod = JUnit4Utils.getTestMethod(description); List categories = JUnit4Utils.getCategories(testClass, testMethod); for (String category : categories) { - if (category.endsWith(InstrumentationBridge.ITR_UNSKIPPABLE_TAG)) { + if (category.endsWith(CIConstants.Tags.ITR_UNSKIPPABLE_TAG)) { return null; } } diff --git a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/execution/JUnit4ExecutionInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/execution/JUnit4ExecutionInstrumentation.java index 2ea225acd7e..3e656415f4b 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/execution/JUnit4ExecutionInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/execution/JUnit4ExecutionInstrumentation.java @@ -19,6 +19,7 @@ import datadog.trace.util.Strings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.lang.reflect.Method; +import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -101,10 +102,12 @@ public static Boolean apply( TestIdentifier testIdentifier = JUnit4Utils.toTestIdentifier(description); TestSourceData testSourceData = JUnit4Utils.toTestSourceData(description); + Collection testTags = + JUnit4Utils.getCategories(testSourceData.getTestClass(), testSourceData.getTestMethod()); TestExecutionPolicy executionPolicy = TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.JUNIT4) - .executionPolicy(testIdentifier, testSourceData); + .executionPolicy(testIdentifier, testSourceData, testTags); if (!executionPolicy.applicable()) { // retries not applicable, run original method return null; diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy index 95b107ac860..4789ca302f5 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy @@ -109,6 +109,7 @@ class JUnit4Test extends CiVisibilityInstrumentationTest { "test-efd-new-slow-test" | true | [TestSucceedSlow] | [] // is executed only twice "test-efd-new-very-slow-test" | true | [TestSucceedVerySlow] | [] // is executed only once "test-efd-faulty-session-threshold" | false | [TestFailedAndSucceed] | [] + "test-efd-skip-new-test" | true | [TestSucceedSkipEfd] | [] } def "test impacted tests detection #testcaseName"() { diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java new file mode 100644 index 00000000000..bdad7fe120d --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java @@ -0,0 +1,17 @@ +package org.example; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.experimental.categories.Category; + +public class TestSucceedSkipEfd { + + @Category(datadog_skip_efd.class) + @Test + public void test_succeed() { + assertTrue(true); + } + + public interface datadog_skip_efd {} +} diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..69c1b4edf99 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,154 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "junit4", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "junit-4.10", + "test.early_flake.enabled" : "true", + "test.framework" : "junit4", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "junit4.test_session", + "resource" : "junit-4.10", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "component" : "junit4", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "junit4", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "junit-4.10", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "name" : "junit4.test_module", + "resource" : "junit-4.10", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "junit4", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "junit4", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "junit-4.10", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "name" : "junit4.test_suite", + "resource" : "org.example.TestSucceedSkipEfd", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "junit4", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "junit4", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "junit-4.10", + "test.name" : "test_succeed", + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.traits" : "{\"category\":[\"org.example.TestSucceedSkipEfd$datadog_skip_efd\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "name" : "junit4.test", + "parent_id" : ${content_parent_id}, + "resource" : "org.example.TestSucceedSkipEfd.test_succeed", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java index e346ef9425e..f2bb1e7ee3c 100644 --- a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java @@ -121,8 +121,7 @@ private void testResourceExecutionStarted( Pair names = CucumberUtils.getFeatureAndScenarioNames(testDescriptor, classpathResourceName); String testName = names.getRight(); - List tags = - testDescriptor.getTags().stream().map(TestTag::getName).collect(Collectors.toList()); + List tags = JUnitPlatformUtils.getTags(testDescriptor); TestEventsHandlerHolder.HANDLERS .get(TestFrameworkInstrumentation.CUCUMBER) .onTestStart( diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/JUnit5CucumberSkipInstrumentation.java b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/JUnit5CucumberSkipInstrumentation.java index eef612bea28..c4c5a5b8f2e 100644 --- a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/JUnit5CucumberSkipInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/JUnit5CucumberSkipInstrumentation.java @@ -9,7 +9,7 @@ import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.api.Config; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.events.TestEventsHandler; import datadog.trace.api.civisibility.telemetry.tag.SkipReason; @@ -114,7 +114,7 @@ public static void shouldBeSkipped( if (skipReason == SkipReason.ITR) { Collection tags = testDescriptor.getTags(); for (TestTag tag : tags) { - if (InstrumentationBridge.ITR_UNSKIPPABLE_TAG.equals(tag.getName())) { + if (CIConstants.Tags.ITR_UNSKIPPABLE_TAG.equals(tag.getName())) { return; } } diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/groovy/CucumberTest.groovy b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/groovy/CucumberTest.groovy index d28a995025d..2b6710602c6 100644 --- a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/groovy/CucumberTest.groovy +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/groovy/CucumberTest.groovy @@ -98,6 +98,7 @@ class CucumberTest extends CiVisibilityInstrumentationTest { "test-efd-new-test" | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [] "test-efd-new-scenario-outline-${version()}" | ["org/example/cucumber/calculator/basic_arithmetic_with_examples.feature"] | [] "test-efd-new-slow-test" | ["org/example/cucumber/calculator/basic_arithmetic_slow.feature"] | [] + "test-efd-skip-new-test" | ["org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature"] | [] } def "test quarantined #testcaseName"() { @@ -181,31 +182,31 @@ class CucumberTest extends CiVisibilityInstrumentationTest { assertSpansData(testcaseName) where: - testcaseName | success | features | attemptToFix | quarantined | disabled + testcaseName | success | features | attemptToFix | quarantined | disabled "test-attempt-to-fix-failed" | false | ["org/example/cucumber/calculator/basic_arithmetic_failed.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [] | [] + ] | [] | [] "test-attempt-to-fix-succeeded" | true | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [] | [] + ] | [] | [] "test-attempt-to-fix-quarantined-failed" | true | ["org/example/cucumber/calculator/basic_arithmetic_failed.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [ + ] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [] + ] | [] "test-attempt-to-fix-quarantined-succeeded" | true | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [ + ] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [] + ] | [] "test-attempt-to-fix-disabled-failed" | true | ["org/example/cucumber/calculator/basic_arithmetic_failed.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") - ] | [] | [ + ] | [] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic", "Addition") ] "test-attempt-to-fix-disabled-succeeded" | true | ["org/example/cucumber/calculator/basic_arithmetic.feature"] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") - ] | [] | [ + ] | [] | [ new TestFQN("classpath:org/example/cucumber/calculator/basic_arithmetic.feature:Basic Arithmetic", "Addition") ] } diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature new file mode 100644 index 00000000000..4ba11ce0b3b --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature @@ -0,0 +1,9 @@ +Feature: Basic Arithmetic + + Background: A Calculator + Given a calculator I just turned on + + @datadog_skip_efd + Scenario: Addition + When I add 4 and 5 + Then the result is 9 diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..e2fdd4883ea --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1,8 @@ +[ { + "files" : [ { + "filename" : "org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature" + } ], + "span_id" : ${content_span_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..41ceb7cf4e3 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,145 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "cucumber-junit-5", + "test.status" : "pass", + "test.suite" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count} + }, + "name" : "cucumber.test_suite", + "resource" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "cucumber-junit-5", + "test.name" : "Addition", + "test.status" : "pass", + "test.suite" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", + "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "cucumber.test", + "parent_id" : ${content_parent_id}, + "resource" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic.Addition", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "cucumber-junit-5", + "test.early_flake.enabled" : "true", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "cucumber.test_session", + "resource" : "cucumber-junit-5", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "cucumber", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "cucumber", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "cucumber-junit-5", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "name" : "cucumber.test_module", + "resource" : "cucumber-junit-5", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java index d11a512a750..3065cf622e1 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java @@ -120,8 +120,7 @@ private void testMethodExecutionStarted(TestDescriptor testDescriptor, MethodSou TestDescriptor suiteDescriptor = SpockUtils.getSpecDescriptor(testDescriptor); String displayName = testDescriptor.getDisplayName(); String testParameters = JUnitPlatformUtils.getParameters(testSource, displayName); - List tags = - testDescriptor.getTags().stream().map(TestTag::getName).collect(Collectors.toList()); + List tags = JUnitPlatformUtils.getTags(testDescriptor); TestSourceData testSourceData = SpockUtils.toTestSourceData(testDescriptor); TestEventsHandlerHolder.HANDLERS diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockUtils.java b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockUtils.java index 436aa78ac33..a5baa28f28d 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockUtils.java +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockUtils.java @@ -1,6 +1,6 @@ package datadog.trace.instrumentation.junit5; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.config.TestSourceData; import java.lang.invoke.MethodHandle; @@ -72,7 +72,7 @@ public static Collection getTags(SpockNode spockNode) { public static boolean isItrUnskippable(SpockNode spockNode) { Collection tags = getTags(spockNode); for (TestTag tag : tags) { - if (InstrumentationBridge.ITR_UNSKIPPABLE_TAG.equals(tag.getName())) { + if (CIConstants.Tags.ITR_UNSKIPPABLE_TAG.equals(tag.getName())) { return true; } } diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/SpockTest.groovy b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/SpockTest.groovy index 518e611f3b9..5c150e9d4b1 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/SpockTest.groovy +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/SpockTest.groovy @@ -14,6 +14,7 @@ import org.example.TestParameterizedSpock import org.example.TestSucceedAndFailedSpock import org.example.TestSucceedSetupSpecSpock import org.example.TestSucceedSpock +import org.example.TestSucceedSpockSkipEfd import org.example.TestSucceedSpockSlow import org.example.TestSucceedSpockUnskippable import org.example.TestSucceedSpockUnskippableSuite @@ -113,6 +114,7 @@ class SpockTest extends CiVisibilityInstrumentationTest { "test-efd-new-slow-test" | true | [TestSucceedSpockSlow] | [] // is executed only twice "test-efd-new-very-slow-test" | true | [TestSucceedSpockVerySlow] | [] // is executed only once "test-efd-faulty-session-threshold" | false | [TestSucceedAndFailedSpock] | [] + "test-efd-skip-new-test" | true | [TestSucceedSpockSkipEfd] | [] } def "test impacted tests detection #testcaseName"() { diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy new file mode 100644 index 00000000000..cc1033ca22b --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy @@ -0,0 +1,14 @@ +package org.example + +import datadog.trace.api.civisibility.CIConstants +import spock.lang.Specification +import spock.lang.Tag + +class TestSucceedSpockSkipEfd extends Specification { + + @Tag(CIConstants.Tags.SKIP_EFD_TAG) + def "test success"() { + expect: + 1 == 1 + } +} diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippable.groovy b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippable.groovy index 281ef56156d..7d7e9e37d51 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippable.groovy +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippable.groovy @@ -1,12 +1,12 @@ package org.example -import datadog.trace.api.civisibility.InstrumentationBridge +import datadog.trace.api.civisibility.CIConstants import spock.lang.Specification import spock.lang.Tag class TestSucceedSpockUnskippable extends Specification { - @Tag(InstrumentationBridge.ITR_UNSKIPPABLE_TAG) + @Tag(CIConstants.Tags.ITR_UNSKIPPABLE_TAG) def "test success"() { expect: 1 == 1 diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippableSuite.groovy b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippableSuite.groovy index b61debf26c7..a216a51d8b2 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippableSuite.groovy +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockUnskippableSuite.groovy @@ -1,10 +1,10 @@ package org.example -import datadog.trace.api.civisibility.InstrumentationBridge +import datadog.trace.api.civisibility.CIConstants import spock.lang.Specification import spock.lang.Tag -@Tag(InstrumentationBridge.ITR_UNSKIPPABLE_TAG) +@Tag(CIConstants.Tags.ITR_UNSKIPPABLE_TAG) class TestSucceedSpockUnskippableSuite extends Specification { def "test success"() { diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..04b8dd32737 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,154 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "component" : "spock", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "spock", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "spock-junit-5", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSpockSkipEfd", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "name" : "spock.test_suite", + "resource" : "org.example.TestSucceedSpockSkipEfd", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "spock", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "spock", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "spock-junit-5", + "test.name" : "test success", + "test.source.file" : "dummy_source_path", + "test.source.method" : "test success()V", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSpockSkipEfd", + "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "name" : "spock.test", + "parent_id" : ${content_parent_id}, + "resource" : "org.example.TestSucceedSpockSkipEfd.test success", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "spock", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "spock-junit-5", + "test.early_flake.enabled" : "true", + "test.framework" : "spock", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "spock.test_session", + "resource" : "spock-junit-5", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "spock", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "spock", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "spock-junit-5", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "name" : "spock.test_module", + "resource" : "spock-junit-5", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnit5SkipInstrumentation.java b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnit5SkipInstrumentation.java index 212130a6235..35218d456a9 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnit5SkipInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnit5SkipInstrumentation.java @@ -10,7 +10,7 @@ import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.api.Config; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.events.TestEventsHandler; import datadog.trace.api.civisibility.telemetry.tag.SkipReason; @@ -109,7 +109,7 @@ public static void shouldBeSkipped( if (skipReason == SkipReason.ITR) { Collection tags = testDescriptor.getTags(); for (TestTag tag : tags) { - if (InstrumentationBridge.ITR_UNSKIPPABLE_TAG.equals(tag.getName())) { + if (CIConstants.Tags.ITR_UNSKIPPABLE_TAG.equals(tag.getName())) { return; } } diff --git a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnitPlatformUtils.java b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnitPlatformUtils.java index 74cfde45593..002f1148621 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnitPlatformUtils.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/JUnitPlatformUtils.java @@ -13,6 +13,7 @@ import java.lang.reflect.Method; import java.util.List; import java.util.ListIterator; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.junit.platform.commons.JUnitException; @@ -21,6 +22,7 @@ import org.junit.platform.engine.TestDescriptor; import org.junit.platform.engine.TestEngine; import org.junit.platform.engine.TestSource; +import org.junit.platform.engine.TestTag; import org.junit.platform.engine.UniqueId; import org.junit.platform.engine.support.descriptor.ClassSource; import org.junit.platform.engine.support.descriptor.MethodSource; @@ -240,4 +242,8 @@ public static TestFrameworkInstrumentation engineIdToFramework(String engineId) return TestFrameworkInstrumentation.JUNIT5; } } + + public static List getTags(TestDescriptor testDescriptor) { + return testDescriptor.getTags().stream().map(TestTag::getName).collect(Collectors.toList()); + } } diff --git a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java index 24f794b83dd..143de0659ec 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java @@ -120,8 +120,7 @@ private void testMethodExecutionStarted(TestDescriptor testDescriptor, MethodSou String displayName = testDescriptor.getDisplayName(); String testName = testSource.getMethodName(); String testParameters = JUnitPlatformUtils.getParameters(testSource, displayName); - List tags = - testDescriptor.getTags().stream().map(TestTag::getName).collect(Collectors.toList()); + List tags = JUnitPlatformUtils.getTags(testDescriptor); TestSourceData testSourceData = JUnitPlatformUtils.toTestSourceData(testDescriptor); TestEventsHandlerHolder.HANDLERS diff --git a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/execution/JUnit5ExecutionInstrumentation.java b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/execution/JUnit5ExecutionInstrumentation.java index 21aa292daac..c464c299f0b 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/execution/JUnit5ExecutionInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/execution/JUnit5ExecutionInstrumentation.java @@ -22,6 +22,7 @@ import datadog.trace.util.Strings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -142,10 +143,11 @@ public static Boolean execute(@Advice.This HierarchicalTestExecutorService.TestT TestIdentifier testIdentifier = TestDataFactory.createTestIdentifier(testDescriptor); TestSourceData testSource = TestDataFactory.createTestSourceData(testDescriptor); + Collection testTags = JUnitPlatformUtils.getTags(testDescriptor); TestExecutionPolicy executionPolicy = TestEventsHandlerHolder.HANDLERS .get(framework) - .executionPolicy(testIdentifier, testSource); + .executionPolicy(testIdentifier, testSource, testTags); if (!executionPolicy.applicable()) { return null; } diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/groovy/JUnit5Test.groovy b/dd-java-agent/instrumentation/junit-5.3/src/test/groovy/JUnit5Test.groovy index 655cf3b2367..1e97c6464cb 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/test/groovy/JUnit5Test.groovy +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/groovy/JUnit5Test.groovy @@ -28,6 +28,7 @@ import org.example.TestSucceed import org.example.TestSucceedAndSkipped import org.example.TestSucceedExpectedException import org.example.TestSucceedNested +import org.example.TestSucceedSkipEfd import org.example.TestSucceedSlow import org.example.TestSucceedUnskippable import org.example.TestSucceedUnskippableSuite @@ -146,6 +147,7 @@ class JUnit5Test extends CiVisibilityInstrumentationTest { "test-efd-new-slow-test" | true | [TestSucceedSlow] | [] // is executed only twice "test-efd-new-very-slow-test" | true | [TestSucceedVerySlow] | [] // is executed only once "test-efd-faulty-session-threshold" | false | [TestFailedAndSucceed] | [] + "test-efd-skip-new-test" | true | [TestSucceedSkipEfd] | [] } def "test impacted tests detection #testcaseName"() { diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java new file mode 100644 index 00000000000..4f7af78cb52 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java @@ -0,0 +1,17 @@ +package org.example; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import datadog.trace.api.civisibility.CIConstants; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Tags; +import org.junit.jupiter.api.Test; + +public class TestSucceedSkipEfd { + + @Test + @Tags({@Tag(CIConstants.Tags.SKIP_EFD_TAG)}) + public void test_succeed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippable.java b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippable.java index 86496ac40ee..99f2c356ab8 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippable.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippable.java @@ -2,7 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Tags; import org.junit.jupiter.api.Test; @@ -10,7 +10,7 @@ public class TestSucceedUnskippable { @Test - @Tags({@Tag(InstrumentationBridge.ITR_UNSKIPPABLE_TAG)}) + @Tags({@Tag(CIConstants.Tags.ITR_UNSKIPPABLE_TAG)}) public void test_succeed() { assertTrue(true); } diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippableSuite.java b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippableSuite.java index f1513089cb5..761f6fbfe54 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippableSuite.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedUnskippableSuite.java @@ -2,12 +2,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Tags; import org.junit.jupiter.api.Test; -@Tags({@Tag(InstrumentationBridge.ITR_UNSKIPPABLE_TAG)}) +@Tags({@Tag(CIConstants.Tags.ITR_UNSKIPPABLE_TAG)}) public class TestSucceedUnskippableSuite { @Test diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..869c10ea399 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,154 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "junit5", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "junit-5.3", + "test.early_flake.enabled" : "true", + "test.framework" : "junit5", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "junit5.test_session", + "resource" : "junit-5.3", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "component" : "junit5", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "junit5", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "junit-5.3", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "name" : "junit5.test_module", + "resource" : "junit-5.3", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "junit5", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "junit5", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "junit-5.3", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "name" : "junit5.test_suite", + "resource" : "org.example.TestSucceedSkipEfd", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "junit5", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "junit5", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "junit-5.3", + "test.name" : "test_succeed", + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "name" : "junit5.test", + "parent_id" : ${content_parent_id}, + "resource" : "org.example.TestSucceedSkipEfd.test_succeed", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/ExecutionContext.java b/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/ExecutionContext.java index d1c223e25a8..279163854da 100644 --- a/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/ExecutionContext.java +++ b/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/ExecutionContext.java @@ -4,6 +4,7 @@ import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.config.TestSourceData; import datadog.trace.api.civisibility.execution.TestExecutionPolicy; +import java.util.Collection; public class ExecutionContext { @@ -39,8 +40,9 @@ public TestExecutionPolicy getExecutionPolicy() { public static ExecutionContext create(Scenario scenario) { TestIdentifier testIdentifier = KarateUtils.toTestIdentifier(scenario); + Collection testTags = scenario.getTagsEffective().getTagKeys(); return new ExecutionContext( TestEventsHandlerHolder.TEST_EVENTS_HANDLER.executionPolicy( - testIdentifier, TestSourceData.UNKNOWN)); + testIdentifier, TestSourceData.UNKNOWN, testTags)); } } diff --git a/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java b/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java index c81b8c0d1da..66408c771c2 100644 --- a/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java +++ b/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java @@ -14,7 +14,7 @@ import com.intuit.karate.core.Step; import com.intuit.karate.core.StepResult; import datadog.trace.api.Config; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.config.TestSourceData; import datadog.trace.api.civisibility.events.TestDescriptor; @@ -121,7 +121,7 @@ public boolean beforeScenario(ScenarioRuntime sr) { if (skipReason != null && !(skipReason == SkipReason.ITR - && categories.contains(InstrumentationBridge.ITR_UNSKIPPABLE_TAG))) { + && categories.contains(CIConstants.Tags.ITR_UNSKIPPABLE_TAG))) { TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestIgnore( suiteDescriptor, testDescriptor, diff --git a/dd-java-agent/instrumentation/karate/src/test/groovy/KarateTest.groovy b/dd-java-agent/instrumentation/karate/src/test/groovy/KarateTest.groovy index f1c372976ce..d99b550dec7 100644 --- a/dd-java-agent/instrumentation/karate/src/test/groovy/KarateTest.groovy +++ b/dd-java-agent/instrumentation/karate/src/test/groovy/KarateTest.groovy @@ -94,6 +94,7 @@ class KarateTest extends CiVisibilityInstrumentationTest { "test-efd-new-parameterized-test" | [TestParameterizedKarate] | [] "test-efd-new-slow-test" | [TestSucceedKarateSlow] | [] // is executed only twice "test-efd-faulty-session-threshold" | [TestParameterizedMoreCasesKarate] | [] + "test-efd-skip-new-test" | [TestSucceedKarateSkipEfd] | [] } def "test quarantined #testcaseName"() { diff --git a/dd-java-agent/instrumentation/karate/src/test/java/org/example/TestSucceedKarateSkipEfd.java b/dd-java-agent/instrumentation/karate/src/test/java/org/example/TestSucceedKarateSkipEfd.java new file mode 100644 index 00000000000..acbcbb9f73b --- /dev/null +++ b/dd-java-agent/instrumentation/karate/src/test/java/org/example/TestSucceedKarateSkipEfd.java @@ -0,0 +1,11 @@ +package org.example; + +import com.intuit.karate.junit5.Karate; + +public class TestSucceedKarateSkipEfd { + + @Karate.Test + public Karate testSucceed() { + return Karate.run("classpath:org/example/test_succeed_skip_efd.feature"); + } +} diff --git a/dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature b/dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature new file mode 100644 index 00000000000..128001b31cc --- /dev/null +++ b/dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature @@ -0,0 +1,6 @@ +@foo +Feature: test succeed + + @datadog_skip_efd + Scenario: first scenario + * print 'first' diff --git a/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..ef4d07b8eaf --- /dev/null +++ b/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,170 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "component" : "karate", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "step.name" : "* print 'first'" + }, + "metrics" : { + "step.endLine" : 6, + "step.startLine" : 6 + }, + "name" : "karate.step", + "parent_id" : ${content_parent_id}, + "resource" : "* print 'first'", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start}, + "trace_id" : ${content_trace_id} + }, + "type" : "span", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "component" : "karate", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.framework" : "karate", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "karate", + "test.status" : "pass", + "test.suite" : "[org/example/test_succeed_skip_efd] test succeed", + "test.traits" : "{\"category\":[\"foo\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count} + }, + "name" : "karate.test_suite", + "resource" : "[org/example/test_succeed_skip_efd] test succeed", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "karate", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.framework" : "karate", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "karate", + "test.name" : "first scenario", + "test.status" : "pass", + "test.suite" : "[org/example/test_succeed_skip_efd] test succeed", + "test.traits" : "{\"category\":[\"datadog_skip_efd\",\"foo\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "karate.test", + "parent_id" : ${content_parent_id_2}, + "resource" : "[org/example/test_succeed_skip_efd] test succeed.first scenario", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_parent_id}, + "start" : ${content_start_3}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "karate", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "karate", + "test.early_flake.enabled" : "true", + "test.framework" : "karate", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "karate.test_session", + "resource" : "karate", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_4}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_5}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "karate", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "karate", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "karate", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "name" : "karate.test_module", + "resource" : "karate", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_5}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java index b6db8da856c..d0ddd84d81e 100644 --- a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java +++ b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java @@ -1,6 +1,6 @@ package datadog.trace.instrumentation.scalatest; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.config.TestSourceData; import datadog.trace.api.civisibility.events.TestDescriptor; @@ -140,7 +140,7 @@ private static void onTestStart(TestStarting event) { Collection categories; TestIdentifier testIdentifier = new TestIdentifier(testSuiteName, testName, null); if (context.itrUnskippable(testIdentifier)) { - categories = Collections.singletonList(InstrumentationBridge.ITR_UNSKIPPABLE_TAG); + categories = Collections.singletonList(CIConstants.Tags.ITR_UNSKIPPABLE_TAG); } else { categories = Collections.emptyList(); } diff --git a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/RunContext.java b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/RunContext.java index 9d67dc38699..1e243561c86 100644 --- a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/RunContext.java +++ b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/RunContext.java @@ -1,5 +1,6 @@ package datadog.trace.instrumentation.scalatest; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.InstrumentationBridge; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.config.TestSourceData; @@ -10,6 +11,8 @@ import datadog.trace.api.civisibility.execution.TestExecutionPolicy; import datadog.trace.api.civisibility.telemetry.tag.SkipReason; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import javax.annotation.Nullable; @@ -38,7 +41,8 @@ public static void destroy(int runStamp) { InstrumentationBridge.createTestEventsHandler("scalatest", null, null); private final java.util.Map skipReasonByTest = new ConcurrentHashMap<>(); - private final java.util.Set itrUnskippableTests = ConcurrentHashMap.newKeySet(); + private final java.util.Map> tagsByTest = + new ConcurrentHashMap<>(); private final java.util.Map executionPolicies = new ConcurrentHashMap<>(); @@ -59,27 +63,43 @@ public SkipReason getSkipReason(TestIdentifier test) { } public boolean itrUnskippable(TestIdentifier test) { - return itrUnskippableTests.remove(test); + return tagsByTest + .getOrDefault(test, Collections.emptyList()) + .contains(CIConstants.Tags.ITR_UNSKIPPABLE_TAG); } - public scala.collection.immutable.List> skip( + public Collection tags(TestIdentifier test) { + return tagsByTest.getOrDefault(test, Collections.emptyList()); + } + + public void populateTags( String suiteId, Map> tags, scala.collection.immutable.List> namesAndSkipStatuses) { + Iterator> it = namesAndSkipStatuses.iterator(); + while (it.hasNext()) { + Tuple2 nameAndSkipStatus = it.next(); + String testName = nameAndSkipStatus._1(); + TestIdentifier test = new TestIdentifier(suiteId, testName, null); + populateTags(test, tags); + } + } + + public scala.collection.immutable.List> skip( + String suiteId, + scala.collection.immutable.List> namesAndSkipStatuses) { java.util.List> modifiedNamesAndSkipStatuses = new ArrayList<>(namesAndSkipStatuses.size()); Iterator> it = namesAndSkipStatuses.iterator(); while (it.hasNext()) { - Tuple2 nameAndSkipStatus = skip(suiteId, tags, it.next()); + Tuple2 nameAndSkipStatus = skip(suiteId, it.next()); modifiedNamesAndSkipStatuses.add(nameAndSkipStatus); } return JavaConverters.asScalaBuffer(modifiedNamesAndSkipStatuses).toList(); } private Tuple2 skip( - String suiteId, - Map> tags, - Tuple2 testNameAndSkipStatus) { + String suiteId, Tuple2 testNameAndSkipStatus) { if (testNameAndSkipStatus._2()) { return testNameAndSkipStatus; // test already skipped } @@ -87,13 +107,8 @@ private Tuple2 skip( String testName = testNameAndSkipStatus._1(); TestIdentifier test = new TestIdentifier(suiteId, testName, null); - boolean itrUnskippable = isItrUnskippable(test, tags); - if (itrUnskippable) { - itrUnskippableTests.add(test); - } - SkipReason skipReason = eventHandler.skipReason(test); - if (skipReason == null || skipReason == SkipReason.ITR && itrUnskippable) { + if (skipReason == null || skipReason == SkipReason.ITR && itrUnskippable(test)) { return testNameAndSkipStatus; } @@ -101,18 +116,25 @@ private Tuple2 skip( return new Tuple2<>(testName, true); } - public boolean skip(TestIdentifier test, Map> tags) { - boolean itrUnskippable = isItrUnskippable(test, tags); - if (itrUnskippable) { - itrUnskippableTests.add(test); + public void populateTags(TestIdentifier test, Map> tags) { + Option> testTagsOption = tags.get(test.getName()); + if (testTagsOption.isEmpty()) { + return; + } + + Set testTags = testTagsOption.get(); + if (testTags != null) { + tagsByTest.put(test, JavaConverters.asJavaCollection(testTags)); } + } + public boolean skip(TestIdentifier test, Map> tags) { SkipReason skipReason = eventHandler.skipReason(test); if (skipReason == null) { return false; } - if (skipReason == SkipReason.ITR && itrUnskippable) { + if (skipReason == SkipReason.ITR && itrUnskippable(test)) { return false; } @@ -120,19 +142,10 @@ public boolean skip(TestIdentifier test, Map> tags) { return true; } - private boolean isItrUnskippable(TestIdentifier test, Map> tags) { - Option> testTagsOption = tags.get(test.getName()); - if (testTagsOption.isEmpty()) { - return false; - } - Set testTags = testTagsOption.get(); - return testTags != null && testTags.contains(InstrumentationBridge.ITR_UNSKIPPABLE_TAG); - } - public TestExecutionPolicy getOrCreateExecutionPolicy( - TestIdentifier testIdentifier, TestSourceData testSourceData) { + TestIdentifier testIdentifier, TestSourceData testSourceData, Collection testTags) { return executionPolicies.computeIfAbsent( - testIdentifier, test -> eventHandler.executionPolicy(test, testSourceData)); + testIdentifier, test -> eventHandler.executionPolicy(test, testSourceData, testTags)); } @Nullable diff --git a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/ScalatestSkipInstrumentation.java b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/ScalatestSkipInstrumentation.java index e885d99079f..dfd6763c5df 100644 --- a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/ScalatestSkipInstrumentation.java +++ b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/ScalatestSkipInstrumentation.java @@ -8,7 +8,6 @@ import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; -import datadog.trace.api.Config; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.bootstrap.InstrumentationContext; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -30,9 +29,7 @@ public ScalatestSkipInstrumentation() { @Override public boolean isApplicable(Set enabledSystems) { - return super.isApplicable(enabledSystems) - && (Config.get().isCiVisibilityTestSkippingEnabled() - || Config.get().isCiVisibilityTestManagementEnabled()); + return super.isApplicable(enabledSystems); } @Override @@ -123,6 +120,8 @@ public static void apply( TestIdentifier test = new TestIdentifier(suiteId, testName, null); RunContext runContext = InstrumentationContext.get(Filter.class, RunContext.class).get(filter); + runContext.populateTags(test, tags); + if (runContext.skip(test, tags)) { filterResult = new Tuple2<>(false, true); } @@ -146,7 +145,9 @@ public static void apply( } RunContext runContext = InstrumentationContext.get(Filter.class, RunContext.class).get(filter); - filterResult = runContext.skip(suiteId, tags, filterResult); + runContext.populateTags(suiteId, tags, filterResult); + + filterResult = runContext.skip(suiteId, filterResult); } } } diff --git a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/execution/ScalatestExecutionInstrumentation.java b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/execution/ScalatestExecutionInstrumentation.java index dc054666c9c..2c662b378e2 100644 --- a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/execution/ScalatestExecutionInstrumentation.java +++ b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/execution/ScalatestExecutionInstrumentation.java @@ -87,7 +87,8 @@ public static void beforeTest( TestIdentifier testIdentifier = new TestIdentifier(suite.suiteId(), testName, null); TestSourceData testSourceData = new TestSourceData(suite.getClass(), null, null); TestExecutionPolicy executionPolicy = - context.getOrCreateExecutionPolicy(testIdentifier, testSourceData); + context.getOrCreateExecutionPolicy( + testIdentifier, testSourceData, context.tags(testIdentifier)); invokeWithFixture = new TestExecutionWrapper(invokeWithFixture, executionPolicy); } diff --git a/dd-java-agent/instrumentation/scalatest/src/test/groovy/ScalatestTest.groovy b/dd-java-agent/instrumentation/scalatest/src/test/groovy/ScalatestTest.groovy index f0a48169d77..9f7ba01037d 100644 --- a/dd-java-agent/instrumentation/scalatest/src/test/groovy/ScalatestTest.groovy +++ b/dd-java-agent/instrumentation/scalatest/src/test/groovy/ScalatestTest.groovy @@ -15,6 +15,7 @@ import org.example.TestSucceed import org.example.TestSucceedFlatSpec import org.example.TestSucceedMoreCases import org.example.TestSucceedParameterized +import org.example.TestSucceedSkipEfd import org.example.TestSucceedSlow import org.example.TestSucceedUnskippable import org.scalatest.tools.Runner @@ -83,6 +84,7 @@ class ScalatestTest extends CiVisibilityInstrumentationTest { "test-efd-new-test" | [TestSucceed] | [] "test-efd-new-slow-test" | [TestSucceedSlow] | [] // is executed only twice "test-efd-faulty-session-threshold" | [TestSucceedMoreCases] | [] + "test-efd-skip-new-test" | [TestSucceedSkipEfd] | [] } def "test impacted tests detection #testcaseName"() { diff --git a/dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..86ee57ec09d --- /dev/null +++ b/dd-java-agent/instrumentation/scalatest/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,150 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "component" : "scalatest", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "scalatest", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "scalatest", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "name" : "scalatest.test_suite", + "resource" : "org.example.TestSucceedSkipEfd", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "scalatest", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "scalatest", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "scalatest", + "test.name" : "test should assert something", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "scalatest.test", + "parent_id" : ${content_parent_id}, + "resource" : "org.example.TestSucceedSkipEfd.test should assert something", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "scalatest", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "scalatest", + "test.early_flake.enabled" : "true", + "test.framework" : "scalatest", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "scalatest.test_session", + "resource" : "scalatest", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "scalatest", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "scalatest", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "scalatest", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "name" : "scalatest.test_module", + "resource" : "scalatest", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala b/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala new file mode 100644 index 00000000000..a981379fe06 --- /dev/null +++ b/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala @@ -0,0 +1,14 @@ +package org.example + +import datadog.trace.api.civisibility.CIConstants.Tags +import datadog.trace.api.civisibility.{CIConstants, InstrumentationBridge} +import org.scalatest.Tag +import org.scalatest.flatspec.AnyFlatSpec + +object SkipEfdTag extends Tag(Tags.SKIP_EFD_TAG) + +class TestSucceedSkipEfd extends AnyFlatSpec { + "test" should "assert something" taggedAs SkipEfdTag in { + assert(2 + 2 > 3) + } +} diff --git a/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedUnskippable.scala b/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedUnskippable.scala index 27ed233b710..7cd74a71970 100644 --- a/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedUnskippable.scala +++ b/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedUnskippable.scala @@ -1,10 +1,11 @@ package org.example -import datadog.trace.api.civisibility.InstrumentationBridge +import datadog.trace.api.civisibility.CIConstants.Tags +import datadog.trace.api.civisibility.{CIConstants, InstrumentationBridge} import org.scalatest.Tag import org.scalatest.flatspec.AnyFlatSpec -object ItrUnskippableTag extends Tag(InstrumentationBridge.ITR_UNSKIPPABLE_TAG) +object ItrUnskippableTag extends Tag(Tags.ITR_UNSKIPPABLE_TAG) class TestSucceedUnskippable extends AnyFlatSpec { "test" should "assert something" taggedAs ItrUnskippableTag in { diff --git a/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TestNGSkipInstrumentation.java b/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TestNGSkipInstrumentation.java index 245fd81cfdb..3302c986c55 100644 --- a/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TestNGSkipInstrumentation.java +++ b/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TestNGSkipInstrumentation.java @@ -8,7 +8,7 @@ import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.api.Config; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import datadog.trace.api.civisibility.config.TestIdentifier; import datadog.trace.api.civisibility.telemetry.tag.SkipReason; import java.lang.reflect.Method; @@ -75,7 +75,7 @@ public static void invokeMethod( if (skipReason == SkipReason.ITR) { List groups = TestNGUtils.getGroups(method); - if (groups.contains(InstrumentationBridge.ITR_UNSKIPPABLE_TAG)) { + if (groups.contains(CIConstants.Tags.ITR_UNSKIPPABLE_TAG)) { return; } } diff --git a/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/execution/RetryAnalyzer.java b/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/execution/RetryAnalyzer.java index 1fa64bbfb41..c4df845cc88 100644 --- a/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/execution/RetryAnalyzer.java +++ b/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/execution/RetryAnalyzer.java @@ -6,6 +6,7 @@ import datadog.trace.api.civisibility.execution.TestExecutionPolicy; import datadog.trace.instrumentation.testng.TestEventsHandlerHolder; import datadog.trace.instrumentation.testng.TestNGUtils; +import java.util.Collection; import org.testng.IRetryAnalyzer; import org.testng.ITestResult; @@ -23,9 +24,10 @@ public boolean retry(ITestResult result) { if (executionPolicy == null) { TestIdentifier testIdentifier = TestNGUtils.toTestIdentifier(result); TestSourceData testSourceData = TestNGUtils.toTestSourceData(result); + Collection testTags = TestNGUtils.getGroups(result); executionPolicy = TestEventsHandlerHolder.TEST_EVENTS_HANDLER.executionPolicy( - testIdentifier, testSourceData); + testIdentifier, testSourceData, testTags); } } } diff --git a/dd-java-agent/instrumentation/testng/src/testFixtures/groovy/datadog/trace/instrumentation/testng/TestNGTest.groovy b/dd-java-agent/instrumentation/testng/src/testFixtures/groovy/datadog/trace/instrumentation/testng/TestNGTest.groovy index 636b3a6e07f..589dad8f372 100644 --- a/dd-java-agent/instrumentation/testng/src/testFixtures/groovy/datadog/trace/instrumentation/testng/TestNGTest.groovy +++ b/dd-java-agent/instrumentation/testng/src/testFixtures/groovy/datadog/trace/instrumentation/testng/TestNGTest.groovy @@ -138,6 +138,7 @@ abstract class TestNGTest extends CiVisibilityInstrumentationTest { "test-efd-new-slow-test" | true | [TestSucceedSlow] | [] // is executed only twice "test-efd-new-very-slow-test" | true | [TestSucceedVerySlow] | [] // is executed only once "test-efd-faulty-session-threshold" | false | [TestFailedAndSucceed] | [] + "test-efd-skip-new-test" | true | [TestSucceedSkipEfd] | [] } def "test impacted tests detection #testcaseName"() { @@ -253,8 +254,8 @@ abstract class TestNGTest extends CiVisibilityInstrumentationTest { assertTestsOrder(expectedOrder) where: - testcaseName | tests | knownTestsList | expectedOrder - "ordering-methods" | [TestSucceedAndSkipped] | [test("org.example.TestSucceedAndSkipped", "test_skipped")] | [ + testcaseName | tests | knownTestsList | expectedOrder + "ordering-methods" | [TestSucceedAndSkipped] | [test("org.example.TestSucceedAndSkipped", "test_skipped")] | [ test("org.example.TestSucceedAndSkipped", "test_succeed"), test("org.example.TestSucceedAndSkipped", "test_skipped") ] @@ -262,7 +263,7 @@ abstract class TestNGTest extends CiVisibilityInstrumentationTest { test('org.example.TestSucceedAndSkipped', 'test_succeed'), test('org.example.TestSucceedAndSkipped', 'test_skipped'), test('org.example.TestSucceedNested$NestedSuite', 'test_succeed_nested'), - ] | [ + ] | [ test('org.example.TestSucceedNested', 'test_succeed'), test('org.example.TestSucceedAndSkipped', 'test_skipped'), test('org.example.TestSucceedAndSkipped', 'test_succeed'), diff --git a/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java b/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java new file mode 100644 index 00000000000..555092bf482 --- /dev/null +++ b/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java @@ -0,0 +1,14 @@ +package org.example; + +import static org.testng.Assert.assertTrue; + +import datadog.trace.api.civisibility.CIConstants; +import org.testng.annotations.Test; + +public class TestSucceedSkipEfd { + + @Test(groups = CIConstants.Tags.SKIP_EFD_TAG) + public void test_succeed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedUnskippable.java b/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedUnskippable.java index 48c37b6eb60..785b5ca9f51 100644 --- a/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedUnskippable.java +++ b/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedUnskippable.java @@ -2,10 +2,10 @@ import static org.testng.Assert.assertTrue; -import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.CIConstants; import org.testng.annotations.Test; -@Test(groups = InstrumentationBridge.ITR_UNSKIPPABLE_TAG) +@Test(groups = CIConstants.Tags.ITR_UNSKIPPABLE_TAG) public class TestSucceedUnskippable { @Test diff --git a/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/coverages.ftl b/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl new file mode 100644 index 00000000000..a95c7ac7bf4 --- /dev/null +++ b/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl @@ -0,0 +1,154 @@ +[ { + "content" : { + "duration" : ${content_duration}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "component" : "testng", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_suite_end", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "testng", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "testng-7", + "test.source.file" : "dummy_source_path", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "name" : "testng.test_suite", + "resource" : "org.example.TestSucceedSkipEfd", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id} + }, + "type" : "test_suite_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_2}, + "error" : 0, + "meta" : { + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "testng", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "test.framework" : "testng", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.is_new" : "true", + "test.module" : "testng-7", + "test.name" : "test_succeed", + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.status" : "pass", + "test.suite" : "org.example.TestSucceedSkipEfd", + "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "name" : "testng.test", + "parent_id" : ${content_parent_id}, + "resource" : "org.example.TestSucceedSkipEfd.test_succeed", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "span_id" : ${content_span_id}, + "start" : ${content_start_2}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id}, + "test_suite_id" : ${content_test_suite_id}, + "trace_id" : ${content_trace_id} + }, + "type" : "test", + "version" : 2 +}, { + "content" : { + "duration" : ${content_duration_3}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "_dd.profiling.ctx" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "component" : "testng", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "language" : "jvm", + "library_version" : ${content_meta_library_version}, + "runtime-id" : ${content_meta_runtime_id}, + "span.kind" : "test_session_end", + "test.command" : "testng-7", + "test.early_flake.enabled" : "true", + "test.framework" : "testng", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "process_id" : ${content_metrics_process_id} + }, + "name" : "testng.test_session", + "resource" : "testng-7", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_3}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_session_end", + "version" : 1 +}, { + "content" : { + "duration" : ${content_duration_4}, + "error" : 0, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "component" : "testng", + "dummy_ci_tag" : "dummy_ci_tag_value", + "env" : "none", + "library_version" : ${content_meta_library_version}, + "span.kind" : "test_module_end", + "test.early_flake.enabled" : "true", + "test.framework" : "testng", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.module" : "testng-7", + "test.status" : "pass", + "test.type" : "test", + "test_session.name" : "session-name" + }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "name" : "testng.test_module", + "resource" : "testng-7", + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "start" : ${content_start_4}, + "test_module_id" : ${content_test_module_id}, + "test_session_id" : ${content_test_session_id} + }, + "type" : "test_module_end", + "version" : 1 +} ] \ No newline at end of file diff --git a/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java b/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java index 6c7ef93544f..3b79f067b49 100644 --- a/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java +++ b/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java @@ -14,4 +14,10 @@ public interface CIConstants { String FAIL_FAST_TEST_ORDER = "FAILFAST"; String CIAPP_TEST_ORIGIN = "ciapp-test"; + + /** Tags that change the behaviour of CI Vis features when applied to a test case. */ + interface Tags { + String ITR_UNSKIPPABLE_TAG = "datadog_itr_unskippable"; + String SKIP_EFD_TAG = "datadog_skip_efd"; + } } diff --git a/internal-api/src/main/java/datadog/trace/api/civisibility/InstrumentationBridge.java b/internal-api/src/main/java/datadog/trace/api/civisibility/InstrumentationBridge.java index 18e8cc860cf..3fa85c6c39f 100644 --- a/internal-api/src/main/java/datadog/trace/api/civisibility/InstrumentationBridge.java +++ b/internal-api/src/main/java/datadog/trace/api/civisibility/InstrumentationBridge.java @@ -8,8 +8,6 @@ public abstract class InstrumentationBridge { - public static final String ITR_UNSKIPPABLE_TAG = "datadog_itr_unskippable"; - private static volatile TestEventsHandler.Factory TEST_EVENTS_HANDLER_FACTORY; private static volatile BuildEventsHandler.Factory BUILD_EVENTS_HANDLER_FACTORY; private static volatile CiVisibilityMetricCollector METRIC_COLLECTOR = diff --git a/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java b/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java index bc7c7fd8730..9295fe0b3a0 100644 --- a/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java +++ b/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java @@ -88,7 +88,8 @@ void onTestIgnore( @Nullable String reason); @Nonnull - TestExecutionPolicy executionPolicy(TestIdentifier test, TestSourceData source); + TestExecutionPolicy executionPolicy( + TestIdentifier test, TestSourceData source, Collection testTags); /** * Returns the priority of the test execution that can be used for ordering tests. The higher the From 8ba4d2297ab51698abe6d9a0ac274b8f991d689b Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko Date: Mon, 3 Mar 2025 19:26:32 +0100 Subject: [PATCH 2/6] Fix test --- .../trace/civisibility/test/ExecutionStrategyTest.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy index 952f816110f..62ebd432adf 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy @@ -1,6 +1,7 @@ package datadog.trace.civisibility.test import datadog.trace.api.Config +import datadog.trace.api.civisibility.CIConstants import datadog.trace.api.civisibility.config.TestFQN import datadog.trace.api.civisibility.config.TestIdentifier import datadog.trace.api.civisibility.config.TestMetadata @@ -75,7 +76,7 @@ class ExecutionStrategyTest extends Specification { def strategy = givenAnExecutionStrategy(executionSettings) expect: - strategy.executionPolicy(testID, TestSourceData.UNKNOWN).class == RunNTimes + strategy.executionPolicy(testID, TestSourceData.UNKNOWN, []).class == RunNTimes } def "test attempt to fix + efd"() { @@ -98,7 +99,7 @@ class ExecutionStrategyTest extends Specification { executionSettings.isKnown(testFQN) >> false def strategy = givenAnExecutionStrategy(executionSettings) - def policy = strategy.executionPolicy(testID, TestSourceData.UNKNOWN) + def policy = strategy.executionPolicy(testID, TestSourceData.UNKNOWN, []) // retry once to get the retry reason policy.retry(true, 0) @@ -118,6 +119,6 @@ class ExecutionStrategyTest extends Specification { executionSettings, resolver, linesResolver - ) + ) } } From a06d082bc638a0d728f805ebe4918e1a86837384 Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko Date: Tue, 4 Mar 2025 12:09:55 +0100 Subject: [PATCH 3/6] Remove unused imports --- .../trace/civisibility/test/ExecutionStrategyTest.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy index 62ebd432adf..aabcb79d2ff 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/test/ExecutionStrategyTest.groovy @@ -1,7 +1,6 @@ package datadog.trace.civisibility.test import datadog.trace.api.Config -import datadog.trace.api.civisibility.CIConstants import datadog.trace.api.civisibility.config.TestFQN import datadog.trace.api.civisibility.config.TestIdentifier import datadog.trace.api.civisibility.config.TestMetadata @@ -119,6 +118,6 @@ class ExecutionStrategyTest extends Specification { executionSettings, resolver, linesResolver - ) + ) } } From a52fe5cd980a2d163ee13fdfdeb4b928a2d125d0 Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko Date: Tue, 4 Mar 2025 15:53:01 +0100 Subject: [PATCH 4/6] Rename env var used for generating test fixtures --- .../trace/civisibility/CiVisibilityInstrumentationTest.groovy | 2 +- .../datadog/trace/civisibility/CiVisibilitySmokeTest.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy index a311f7568e8..c4055519759 100644 --- a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityInstrumentationTest.groovy @@ -354,7 +354,7 @@ abstract class CiVisibilityInstrumentationTest extends AgentTestRunner { "content.meta.['test.toolchain']" : "${instrumentedLibraryName()}:${instrumentedLibraryVersion()}" ] + replacements - if (System.getenv().get("DD_GENERATE_TEST_FIXTURES") != null) { + if (System.getenv().get("GENERATE_TEST_FIXTURES") != null) { return generateTestFixtures(testcaseName, events, coverages, additionalReplacements) } else { return CiVisibilityTestUtils.assertData(testcaseName, events, coverages, additionalReplacements) diff --git a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy index 77caec6dada..c4120d8649b 100644 --- a/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy @@ -8,7 +8,7 @@ abstract class CiVisibilitySmokeTest extends Specification { protected verifyEventsAndCoverages(String projectName, String toolchain, String toolchainVersion, List> events, List> coverages) { def additionalReplacements = ["content.meta.['test.toolchain']": "$toolchain:$toolchainVersion"] - if (System.getenv().get("DD_GENERATE_TEST_FIXTURES") != null) { + if (System.getenv().get("GENERATE_TEST_FIXTURES") != null) { def baseTemplatesPath = CiVisibilitySmokeTest.classLoader.getResource(projectName).toURI().schemeSpecificPart.replace('build/resources/test', 'src/test/resources') CiVisibilityTestUtils.generateTemplates(baseTemplatesPath, events, coverages, additionalReplacements) } else { From a617ea012fb5d248bd48033cf9bf08a571d1ba05 Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko Date: Tue, 4 Mar 2025 16:50:07 +0100 Subject: [PATCH 5/6] Rename skip EFD tag --- .../datadog/trace/civisibility/test/ExecutionStrategy.java | 2 +- .../cucumber/calculator/basic_arithmetic_skip_efd.feature | 2 +- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala | 2 +- .../src/test/java/org/example/TestSucceedSkipEfd.java | 4 ++-- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../cucumber/calculator/basic_arithmetic_skip_efd.feature | 2 +- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../test/groovy/org/example/TestSucceedSpockSkipEfd.groovy | 2 +- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../src/test/java/org/example/TestSucceedSkipEfd.java | 2 +- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../src/test/java/org/example/test_succeed_skip_efd.feature | 2 +- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../src/test/scala/org/example/TestSucceedSkipEfd.scala | 2 +- .../src/testFixtures/java/org/example/TestSucceedSkipEfd.java | 2 +- .../src/test/resources/test-efd-skip-new-test/events.ftl | 4 ++-- .../main/java/datadog/trace/api/civisibility/CIConstants.java | 2 +- 19 files changed, 28 insertions(+), 28 deletions(-) diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java index 097e000cd46..ed8177d0708 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java @@ -173,7 +173,7 @@ private boolean isEFDApplicable( && !isEFDLimitReached() && (isNew(test) || isModified(testSource)) // endsWith matching is needed for JUnit4-based frameworks, where tags are classes - && testTags.stream().noneMatch(t -> t.endsWith(CIConstants.Tags.SKIP_EFD_TAG)); + && testTags.stream().noneMatch(t -> t.endsWith(CIConstants.Tags.EFD_DISABLE_TAG)); } public boolean isEFDLimitReached() { diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature index 24922fb146e..00748c26be3 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature @@ -3,7 +3,7 @@ Feature: Basic Arithmetic Background: A Calculator Given a calculator I just turned on - @datadog_skip_efd + @datadog_efd_disable Scenario: Addition # Try to change one of the values below to provoke a failure When I add 4 and 5 diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl index 6045db2592b..ed7a1131e36 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl @@ -51,7 +51,7 @@ "test.name" : "Addition", "test.status" : "pass", "test.suite" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", - "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.traits" : "{\"category\":[\"datadog_efd_disable\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -142,4 +142,4 @@ }, "type" : "test_module_end", "version" : 1 -} ] \ No newline at end of file +} ] diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl index fe7e4d11f99..a5b789a541c 100644 --- a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/resources/test-efd-skip-new-test/events.ftl @@ -125,7 +125,7 @@ "test.source.file" : "dummy_source_path", "test.status" : "pass", "test.suite" : "org.example.TestSucceedMUnitSkipEfd", - "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.traits" : "{\"category\":[\"datadog_efd_disable\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -148,4 +148,4 @@ }, "type" : "test", "version" : 2 -} ] \ No newline at end of file +} ] diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala index 73d6742039b..dcc32c4af3c 100644 --- a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/test/scala/org/example/TestSucceedMUnitSkipEfd.scala @@ -3,7 +3,7 @@ package org.example import munit.FunSuite class TestSucceedMUnitSkipEfd extends FunSuite { - test("Calculator.add".tag(new munit.Tag("datadog_skip_efd"))) { + test("Calculator.add".tag(new munit.Tag("datadog_efd_disable"))) { assertEquals(1 + 2, 3) } } diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java index bdad7fe120d..9104e505a5d 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedSkipEfd.java @@ -7,11 +7,11 @@ public class TestSucceedSkipEfd { - @Category(datadog_skip_efd.class) + @Category(datadog_efd_disable.class) @Test public void test_succeed() { assertTrue(true); } - public interface datadog_skip_efd {} + public interface datadog_efd_disable {} } diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl index 69c1b4edf99..78dd18aa4fd 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-efd-skip-new-test/events.ftl @@ -126,7 +126,7 @@ "test.source.method" : "test_succeed()V", "test.status" : "pass", "test.suite" : "org.example.TestSucceedSkipEfd", - "test.traits" : "{\"category\":[\"org.example.TestSucceedSkipEfd$datadog_skip_efd\"]}", + "test.traits" : "{\"category\":[\"org.example.TestSucceedSkipEfd$datadog_efd_disable\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -151,4 +151,4 @@ }, "type" : "test", "version" : 2 -} ] \ No newline at end of file +} ] diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature index 4ba11ce0b3b..bf1da7c6e72 100644 --- a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature @@ -3,7 +3,7 @@ Feature: Basic Arithmetic Background: A Calculator Given a calculator I just turned on - @datadog_skip_efd + @datadog_efd_disable Scenario: Addition When I add 4 and 5 Then the result is 9 diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl index 41ceb7cf4e3..18134022ed9 100644 --- a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl @@ -51,7 +51,7 @@ "test.name" : "Addition", "test.status" : "pass", "test.suite" : "classpath:org/example/cucumber/calculator/basic_arithmetic_skip_efd.feature:Basic Arithmetic", - "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.traits" : "{\"category\":[\"datadog_efd_disable\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -142,4 +142,4 @@ }, "type" : "test_module_end", "version" : 1 -} ] \ No newline at end of file +} ] diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy index cc1033ca22b..d219649f281 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/groovy/org/example/TestSucceedSpockSkipEfd.groovy @@ -6,7 +6,7 @@ import spock.lang.Tag class TestSucceedSpockSkipEfd extends Specification { - @Tag(CIConstants.Tags.SKIP_EFD_TAG) + @Tag(CIConstants.Tags.EFD_DISABLE_TAG) def "test success"() { expect: 1 == 1 diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl index 04b8dd32737..8a8b707f436 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/test/resources/test-efd-skip-new-test/events.ftl @@ -58,7 +58,7 @@ "test.source.method" : "test success()V", "test.status" : "pass", "test.suite" : "org.example.TestSucceedSpockSkipEfd", - "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.traits" : "{\"category\":[\"datadog_efd_disable\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -151,4 +151,4 @@ }, "type" : "test_module_end", "version" : 1 -} ] \ No newline at end of file +} ] diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java index 4f7af78cb52..5d75f1bde1b 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/java/org/example/TestSucceedSkipEfd.java @@ -10,7 +10,7 @@ public class TestSucceedSkipEfd { @Test - @Tags({@Tag(CIConstants.Tags.SKIP_EFD_TAG)}) + @Tags({@Tag(CIConstants.Tags.EFD_DISABLE_TAG)}) public void test_succeed() { assertTrue(true); } diff --git a/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl index 869c10ea399..f797c702e61 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/junit-5.3/src/test/resources/test-efd-skip-new-test/events.ftl @@ -126,7 +126,7 @@ "test.source.method" : "test_succeed()V", "test.status" : "pass", "test.suite" : "org.example.TestSucceedSkipEfd", - "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.traits" : "{\"category\":[\"datadog_efd_disable\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -151,4 +151,4 @@ }, "type" : "test", "version" : 2 -} ] \ No newline at end of file +} ] diff --git a/dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature b/dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature index 128001b31cc..1b2325b1880 100644 --- a/dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature +++ b/dd-java-agent/instrumentation/karate/src/test/java/org/example/test_succeed_skip_efd.feature @@ -1,6 +1,6 @@ @foo Feature: test succeed - @datadog_skip_efd + @datadog_efd_disable Scenario: first scenario * print 'first' diff --git a/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl index ef4d07b8eaf..b7cba516951 100644 --- a/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/karate/src/test/resources/test-efd-skip-new-test/events.ftl @@ -76,7 +76,7 @@ "test.name" : "first scenario", "test.status" : "pass", "test.suite" : "[org/example/test_succeed_skip_efd] test succeed", - "test.traits" : "{\"category\":[\"datadog_skip_efd\",\"foo\"]}", + "test.traits" : "{\"category\":[\"datadog_efd_disable\",\"foo\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -167,4 +167,4 @@ }, "type" : "test_module_end", "version" : 1 -} ] \ No newline at end of file +} ] diff --git a/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala b/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala index a981379fe06..f7aad43be9f 100644 --- a/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala +++ b/dd-java-agent/instrumentation/scalatest/src/test/scala/org/example/TestSucceedSkipEfd.scala @@ -5,7 +5,7 @@ import datadog.trace.api.civisibility.{CIConstants, InstrumentationBridge} import org.scalatest.Tag import org.scalatest.flatspec.AnyFlatSpec -object SkipEfdTag extends Tag(Tags.SKIP_EFD_TAG) +object SkipEfdTag extends Tag(Tags.EFD_DISABLE_TAG) class TestSucceedSkipEfd extends AnyFlatSpec { "test" should "assert something" taggedAs SkipEfdTag in { diff --git a/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java b/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java index 555092bf482..83942dc7dcc 100644 --- a/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java +++ b/dd-java-agent/instrumentation/testng/src/testFixtures/java/org/example/TestSucceedSkipEfd.java @@ -7,7 +7,7 @@ public class TestSucceedSkipEfd { - @Test(groups = CIConstants.Tags.SKIP_EFD_TAG) + @Test(groups = CIConstants.Tags.EFD_DISABLE_TAG) public void test_succeed() { assertTrue(true); } diff --git a/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl b/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl index a95c7ac7bf4..d56800edc2f 100644 --- a/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl +++ b/dd-java-agent/instrumentation/testng/testng-7/src/test/resources/test-efd-skip-new-test/events.ftl @@ -58,7 +58,7 @@ "test.source.method" : "test_succeed()V", "test.status" : "pass", "test.suite" : "org.example.TestSucceedSkipEfd", - "test.traits" : "{\"category\":[\"datadog_skip_efd\"]}", + "test.traits" : "{\"category\":[\"datadog_efd_disable\"]}", "test.type" : "test", "test_session.name" : "session-name" }, @@ -151,4 +151,4 @@ }, "type" : "test_module_end", "version" : 1 -} ] \ No newline at end of file +} ] diff --git a/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java b/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java index 3b79f067b49..08d5b7a13cf 100644 --- a/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java +++ b/internal-api/src/main/java/datadog/trace/api/civisibility/CIConstants.java @@ -18,6 +18,6 @@ public interface CIConstants { /** Tags that change the behaviour of CI Vis features when applied to a test case. */ interface Tags { String ITR_UNSKIPPABLE_TAG = "datadog_itr_unskippable"; - String SKIP_EFD_TAG = "datadog_skip_efd"; + String EFD_DISABLE_TAG = "datadog_efd_disable"; } } From c398faa5a1c684372168e724b3c6a90b8ef79472 Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko Date: Tue, 4 Mar 2025 17:27:31 +0100 Subject: [PATCH 6/6] Increase allowed tracer size --- dd-java-agent/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dd-java-agent/build.gradle b/dd-java-agent/build.gradle index 459880a0ee7..6528a2e3c2e 100644 --- a/dd-java-agent/build.gradle +++ b/dd-java-agent/build.gradle @@ -289,7 +289,7 @@ tasks.register('checkAgentJarSize').configure { doLast { // Arbitrary limit to prevent unintentional increases to the agent jar size // Raise or lower as required - assert shadowJar.archiveFile.get().getAsFile().length() <= 30 * 1024 * 1024 + assert shadowJar.archiveFile.get().getAsFile().length() <= 31 * 1024 * 1024 } dependsOn "shadowJar"