You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by rs...@apache.org on 2018/10/15 08:12:26 UTC
[kafka] branch 2.1 updated: MINOR: Update reverse lookup test to
work when ipv6 not enabled (#5797)
This is an automated email from the ASF dual-hosted git repository.
rsivaram pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/2.1 by this push:
new 3d532bd MINOR: Update reverse lookup test to work when ipv6 not enabled (#5797)
3d532bd is described below
commit 3d532bdba2640179f6b0b1dbe843d628dc80025b
Author: Rajini Sivaram <ra...@googlemail.com>
AuthorDate: Mon Oct 15 08:59:20 2018 +0100
MINOR: Update reverse lookup test to work when ipv6 not enabled (#5797)
Update `ClientUtilsTest.testParseAndValidateAddressesWithReverseLookup` test to work in environments where ipv6 is not enabled and `InetAddress.getAllByName` doesn't return ipv6 addresses.
Reviewers: Ismael Juma <is...@juma.me.uk>
---
.../java/org/apache/kafka/clients/ClientUtilsTest.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java b/clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java
index 35f52a9..227afea 100644
--- a/clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java
+++ b/clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java
@@ -27,6 +27,7 @@ import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
public class ClientUtilsTest {
@@ -50,11 +51,16 @@ public class ClientUtilsTest {
checkWithoutLookup("localhost:8080");
checkWithoutLookup("[::1]:8000");
checkWithoutLookup("[2001:db8:85a3:8d3:1319:8a2e:370:7348]:1234", "localhost:10000");
+
+ // With lookup of example.com, either one or two addresses are expected depending on
+ // whether ipv4 and ipv6 are enabled
List<InetSocketAddress> validatedAddresses = checkWithLookup(Arrays.asList("example.com:10000"));
- assertEquals(2, validatedAddresses.size());
- InetSocketAddress address = validatedAddresses.get(0);
- assertEquals("93.184.216.34", address.getHostName());
- assertEquals(10000, address.getPort());
+ assertTrue("Unexpected addresses " + validatedAddresses, validatedAddresses.size() >= 1);
+ List<String> validatedHostNames = validatedAddresses.stream().map(InetSocketAddress::getHostName)
+ .collect(Collectors.toList());
+ List<String> expectedHostNames = Arrays.asList("93.184.216.34", "2606:2800:220:1:248:1893:25c8:1946");
+ assertTrue("Unexpected addresses " + validatedHostNames, expectedHostNames.containsAll(validatedHostNames));
+ validatedAddresses.forEach(address -> assertEquals(10000, address.getPort()));
}
@Test(expected = IllegalArgumentException.class)