kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject [kafka] branch trunk updated: MINOR: Update reverse lookup test to work when ipv6 not enabled (#5797)
Date Mon, 15 Oct 2018 07:59:33 GMT
This is an automated email from the ASF dual-hosted git repository.

rsivaram pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 148b5be  MINOR: Update reverse lookup test to work when ipv6 not enabled (#5797)
148b5be is described below

commit 148b5be74b7addde6d5a0c0f8f6011f3f27647ba
Author: Rajini Sivaram <rajinisivaram@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 <ismael@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)


Mime
View raw message