Github user sohami commented on a diff in the pull request: https://github.com/apache/drill/pull/648#discussion_r87351643 --- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/client/DrillClientSystemTest.java --- @@ -73,4 +77,90 @@ public void testSubmitPlanTwoNodes() throws Exception { } client.close(); } + + @Test + public void testPopulateEndpointsList() throws Exception{ + + ArrayList<DrillbitEndpoint> endpointsList = new ArrayList<>(); + String drillBitConnection; + DrillClient client = new DrillClient(); + DrillbitEndpoint endpoint; + Iterator<DrillbitEndpoint> endpointIterator; + + + // Test with single drillbit ip + drillBitConnection = "10.10.100.161"; + client.populateEndpointsList(endpointsList, drillBitConnection); + endpoint = endpointsList.iterator().next(); + assert(endpointsList.size() == 1); + assert(endpoint.getAddress().equalsIgnoreCase(drillBitConnection)); + assert(endpoint.getUserPort() == client.getConfig().getInt(ExecConstants.INITIAL_USER_PORT)); + + // Test with single drillbit ip:port + endpointsList.clear(); + drillBitConnection = "10.10.100.161:5000"; + String[] ipAndPort = drillBitConnection.split(":"); + client.populateEndpointsList(endpointsList, drillBitConnection); + assert(endpointsList.size() == 1); + + endpoint = endpointsList.iterator().next(); + assert(endpoint.getAddress().equalsIgnoreCase(ipAndPort[0])); + assert(endpoint.getUserPort() == Integer.parseInt(ipAndPort[1])); + + // Test with multiple drillbit ip + endpointsList.clear(); + drillBitConnection = "10.10.100.161,10.10.100.162"; + client.populateEndpointsList(endpointsList, drillBitConnection); + assert(endpointsList.size() == 2); + + endpointIterator = endpointsList.iterator(); + endpoint = endpointIterator.next(); + assert(endpoint.getAddress().equalsIgnoreCase("10.10.100.161")); + assert(endpoint.getUserPort() == client.getConfig().getInt(ExecConstants.INITIAL_USER_PORT)); --- End diff -- Fixed
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---