Fall back to HOSTNAME(1) in stream Java test suite

In case the Java way fails (only on new CI).
This commit is contained in:
Arnaud Cogoluègnes 2021-09-15 10:36:27 +02:00
parent 9725595c00
commit b140395864
No known key found for this signature in database
GPG Key ID: D5C8C4DFAD43AFA8
2 changed files with 12 additions and 10 deletions

View File

@ -60,7 +60,6 @@ public class FailureTest {
@Test
void leaderFailureWhenPublisherConnectedToReplica() throws Exception {
System.out.println("stream " + stream);
Set<String> messages = new HashSet<>();
Client client = cf.get(new Client.ClientParameters().port(TestUtils.streamPortNode1()));
Map<String, Client.StreamMetadata> metadata = client.metadata(stream);

View File

@ -94,20 +94,23 @@ public class Host {
}
public static String node1name() {
try {
return System.getProperty(
"node1.name", "rabbit-1@" + InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
return System.getProperty("node1.name", "rabbit-1@" + hostname());
}
public static String node2name() {
return System.getProperty("node2.name", "rabbit-2@" + hostname());
}
public static String hostname() {
try {
return System.getProperty(
"node2.name", "rabbit-2@" + InetAddress.getLocalHost().getHostName());
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
throw new RuntimeException(e);
try {
Process process = executeCommand("hostname");
return capture(process.getInputStream()).trim();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}