You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2019/07/16 20:35:54 UTC

[GitHub] [incubator-pinot] jackjlli commented on a change in pull request #4438: Clean up the ServerInstance class and remove the un-necessary ip address stored

jackjlli commented on a change in pull request #4438: Clean up the ServerInstance class and remove the un-necessary ip address stored
URL: https://github.com/apache/incubator-pinot/pull/4438#discussion_r304106872
 
 

 ##########
 File path: pinot-transport/src/test/java/org/apache/pinot/transport/common/ServerInstanceTest.java
 ##########
 @@ -18,61 +18,27 @@
  */
 package org.apache.pinot.transport.common;
 
-import java.net.InetAddress;
 import org.apache.pinot.common.response.ServerInstance;
-import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
+
 
 public class ServerInstanceTest {
 
   @Test
-  public void testServerInstance()
-      throws Exception {
-    // Same local hostname and port
-    {
-      ServerInstance instance1 = new ServerInstance("localhost", 8080);
-      ServerInstance instance2 = new ServerInstance("localhost", 8080);
-//      System.out.println("Instance 1 :" + instance1);
-//      System.out.println("Instance 2 :" + instance2);
-      Assert.assertEquals(instance2, instance1, "Localhost server-instances with same port");
-    }
-
-    // Same  hostname and port
-    {
-      ServerInstance instance1 = new ServerInstance("test-host", 8080);
-      ServerInstance instance2 = new ServerInstance("test-host", 8080);
-//      System.out.println("Instance 1 :" + instance1);
-//      System.out.println("Instance 2 :" + instance2);
-      Assert.assertEquals(instance2, instance1, "Localhost server-instances with same port");
-    }
-    // same hostname but different port
-    {
-      ServerInstance instance1 = new ServerInstance("localhost", 8081);
-      ServerInstance instance2 = new ServerInstance("localhost", 8082);
-//      System.out.println("Instance 1 :" + instance1);
-//      System.out.println("Instance 2 :" + instance2);
-      Assert.assertFalse(instance1.equals(instance2), "Localhost server-instances with same port");
-    }
+  public void testServerInstance() {
+    // Same local host and port
+    assertEquals(new ServerInstance("localhost", 8080), new ServerInstance("localhost", 8080));
 
-    // same port but different host
-    {
-      ServerInstance instance1 = new ServerInstance("abcd", 8080);
-      ServerInstance instance2 = new ServerInstance("abce", 8080);
-//      System.out.println("Instance 1 :" + instance1);
-//      System.out.println("Instance 2 :" + instance2);
-      Assert.assertFalse(instance1.equals(instance2), "Localhost server-instances with same port");
-    }
+    // Same host and port
+    assertEquals(new ServerInstance("test-host", 8080), new ServerInstance("test-host", 8080));
 
-    // Test getIpAddress
-    {
-      InetAddress ipAddr = InetAddress.getByName("127.0.0.1");
+    // Same host but different port
+    assertNotEquals(new ServerInstance("localhost", 8081), new ServerInstance("localhost", 8082));
 
-      ServerInstance instance1 = new ServerInstance("127.0.0.1", 8080);
-      Assert.assertEquals(instance1.getPort(), 8080, "Port check");
-      Assert.assertEquals(instance1.getPort(), 8080, "Hostname check");
-      Assert.assertEquals(instance1.getHostname(), ipAddr.getHostName(), "Host check");
-      Assert.assertEquals(instance1.getIpAddress(), ipAddr, "IP check");
-    }
+    // Same port but different host
+    assertNotEquals(new ServerInstance("foo", 8080), new ServerInstance("bar", 8080));
 
 Review comment:
   Can we include a test to test the case when host name is an ip address, like `127.0.0.1`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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