HADOOP-12449. TestDNS and TestNetUtils failing if no network. (stevel)
This commit is contained in:
parent
950e8a459e
commit
38f86c0842
|
@ -629,6 +629,8 @@ Release 2.8.0 - UNRELEASED
|
||||||
HADOOP-12284. UserGroupInformation doAs can throw misleading exception
|
HADOOP-12284. UserGroupInformation doAs can throw misleading exception
|
||||||
(Aaron Dosset via stevel)
|
(Aaron Dosset via stevel)
|
||||||
|
|
||||||
|
HADOOP-12449. TestDNS and TestNetUtils failing if no network. (stevel)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
|
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.net.SocketException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
import javax.naming.CommunicationException;
|
||||||
import javax.naming.NameNotFoundException;
|
import javax.naming.NameNotFoundException;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -165,8 +166,8 @@ public class TestDNS {
|
||||||
InetAddress localhost = getLocalIPAddr();
|
InetAddress localhost = getLocalIPAddr();
|
||||||
try {
|
try {
|
||||||
String s = DNS.reverseDns(localhost, null);
|
String s = DNS.reverseDns(localhost, null);
|
||||||
LOG.info("Local revers DNS hostname is " + s);
|
LOG.info("Local reverse DNS hostname is " + s);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException | CommunicationException e) {
|
||||||
if (!localhost.isLinkLocalAddress() || localhost.isLoopbackAddress()) {
|
if (!localhost.isLinkLocalAddress() || localhost.isLoopbackAddress()) {
|
||||||
//these addresses probably won't work with rDNS anyway, unless someone
|
//these addresses probably won't work with rDNS anyway, unless someone
|
||||||
//has unusual entries in their DNS server mapping 1.0.0.127 to localhost
|
//has unusual entries in their DNS server mapping 1.0.0.127 to localhost
|
||||||
|
|
|
@ -616,19 +616,29 @@ public class TestNetUtils {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testNormalizeHostName() {
|
public void testNormalizeHostName() {
|
||||||
List<String> hosts = Arrays.asList(new String[] {"127.0.0.1",
|
String oneHost = "1.kanyezone.appspot.com";
|
||||||
"localhost", "1.kanyezone.appspot.com", "UnknownHost123"});
|
try {
|
||||||
|
InetAddress.getByName(oneHost);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
Assume.assumeTrue("Network not resolving "+ oneHost, false);
|
||||||
|
}
|
||||||
|
List<String> hosts = Arrays.asList("127.0.0.1",
|
||||||
|
"localhost", oneHost, "UnknownHost123");
|
||||||
List<String> normalizedHosts = NetUtils.normalizeHostNames(hosts);
|
List<String> normalizedHosts = NetUtils.normalizeHostNames(hosts);
|
||||||
|
String summary = "original [" + StringUtils.join(hosts, ", ") + "]"
|
||||||
|
+ " normalized [" + StringUtils.join(normalizedHosts, ", ") + "]";
|
||||||
// when ipaddress is normalized, same address is expected in return
|
// when ipaddress is normalized, same address is expected in return
|
||||||
assertEquals(normalizedHosts.get(0), hosts.get(0));
|
assertEquals(summary, hosts.get(0), normalizedHosts.get(0));
|
||||||
// for normalizing a resolvable hostname, resolved ipaddress is expected in return
|
// for normalizing a resolvable hostname, resolved ipaddress is expected in return
|
||||||
assertFalse(normalizedHosts.get(1).equals(hosts.get(1)));
|
assertFalse("Element 1 equal "+ summary,
|
||||||
assertEquals(normalizedHosts.get(1), hosts.get(0));
|
normalizedHosts.get(1).equals(hosts.get(1)));
|
||||||
|
assertEquals(summary, hosts.get(0), normalizedHosts.get(1));
|
||||||
// this address HADOOP-8372: when normalizing a valid resolvable hostname start with numeric,
|
// this address HADOOP-8372: when normalizing a valid resolvable hostname start with numeric,
|
||||||
// its ipaddress is expected to return
|
// its ipaddress is expected to return
|
||||||
assertFalse(normalizedHosts.get(2).equals(hosts.get(2)));
|
assertFalse("Element 2 equal " + summary,
|
||||||
|
normalizedHosts.get(2).equals(hosts.get(2)));
|
||||||
// return the same hostname after normalizing a irresolvable hostname.
|
// return the same hostname after normalizing a irresolvable hostname.
|
||||||
assertEquals(normalizedHosts.get(3), hosts.get(3));
|
assertEquals(summary, hosts.get(3), normalizedHosts.get(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue