@@ -29,7 +29,7 @@ class TracerFlareSmokeTest extends AbstractSmokeTest {
2929 // cause rare test flakes.
3030 private static final int FLARE_TRIGGER_SECONDS = 25
3131 // Number of processes to run in parallel for testing
32- private static final int NUMBER_OF_PROCESSES = 2
32+ private static final int NUMBER_OF_PROCESSES = 3
3333
3434 protected int numberOfProcesses () {
3535 NUMBER_OF_PROCESSES
@@ -38,7 +38,8 @@ class TracerFlareSmokeTest extends AbstractSmokeTest {
3838 @Shared
3939 final flareDirs = [
4040 File . createTempDir(" flare-test-profiling-enabled-" , " " ),
41- File . createTempDir(" flare-test-profiling-disabled-" , " " )
41+ File . createTempDir(" flare-test-profiling-disabled-" , " " ),
42+ File . createTempDir(" flare-test-profiling-with-override-" , " " )
4243 ]
4344
4445 def cleanupSpec () {
@@ -56,16 +57,28 @@ class TracerFlareSmokeTest extends AbstractSmokeTest {
5657
5758 def command = [javaPath()]
5859
59- if (processIndex == 0 ) {
60+ switch (processIndex) {
61+ case 0 :
6062 // Process 0: Profiling enabled (default)
61- command. addAll(defaultJavaProperties)
62- } else {
63+ command. addAll(defaultJavaProperties)
64+ break
65+ case 1 :
6366 // Process 1: Profiling disabled
64- def filteredProperties = defaultJavaProperties. findAll { prop ->
65- ! prop. startsWith(" -Ddd.profiling." )
66- }
67- command. addAll(filteredProperties)
68- command. add(" -Ddd.profiling.enabled=false" )
67+ def filteredProperties = defaultJavaProperties. findAll { prop ->
68+ ! prop. startsWith(" -Ddd.profiling." )
69+ }
70+ command. addAll(filteredProperties)
71+ command. add(" -Ddd.profiling.enabled=false" )
72+ break
73+ case 2 :
74+ // Process 2: Profiling enabled with template override
75+ command. addAll(defaultJavaProperties)
76+ // Create a temp file with the override content
77+ def tempOverrideFile = File . createTempFile(" test-override-" , " .jfp" )
78+ tempOverrideFile. deleteOnExit()
79+ tempOverrideFile. text = " datadog.ExceptionSample#enabled=false" // Arbitrary event choice
80+ command. add(" -Ddd.profiling.jfr-template-override-file=" + tempOverrideFile. absolutePath)
81+ break
6982 }
7083
7184 // Configure flare generation
@@ -116,14 +129,15 @@ class TracerFlareSmokeTest extends AbstractSmokeTest {
116129 // Alternative log format
117130 " flare_errors.txt" ,
118131 // Only if there were errors
119- " pending_traces.txt" // Only if there were traces pending transmission
132+ " pending_traces.txt" ,
133+ // Only if there were traces pending transmission
134+ " profiling_template_override.jfp"
135+ // Only if template override is configured
120136 ] as Set<String >
121137
122138 // Profiling-related files
123- private static final PROFILING_FILES = [
124- " profiler_config.txt" ,
139+ private static final PROFILING_FILES = [" profiler_config.txt" ,
125140 // Only if profiling is enabled
126- " profiling_template_override.jfp" // Only if template override is configured
127141 ] as Set<String >
128142
129143 // Flare file naming pattern constants
@@ -150,8 +164,9 @@ class TracerFlareSmokeTest extends AbstractSmokeTest {
150164 assert file in zipContents : " Missing required core file : ${file}"
151165 }
152166
153- // Verify profiling files are present (profiling is enabled in defaultJavaProperties)
154- assert " profiler_config. txt" in zipContents : " Missing profiler_config. txt when profiling is enabled"
167+ PROFILING_FILES.each { file ->
168+ assert (file in zipContents) : " Didn ' t find profiling file ' ${file}' when profiling is enabled"
169+ }
155170
156171 // Check for unexpected files and fail if found
157172 validateNoUnexpectedFiles(zipContents, CORE_FILES + OPTIONAL_FILES + PROFILING_FILES)
@@ -179,6 +194,29 @@ class TracerFlareSmokeTest extends AbstractSmokeTest {
179194 validateNoUnexpectedFiles(zipContents, CORE_FILES + OPTIONAL_FILES)
180195 }
181196
197+ def "tracer generates flare with profiling template override"() {
198+ when:
199+ // Wait for flare file to be created for process 2 (profiling with template override)
200+ def flareFile = waitForFlareFile(flareDirs[2])
201+ def zipContents = extractZipContents(flareFile)
202+
203+ then:
204+ // Verify core files are present
205+ CORE_FILES.each { file ->
206+ assert file in zipContents : "Missing required core file: ${file}"
207+ }
208+
209+ PROFILING_FILES.each { file ->
210+ assert (file in zipContents) : "Didn' t find profiling file ' ${file}' when profiling is enabled"
211+ }
212+
213+ // Verify no template override file when not configured (the typical scenario)
214+ assert " profiling_template_override. jfp" in zipContents : " Didn ' t find profiling_template_override.jfp when override was configured"
215+
216+ // Check for unexpected files and fail if found
217+ validateNoUnexpectedFiles(zipContents, CORE_FILES + OPTIONAL_FILES + PROFILING_FILES)
218+ }
219+
182220 private static void validateNoUnexpectedFiles(Set<String> zipContents, Set<String> expectedFiles) {
183221 def unexpectedFiles = zipContents - expectedFiles
184222 assert !unexpectedFiles : "Found unexpected files in flare: ${unexpectedFiles}"
0 commit comments