diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java index 900a0f99ed9..b5a04969687 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java @@ -105,6 +105,8 @@ public class ElasticsearchNode implements TestClusterConfiguration { "is a pre-release version of Elasticsearch", "max virtual memory areas vm.max_map_count" ); + private static final String HOSTNAME_OVERRIDE = "LinuxDarwinHostname"; + private static final String COMPUTERNAME_OVERRIDE = "WindowsComputername"; private final String path; private final String name; @@ -604,6 +606,10 @@ public class ElasticsearchNode implements TestClusterConfiguration { // Windows requires this as it defaults to `c:\windows` despite ES_TMPDIR defaultEnv.put("TMP", tmpDir.toString()); + // Override the system hostname variables for testing + defaultEnv.put("HOSTNAME", HOSTNAME_OVERRIDE); + defaultEnv.put("COMPUTERNAME", COMPUTERNAME_OVERRIDE); + Set commonKeys = new HashSet<>(environment.keySet()); commonKeys.retainAll(defaultEnv.keySet()); if (commonKeys.isEmpty() == false) { diff --git a/qa/unconfigured-node-name/build.gradle b/qa/unconfigured-node-name/build.gradle index 57213f689a5..bcdc9ac958e 100644 --- a/qa/unconfigured-node-name/build.gradle +++ b/qa/unconfigured-node-name/build.gradle @@ -30,6 +30,4 @@ testClusters.integTest { integTest.runner { nonInputProperties.systemProperty 'tests.logfile', "${ -> testClusters.integTest.singleNode().getServerLog() }" - // https://github.com/elastic/elasticsearch/issues/44656 - onlyIf { OS.WINDOWS.equals(OS.current()) == false } } diff --git a/qa/unconfigured-node-name/src/test/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java b/qa/unconfigured-node-name/src/test/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java index 50cc20b0e57..e7f5b892647 100644 --- a/qa/unconfigured-node-name/src/test/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java +++ b/qa/unconfigured-node-name/src/test/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java @@ -30,12 +30,22 @@ import java.nio.file.Path; import java.security.AccessController; import java.security.PrivilegedAction; -import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.equalTo; public class JsonLogsFormatAndParseIT extends JsonLogsIntegTestCase { + private static final String OS_NAME = System.getProperty("os.name"); + private static final boolean WINDOWS = OS_NAME.startsWith("Windows"); + + // These match the values defined in org.elasticsearch.gradle.testclusters.ElasticsearchNode + private static final String COMPUTERNAME = "WindowsComputername"; + private static final String HOSTNAME = "LinuxDarwinHostname"; + @Override protected Matcher nodeNameMatcher() { - return not(""); + if (WINDOWS) { + return equalTo(COMPUTERNAME); + } + return equalTo(HOSTNAME); } @Override