|
@@ -17,6 +17,7 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.hdfs.tools;
|
|
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_BIND_HOST_KEY;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
@@ -57,6 +58,8 @@ import org.junit.Test;
|
|
|
import com.google.common.base.Supplier;
|
|
|
|
|
|
public class TestDFSZKFailoverController extends ClientBaseWithFixes {
|
|
|
+ private static final String LOCALHOST_SERVER_ADDRESS = "127.0.0.1";
|
|
|
+ private static final String WILDCARD_ADDRESS = "0.0.0.0";
|
|
|
private Configuration conf;
|
|
|
private MiniDFSCluster cluster;
|
|
|
private TestContext ctx;
|
|
@@ -207,6 +210,27 @@ public class TestDFSZKFailoverController extends ClientBaseWithFixes {
|
|
|
waitForHAState(1, HAServiceState.STANDBY);
|
|
|
}
|
|
|
|
|
|
+ @Test(timeout=30000)
|
|
|
+ public void testWithoutBindAddressSet() throws Exception {
|
|
|
+ DFSZKFailoverController zkfc = DFSZKFailoverController.create(
|
|
|
+ conf);
|
|
|
+
|
|
|
+ assertEquals("Bind address not expected to be wildcard by default.",
|
|
|
+ zkfc.getRpcAddressToBindTo().getHostString(),
|
|
|
+ LOCALHOST_SERVER_ADDRESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(timeout=30000)
|
|
|
+ public void testWithBindAddressSet() throws Exception {
|
|
|
+ conf.set(DFS_NAMENODE_SERVICE_RPC_BIND_HOST_KEY, WILDCARD_ADDRESS);
|
|
|
+ DFSZKFailoverController zkfc = DFSZKFailoverController.create(
|
|
|
+ conf);
|
|
|
+ String addr = zkfc.getRpcAddressToBindTo().getHostString();
|
|
|
+
|
|
|
+ assertEquals("Bind address " + addr + " is not wildcard.",
|
|
|
+ addr, WILDCARD_ADDRESS);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Tests that a Namenode in Observer state rejects any state transition
|
|
|
* request from ZKFC, as a result of namenode's participation in the ZK
|