Skip to content

Commit 6fef1bf

Browse files
committed
Add test case for log4j agent
1 parent 3c30e55 commit 6fef1bf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

dd-smoke-tests/lib-injection/src/test/groovy/datadog/smoketest/MultipleAgentGuardrailsTest.groovy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
package datadog.smoketest
22

3+
import java.nio.file.Files
4+
import java.nio.file.StandardCopyOption
5+
6+
37
abstract class MultipleAgentGuardrailsTest extends AbstractSmokeTest {
48
static final String LIB_INJECTION_ENABLED_FLAG = 'DD_INJECTION_ENABLED'
59
static final String LIB_INJECTION_FORCE_FLAG = 'DD_INJECT_FORCE'
610

711
@Override
812
ProcessBuilder createProcessBuilder() {
13+
String extraAgentFilename() {
14+
return null
15+
}
16+
917
def jarPath = System.getProperty("datadog.smoketest.shadowJar.path")
18+
if (extraAgentFilename() != null) {
19+
renamedJar = Paths.get(jarPath).getParent().resolve(extraAgentFilename())
20+
Files.copy(Paths.get(jarPath), renamedJar, StandardCopyOption.REPLACE_EXISTING)
21+
jarPath = renamedJar.toString()
22+
}
1023
def command = []
1124
command+= javaPath()
1225
command.addAll(defaultJavaProperties)
@@ -78,3 +91,26 @@ class LibInjectionForcedTest extends MultipleAgentGuardrailsTest {
7891
return true
7992
}
8093
}
94+
95+
// Test that injection still works if we have to agent if one of them is the aws emr log4j patcher
96+
class LibsInjectionWorksEmr extends MultipleAgentGuardrailsTest {
97+
@Override
98+
boolean isLibInjectionEnabled() {
99+
return true
100+
}
101+
102+
@Override
103+
boolean isLibInjectionForced() {
104+
return false
105+
}
106+
107+
@Override
108+
String extraAgentFilenam() {
109+
return "Log4jHotPatchFat.jar"
110+
}
111+
112+
@Override
113+
boolean isExpectingTrace() {
114+
return true
115+
}
116+
}

0 commit comments

Comments
 (0)