Skip to content

Commit b140395

Browse files
committed
Fall back to HOSTNAME(1) in stream Java test suite
In case the Java way fails (only on new CI).
1 parent 9725595 commit b140395

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

deps/rabbitmq_stream/test/rabbit_stream_SUITE_data/src/test/java/com/rabbitmq/stream/FailureTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ void tearDown() {
6060

6161
@Test
6262
void leaderFailureWhenPublisherConnectedToReplica() throws Exception {
63-
System.out.println("stream " + stream);
6463
Set<String> messages = new HashSet<>();
6564
Client client = cf.get(new Client.ClientParameters().port(TestUtils.streamPortNode1()));
6665
Map<String, Client.StreamMetadata> metadata = client.metadata(stream);

deps/rabbitmq_stream/test/rabbit_stream_SUITE_data/src/test/java/com/rabbitmq/stream/Host.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,23 @@ public static Process rabbitmqctl(String command, String nodename) throws IOExce
9494
}
9595

9696
public static String node1name() {
97-
try {
98-
return System.getProperty(
99-
"node1.name", "rabbit-1@" + InetAddress.getLocalHost().getHostName());
100-
} catch (UnknownHostException e) {
101-
throw new RuntimeException(e);
102-
}
97+
return System.getProperty("node1.name", "rabbit-1@" + hostname());
10398
}
10499

105100
public static String node2name() {
101+
return System.getProperty("node2.name", "rabbit-2@" + hostname());
102+
}
103+
104+
public static String hostname() {
106105
try {
107-
return System.getProperty(
108-
"node2.name", "rabbit-2@" + InetAddress.getLocalHost().getHostName());
106+
return InetAddress.getLocalHost().getHostName();
109107
} catch (UnknownHostException e) {
110-
throw new RuntimeException(e);
108+
try {
109+
Process process = executeCommand("hostname");
110+
return capture(process.getInputStream()).trim();
111+
} catch (Exception ex) {
112+
throw new RuntimeException(ex);
113+
}
111114
}
112115
}
113116

0 commit comments

Comments
 (0)