Sunil G commented on YARN-4306:


>From {{SecurityUtil#getByName}}, 
        // it's a simple host with no dots, ex. "host"
        // try the search list, then fallback to exact host
        InetAddress loopback = InetAddress.getByName(null);
        if (host.equalsIgnoreCase(loopback.getHostName())) {
          addr = InetAddress.getByAddress(host, loopback.getAddress());
        } else {
          addr = getByNameWithSearch(host);
          if (addr == null) {
            addr = getByExactName(host);
This code will hit while trying to resolve hostname to IP Address (For eg: 
Hostname is "sunil-Inspiron-3543").

Also a my "/etc/hosts" will look like below:
{noformat}       localhost       sunil-Inspiron-3543

When I debugged this, I could see that {{InetAddress.getByName(null)}} returns 
"localhost" and comparision fails as my hostname is "sunil-Inspiron-3543".

This will take the code to hit the method {{getByNameWithSearch}} and 
subsequently {{getByExactName}} as getByNameWithSearch will also fail (no DNS 
is configured).

    InetAddress getByExactName(String host) {
      InetAddress addr = null;
      // InetAddress will use the search list unless the host is rooted
      // with a trailing dot.  The trailing dot will disable any use of the
      // search path in a lower level resolver.  See RFC 1535.
      String fqHost = host;
      if (!fqHost.endsWith(".")) fqHost += ".";
      try {
        addr = getInetAddressByName(fqHost);

Since {{if (!fqHost.endsWith(".")) fqHost += ".";}} is performed before 
{{getInetAddressByName}}, this lookup also will fail. If this is not added, 
then lookup is coming successful. This causes the test failure. Basically an 
*UnKnownHostException* causing test failures.

1, loopback address configuration can be changed to use hostname
2, use DNS in local machine
3, we can make changes in {{getByExactName}} where we check with given hostname 
itself before doing with *hostname + "."*.

Kindly help to share your thoughts.

> Test failure: TestClientRMTokens
> --------------------------------
>                 Key: YARN-4306
>                 URL: https://issues.apache.org/jira/browse/YARN-4306
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: test
>            Reporter: Sunil G
>            Assignee: Sunil G
> Tests are getting failed in local also. As part of HADOOP-12321 jenkins run, 
> I see same error.:
> {noformat}testShortCircuitRenewCancelDifferentHostSamePort(org.apache.hadoop.yarn.server.resourcemanager.TestClientRMTokens)
>   Time elapsed: 0.638 sec  <<< FAILURE!
> java.lang.AssertionError: expected:<getProxy> but was:<null>
>       at org.junit.Assert.fail(Assert.java:88)
>       at org.junit.Assert.failNotEquals(Assert.java:743)
>       at org.junit.Assert.assertEquals(Assert.java:118)
>       at org.junit.Assert.assertEquals(Assert.java:144)
>       at 
> org.apache.hadoop.yarn.server.resourcemanager.TestClientRMTokens.checkShortCircuitRenewCancel(TestClientRMTokens.java:363)
>       at 
> org.apache.hadoop.yarn.server.resourcemanager.TestClientRMTokens.testShortCircuitRenewCancelDifferentHostSamePort(TestClientRMTokens.java:316)
> {noformat}

This message was sent by Atlassian JIRA

Reply via email to