Skip to content

Commit

Permalink
Move common system properties for test clusters to default provider (e…
Browse files Browse the repository at this point in the history
…lastic#117928)

This commit moves common system properties needed for test clusters to a
SystemPropertyProvider which can be reused and extended by serverless.
  • Loading branch information
rjernst committed Dec 3, 2024
1 parent 2205461 commit 8ce642d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public T systemProperty(String key, Supplier<String> supplier) {
return cast(this);
}

public T systemProperty(SystemPropertyProvider systemPropertyProvider) {
public T systemProperties(SystemPropertyProvider systemPropertyProvider) {
this.systemPropertyProviders.add(systemPropertyProvider);
return cast(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ public final class DefaultLocalClusterSpecBuilder extends AbstractLocalClusterSp

public DefaultLocalClusterSpecBuilder() {
super();
this.apply(
c -> c.systemProperty("ingest.geoip.downloader.enabled.default", "false").systemProperty("tests.testfeatures.enabled", "true")
);
this.apply(new FipsEnabledClusterConfigProvider());
this.systemProperties(new DefaultSystemPropertyProvider());
this.settings(new DefaultSettingsProvider());
this.environment(new DefaultEnvironmentProvider());
this.rolesFile(Resource.fromClasspath("default_test_roles.yml"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.test.cluster.local;

import org.elasticsearch.test.cluster.SystemPropertyProvider;

import java.util.Map;

import static java.util.Map.entry;

public class DefaultSystemPropertyProvider implements SystemPropertyProvider {
@Override
public Map<String, String> get(LocalClusterSpec.LocalNodeSpec nodeSpec) {
return Map.ofEntries(entry("ingest.geoip.downloader.enabled.default", "false"), entry("tests.testfeatures.enabled", "true"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ interface LocalSpecBuilder<T extends LocalSpecBuilder<?>> {
/**
* Register a {@link SystemPropertyProvider}.
*/
T systemProperty(SystemPropertyProvider systemPropertyProvider);
T systemProperties(SystemPropertyProvider systemPropertyProvider);

/**
* Adds an additional command line argument to node JVM arguments.
Expand Down

0 comments on commit 8ce642d

Please sign in to comment.