Skip to content

Commit 6e5ee5b

Browse files
authored
Allow test clusters to specify additional jvm arguments (elastic#97584)
Somet special tests like die-with-dignity need to pass additional jvm arguments (exit on OOM). This commit adds a new jvmArg to the cluster spec for the new test clusters infra.
1 parent 52d1505 commit 6e5ee5b

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterSpecBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ private LocalNodeSpec build(LocalClusterSpec cluster) {
161161
getKeystorePassword(),
162162
getExtraConfigFiles(),
163163
getSystemProperties(),
164+
getJvmArgs(),
164165
getSecrets()
165166
);
166167
}

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public abstract class AbstractLocalSpecBuilder<T extends LocalSpecBuilder<?>> im
3838
private final Map<String, Resource> keystoreFiles = new HashMap<>();
3939
private final Map<String, Resource> extraConfigFiles = new HashMap<>();
4040
private final Map<String, String> systemProperties = new HashMap<>();
41+
private final List<String> jvmArgs = new ArrayList<>();
4142
private final Map<String, String> secrets = new HashMap<>();
4243
private DistributionType distributionType;
4344
private Version version;
@@ -218,6 +219,16 @@ public Map<String, String> getSystemProperties() {
218219
return inherit(() -> parent.getSystemProperties(), systemProperties);
219220
}
220221

222+
@Override
223+
public T jvmArg(String arg) {
224+
this.jvmArgs.add(arg);
225+
return cast(this);
226+
}
227+
228+
public List<String> getJvmArgs() {
229+
return inherit(() -> parent.getJvmArgs(), jvmArgs);
230+
}
231+
221232
@Override
222233
public T keystorePassword(String password) {
223234
this.keystorePassword = password;

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ private Map<String, String> getEnvironmentVariables() {
635635
.map(p -> p.replace("${ES_PATH_CONF}", configDir.toString()))
636636
.collect(Collectors.joining(" "));
637637
}
638+
String jvmArgs = String.join(" ", spec.getJvmArgs());
638639

639640
String debugArgs = "";
640641
if (Boolean.getBoolean(TESTS_CLUSTER_DEBUG_ENABLED_SYSPROP)) {
@@ -649,6 +650,7 @@ private Map<String, String> getEnvironmentVariables() {
649650
+ " "
650651
+ featureFlagProperties
651652
+ systemProperties
653+
+ jvmArgs
652654
+ debugArgs);
653655

654656
return environment;

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public static class LocalNodeSpec {
8383
private final String keystorePassword;
8484
private final Map<String, Resource> extraConfigFiles;
8585
private final Map<String, String> systemProperties;
86+
private final List<String> jvmArgs;
8687
private final Map<String, String> secrets;
8788
private Version version;
8889

@@ -104,6 +105,7 @@ public LocalNodeSpec(
104105
String keystorePassword,
105106
Map<String, Resource> extraConfigFiles,
106107
Map<String, String> systemProperties,
108+
List<String> jvmArgs,
107109
Map<String, String> secrets
108110
) {
109111
this.cluster = cluster;
@@ -123,6 +125,7 @@ public LocalNodeSpec(
123125
this.keystorePassword = keystorePassword;
124126
this.extraConfigFiles = extraConfigFiles;
125127
this.systemProperties = systemProperties;
128+
this.jvmArgs = jvmArgs;
126129
this.secrets = secrets;
127130
}
128131

@@ -182,6 +185,10 @@ public Map<String, String> getSystemProperties() {
182185
return systemProperties;
183186
}
184187

188+
public List<String> getJvmArgs() {
189+
return jvmArgs;
190+
}
191+
185192
public Map<String, String> getSecrets() {
186193
return secrets;
187194
}
@@ -299,6 +306,7 @@ private LocalNodeSpec getFilteredSpec(SettingsProvider filteredProvider, Setting
299306
n.keystorePassword,
300307
n.extraConfigFiles,
301308
n.systemProperties,
309+
n.jvmArgs,
302310
n.secrets
303311
)
304312
)

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,9 @@ interface LocalSpecBuilder<T extends LocalSpecBuilder<?>> {
126126
* Adds a system property to node JVM arguments.
127127
*/
128128
T systemProperty(String property, String value);
129+
130+
/**
131+
* Adds an additional command line argument to node JVM arguments.
132+
*/
133+
T jvmArg(String arg);
129134
}

0 commit comments

Comments
 (0)