You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2019/07/17 23:27:52 UTC

[incubator-pinot] 01/01: Fix ServerInstanceTest

This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch fix_server_instance_test
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git

commit 403db0e6a27fc947a86d6ca2696f03b19e0ebe57
Author: Jackie (Xiaotian) Jiang <xa...@linkedin.com>
AuthorDate: Wed Jul 17 16:26:43 2019 -0700

    Fix ServerInstanceTest
    
    There is no guarantee that 127.0.0.1 gets resolved to localhost
---
 .../apache/pinot/transport/common/ServerInstanceTest.java   | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/pinot-transport/src/test/java/org/apache/pinot/transport/common/ServerInstanceTest.java b/pinot-transport/src/test/java/org/apache/pinot/transport/common/ServerInstanceTest.java
index 5c89d25..3853c7a 100644
--- a/pinot-transport/src/test/java/org/apache/pinot/transport/common/ServerInstanceTest.java
+++ b/pinot-transport/src/test/java/org/apache/pinot/transport/common/ServerInstanceTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.pinot.transport.common;
 
+import java.net.InetAddress;
 import org.apache.pinot.common.response.ServerInstance;
 import org.testng.annotations.Test;
 
@@ -28,21 +29,23 @@ import static org.testng.Assert.assertNotEquals;
 public class ServerInstanceTest {
 
   @Test
-  public void testServerInstance() {
+  public void testServerInstance()
+      throws Exception {
     // Same local host name and port
     assertEquals(new ServerInstance("localhost", 8080), new ServerInstance("localhost", 8080));
 
-    // Same IP address host and port
+    // Same local host IP address and port
     assertEquals(new ServerInstance("127.0.0.1", 8080), new ServerInstance("127.0.0.1", 8080));
 
     // Same other host name and port
     assertEquals(new ServerInstance("test-host", 8080), new ServerInstance("test-host", 8080));
 
-    // Same other IP address host and port
+    // Same other host IP address and port
     assertEquals(new ServerInstance("192.168.0.1", 8080), new ServerInstance("192.168.0.1", 8080));
 
-    // Same local host and port, one with host name and one with IP address
-    assertEquals(new ServerInstance("localhost", 8080), new ServerInstance("127.0.0.1", 8080));
+    // Same local host and port, one with IP address and one with host name
+    assertEquals(new ServerInstance("127.0.0.1", 8080),
+        new ServerInstance(InetAddress.getByName("127.0.0.1").getHostName(), 8080));
 
     // Same host but different port
     assertNotEquals(new ServerInstance("localhost", 8081), new ServerInstance("localhost", 8082));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org