11package datadog.smoketest
22
3+ import java.nio.file.Files
4+ import java.nio.file.StandardCopyOption
5+ import java.nio.file.Paths
6+
7+
38abstract class MultipleAgentGuardrailsTest extends AbstractSmokeTest {
49 static final String LIB_INJECTION_ENABLED_FLAG = ' DD_INJECTION_ENABLED'
510 static final String LIB_INJECTION_FORCE_FLAG = ' DD_INJECT_FORCE'
611
712 @Override
813 ProcessBuilder createProcessBuilder () {
14+
915 def jarPath = System . getProperty(" datadog.smoketest.shadowJar.path" )
16+ if (extraAgentFilename() != null ) {
17+ def renamedJar = Paths . get(jarPath). getParent(). resolve(extraAgentFilename())
18+ Files . copy(Paths . get(jarPath), renamedJar, StandardCopyOption . REPLACE_EXISTING )
19+ jarPath = renamedJar. toString()
20+ }
1021 def command = []
1122 command+ = javaPath()
1223 command. addAll(defaultJavaProperties)
@@ -28,6 +39,11 @@ abstract class MultipleAgentGuardrailsTest extends AbstractSmokeTest {
2839 abstract boolean isLibInjectionEnabled ()
2940 abstract boolean isLibInjectionForced ()
3041
42+ String extraAgentFilename () {
43+ return null
44+ }
45+
46+
3147 boolean isExpectingTrace () {
3248 return ! isLibInjectionEnabled() || isLibInjectionForced()
3349 }
@@ -78,3 +94,26 @@ class LibInjectionForcedTest extends MultipleAgentGuardrailsTest {
7894 return true
7995 }
8096}
97+
98+ // Test that injection still works if we have to agent if one of them is the aws emr log4j patcher
99+ class LibsInjectionWorksEmr extends MultipleAgentGuardrailsTest {
100+ @Override
101+ boolean isLibInjectionEnabled () {
102+ return true
103+ }
104+
105+ @Override
106+ boolean isLibInjectionForced () {
107+ return false
108+ }
109+
110+ @Override
111+ String extraAgentFilename () {
112+ return " Log4jHotPatchFat.jar"
113+ }
114+
115+ @Override
116+ boolean isExpectingTrace () {
117+ return true
118+ }
119+ }
0 commit comments