Skip to content

Commit 9240710

Browse files
committed
chore: Patch smoke test forked processes to use a custom preference file
1 parent ad93e09 commit 9240710

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

dd-java-agent/agent-ci-visibility/civisibility-test-fixtures/src/main/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ abstract class CiVisibilitySmokeTest extends Specification {
100100
}
101101

102102
/**
103-
* Trick to prevent jul Prefs file lock issue on forked processes.
104-
*
105-
* Reason: multiple observations of failed job with
103+
* Trick to prevent jul Prefs file lock issue on forked processes, in particular in CI which
104+
* runs on Linux and have competing processes trying to write to it, including the Gradle daemon.
106105
*
107106
* <pre><code>
108107
* Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.

dd-smoke-tests/debugger-integration-tests/src/test/java/datadog/smoketest/ProcessBuilderHelper.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ public static ProcessBuilder createProcessBuilder(
2828
String mainClassName,
2929
String... params) {
3030

31+
// Trick to prevent jul preferences file lock issue on forked processes, in particular in CI
32+
// which runs on Linux and have competing processes trying to write to it, including the
33+
// Gradle daemon.
34+
//
35+
// Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
36+
String prefsDir =
37+
System.getProperty("java.io.tmpdir")
38+
+ File.separator
39+
+ "userPrefs"
40+
+ File.separator
41+
+ mainClassName
42+
+ "_"
43+
+ System.nanoTime();
44+
3145
List<String> baseCommand =
3246
Arrays.asList(
3347
javaPath(),
@@ -37,7 +51,8 @@ public static ProcessBuilder createProcessBuilder(
3751
"-javaagent:" + agentShadowJar(),
3852
"-XX:ErrorFile=/tmp/hs_err_pid%p.log",
3953
"-Ddd.env=smoketest",
40-
"-Ddd.version=99");
54+
"-Ddd.version=99",
55+
"-Djava.util.prefs.userRoot=" + prefsDir);
4156

4257
List<String> command = new ArrayList<>();
4358
command.addAll(baseCommand);

dd-smoke-tests/src/main/groovy/datadog/smoketest/AbstractSmokeTest.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ abstract class AbstractSmokeTest extends ProcessManager {
188188
def javaProperties() {
189189
def tmpDir = "/tmp"
190190

191+
// Trick to prevent jul preferences file lock issue on forked processes, in particular in CI which
192+
// runs on Linux and have competing processes trying to write to it, including the Gradle daemon.
193+
//
194+
// Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
195+
def prefsDir = "${tmpDir}/userPrefs/${this.getClass().simpleName}_${System.nanoTime()}"
196+
191197
def ret = [
192198
"${getMaxMemoryArgumentForFork()}",
193199
"${getMinMemoryArgumentForFork()}",
@@ -204,7 +210,8 @@ abstract class AbstractSmokeTest extends ProcessManager {
204210
"-Ddd.profiling.ddprof.alloc.enabled=${isDdprofSafe()}",
205211
"-Ddatadog.slf4j.simpleLogger.defaultLogLevel=${logLevel()}",
206212
"-Dorg.slf4j.simpleLogger.defaultLogLevel=${logLevel()}",
207-
"-Ddd.site="
213+
"-Ddd.site=",
214+
"-Djava.util.prefs.userRoot=${prefsDir}"
208215
]
209216
if (inferServiceName()) {
210217
ret += "-Ddd.service.name=${SERVICE_NAME}"

0 commit comments

Comments
 (0)