|
@@ -29,11 +29,11 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SECONDARY_HTTP_A
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMESERVICES;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMESERVICE_ID;
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.assertFalse;
|
|
|
-import static org.junit.Assert.assertNull;
|
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
-import static org.junit.Assert.fail;
|
|
|
+import org.apache.hadoop.util.Shell;
|
|
|
+
|
|
|
+import static org.junit.Assert.*;
|
|
|
+import org.junit.Assume;
|
|
|
+import static org.hamcrest.CoreMatchers.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.net.InetSocketAddress;
|
|
@@ -619,19 +619,25 @@ public class TestDFSUtil {
|
|
|
|
|
|
assertEquals(1, uris.size());
|
|
|
assertTrue(uris.contains(new URI("hdfs://" + NN1_SRVC_ADDR)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test (timeout=15000)
|
|
|
+ public void testLocalhostReverseLookup() {
|
|
|
+ // 127.0.0.1 -> localhost reverse resolution does not happen on Windows.
|
|
|
+ Assume.assumeTrue(!Shell.WINDOWS);
|
|
|
|
|
|
// Make sure when config FS_DEFAULT_NAME_KEY using IP address,
|
|
|
// it will automatically convert it to hostname
|
|
|
- conf = new HdfsConfiguration();
|
|
|
+ HdfsConfiguration conf = new HdfsConfiguration();
|
|
|
conf.set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY, "hdfs://127.0.0.1:8020");
|
|
|
- uris = DFSUtil.getNameServiceUris(conf);
|
|
|
+ Collection<URI> uris = DFSUtil.getNameServiceUris(conf);
|
|
|
assertEquals(1, uris.size());
|
|
|
for (URI uri : uris) {
|
|
|
- assertFalse(uri.getHost().equals("127.0.0.1"));
|
|
|
+ assertThat(uri.getHost(), not("127.0.0.1"));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @Test
|
|
|
+
|
|
|
+ @Test (timeout=15000)
|
|
|
public void testIsValidName() {
|
|
|
assertFalse(DFSUtil.isValidName("/foo/../bar"));
|
|
|
assertFalse(DFSUtil.isValidName("/foo//bar"));
|