mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-10 06:55:32 +00:00
add more tests to network service
Follow up for #15340 We test that bind with wilcard IP + fixed IP it raises an exception We test binding multiple IPs (cherry picked from commit 2cc5bb7)
This commit is contained in:
parent
b6fbd18e09
commit
f675801b26
@ -24,6 +24,8 @@ import org.elasticsearch.test.ESTestCase;
|
|||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for network service... try to keep them safe depending upon configuration
|
* Tests for network service... try to keep them safe depending upon configuration
|
||||||
* please don't actually bind to anything, just test the addresses.
|
* please don't actually bind to anything, just test the addresses.
|
||||||
@ -42,7 +44,6 @@ public class NetworkServiceTests extends ESTestCase {
|
|||||||
assertTrue(e.getMessage().contains("invalid: multicast"));
|
assertTrue(e.getMessage().contains("invalid: multicast"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ensure exception if we bind to multicast ipv6 address
|
* ensure exception if we bind to multicast ipv6 address
|
||||||
*/
|
*/
|
||||||
@ -115,4 +116,26 @@ public class NetworkServiceTests extends ESTestCase {
|
|||||||
InetAddress address = service.resolvePublishHostAddresses(new String[] { "::" });
|
InetAddress address = service.resolvePublishHostAddresses(new String[] { "::" });
|
||||||
assertFalse(address.isAnyLocalAddress());
|
assertFalse(address.isAnyLocalAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ensure we can bind to multiple addresses
|
||||||
|
*/
|
||||||
|
public void testBindMultipleAddresses() throws Exception {
|
||||||
|
NetworkService service = new NetworkService(Settings.EMPTY);
|
||||||
|
InetAddress[] addresses = service.resolveBindHostAddresses(new String[]{"127.0.0.1", "127.0.0.2"});
|
||||||
|
assertThat(addresses.length, is(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ensure we can't bind to multiple addresses when using wildcard
|
||||||
|
*/
|
||||||
|
public void testBindMultipleAddressesWithWildcard() throws Exception {
|
||||||
|
NetworkService service = new NetworkService(Settings.EMPTY);
|
||||||
|
try {
|
||||||
|
service.resolveBindHostAddresses(new String[]{"0.0.0.0", "127.0.0.1"});
|
||||||
|
fail("should have hit exception");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
assertTrue(e.getMessage().contains("is wildcard, but multiple addresses specified"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user