Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/648#discussion_r87102298
  
    --- 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));
    +
    +    endpoint = endpointIterator.next();
    +    assert(endpoint.getAddress().equalsIgnoreCase("10.10.100.162"));
    +    assert(endpoint.getUserPort() == 
client.getConfig().getInt(ExecConstants.INITIAL_USER_PORT));
    +
    +    // Test with multiple drillbit ip:port
    +    endpointsList.clear();
    +    drillBitConnection = "10.10.100.161:5000,10.10.100.162:5000";
    +    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() == 5000);
    +
    +    endpoint = endpointIterator.next();
    +    assert(endpoint.getAddress().equalsIgnoreCase("10.10.100.162"));
    +    assert(endpoint.getUserPort() == 5000);
    +
    +    // Test with multiple drillbit with mix of ip:port and ip
    +    endpointsList.clear();
    +    drillBitConnection = "10.10.100.161:5000,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() == 5000);
    +
    +    endpoint = endpointIterator.next();
    +    assert(endpoint.getAddress().equalsIgnoreCase("10.10.100.162"));
    +    assert(endpoint.getUserPort() == 
client.getConfig().getInt(ExecConstants.INITIAL_USER_PORT));
    +
    +    // Test with empty string
    +    endpointsList.clear();
    +    drillBitConnection = "";
    +    client.populateEndpointsList(endpointsList, drillBitConnection);
    +    assert(endpointsList.size() == 0);
    +
    +
    --- End diff --
    
    Test the other strange cases noted in earlier comments: spaces, non-numeric 
ports, missing host, etc:
    
        " foo : 10 ", "foo: ", "foo:", "foo:bar", ":20", etc.
    
    for errors:
    
        {
            try { parseEndpoints( "foo:bogus" ); fail( ); }
            catch( YourException e ) { }
        }



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to