Skip to content

Commit 0ba5cb2

Browse files
Fix the smoke test to report the same spans in CI and locally
1 parent 687cdff commit 0ba5cb2

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

dd-java-agent/agent-ci-visibility/src/testFixtures/groovy/datadog/trace/civisibility/CiVisibilityTestUtils.groovy

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ abstract class CiVisibilityTestUtils {
103103
try {
104104
JSONAssert.assertEquals(expectedEvents, actualEvents, comparisonMode)
105105
} catch (AssertionError e) {
106-
println "Expected events: $expectedEvents" // TODO remove
107-
println "Actual events: $actualEvents" // TODO remove
106+
if (ciRun) {
107+
// When running in CI the assertion error message does not contain the actual diff,
108+
// so we print the events to the console to help debug the issue
109+
println "Expected events: $expectedEvents"
110+
println "Actual events: $actualEvents"
111+
}
108112
throw new org.opentest4j.AssertionFailedError("Events mismatch", expectedEvents, actualEvents, e)
109113
}
110114

@@ -113,6 +117,12 @@ abstract class CiVisibilityTestUtils {
113117
try {
114118
JSONAssert.assertEquals(expectedCoverages, actualCoverages, comparisonMode)
115119
} catch (AssertionError e) {
120+
if (ciRun) {
121+
// When running in CI the assertion error message does not contain the actual diff,
122+
// so we print the events to the console to help debug the issue
123+
println "Expected coverages: $expectedCoverages"
124+
println "Actual coverages: $actualCoverages"
125+
}
116126
throw new org.opentest4j.AssertionFailedError("Coverages mismatch", expectedCoverages, actualCoverages, e)
117127
}
118128

dd-smoke-tests/gradle/src/test/groovy/datadog/smoketest/GradleDaemonSmokeTest.groovy

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
package datadog.smoketest
22

3-
43
import datadog.trace.api.Config
54
import datadog.trace.api.Platform
65
import datadog.trace.api.config.CiVisibilityConfig
76
import datadog.trace.api.config.GeneralConfig
7+
import datadog.trace.api.config.TraceInstrumentationConfig
88
import datadog.trace.util.Strings
99
import org.gradle.testkit.runner.BuildResult
1010
import org.gradle.testkit.runner.GradleRunner
1111
import org.gradle.testkit.runner.TaskOutcome
1212
import org.gradle.util.DistributionLocator
1313
import org.gradle.util.GradleVersion
14-
import org.gradle.wrapper.Download
15-
import org.gradle.wrapper.GradleUserHomeLookup
16-
import org.gradle.wrapper.Install
17-
import org.gradle.wrapper.PathAssembler
18-
import org.gradle.wrapper.WrapperConfiguration
14+
import org.gradle.wrapper.*
1915
import spock.lang.IgnoreIf
2016
import spock.lang.Shared
2117
import spock.lang.TempDir
@@ -133,6 +129,16 @@ class GradleDaemonSmokeTest extends AbstractGradleTest {
133129
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_AGENTLESS_ENABLED)}=true," +
134130
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_GIT_UPLOAD_ENABLED)}=false," +
135131
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_CIPROVIDER_INTEGRATION_ENABLED)}=false," +
132+
/*
133+
* Some of the smoke tests (in particular the one with the Gradle plugin), are using Gradle Test Kit for their tests.
134+
* Gradle Test Kit needs to do a "chmod" when starting a Gradle Daemon.
135+
* This "chmod" operation is traced by datadog.trace.instrumentation.java.lang.ProcessImplInstrumentation and is reported as a span.
136+
* The problem is that the "chmod" only happens when running in CI (could be due to differences in OS or FS permissions),
137+
* so when running the tests locally, the "chmod" span is not there.
138+
* This causes the tests to fail because the number of reported traces is different.
139+
* To avoid this discrepancy between local and CI runs, we disable tracing instrumentations.
140+
*/
141+
"${Strings.propertyNameToSystemPropertyName(TraceInstrumentationConfig.TRACE_ENABLED)}=false," +
136142
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_JACOCO_PLUGIN_VERSION)}=$JACOCO_PLUGIN_VERSION," +
137143
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_AGENTLESS_URL)}=${mockBackend.intakeUrl}"
138144

0 commit comments

Comments
 (0)