1
1
package datadog.smoketest
2
2
3
+ import java.nio.file.Files
4
+ import java.nio.file.StandardCopyOption
5
+ import java.nio.file.Paths
6
+
7
+
3
8
abstract class MultipleAgentGuardrailsTest extends AbstractSmokeTest {
4
9
static final String LIB_INJECTION_ENABLED_FLAG = ' DD_INJECTION_ENABLED'
5
10
static final String LIB_INJECTION_FORCE_FLAG = ' DD_INJECT_FORCE'
6
11
7
12
@Override
8
13
ProcessBuilder createProcessBuilder () {
14
+
9
15
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
+ }
10
21
def command = []
11
22
command+ = javaPath()
12
23
command. addAll(defaultJavaProperties)
@@ -28,6 +39,11 @@ abstract class MultipleAgentGuardrailsTest extends AbstractSmokeTest {
28
39
abstract boolean isLibInjectionEnabled ()
29
40
abstract boolean isLibInjectionForced ()
30
41
42
+ String extraAgentFilename () {
43
+ return null
44
+ }
45
+
46
+
31
47
boolean isExpectingTrace () {
32
48
return ! isLibInjectionEnabled() || isLibInjectionForced()
33
49
}
@@ -78,3 +94,26 @@ class LibInjectionForcedTest extends MultipleAgentGuardrailsTest {
78
94
return true
79
95
}
80
96
}
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