HDFS-15657. RBF: TestRouter#testNamenodeHeartBeatEnableDefault fails by BindException (#2418)

(cherry picked from commit b3ba74d72d)
This commit is contained in:
Akira Ajisaka 2020-10-28 19:12:23 +09:00 committed by Takanobu Asanuma
parent d4129c6794
commit 8e0922edb2

View File

@ -274,9 +274,18 @@ public void testNamenodeHeartBeatEnableDefault() throws IOException {
*/
private void checkNamenodeHeartBeatEnableDefault(boolean enable)
throws IOException {
final Router router = new Router();
try {
try (Router router = new Router()) {
// Use default config
Configuration config = new HdfsConfiguration();
// bind to any available port
config.set(RBFConfigKeys.DFS_ROUTER_RPC_BIND_HOST_KEY, "0.0.0.0");
config.set(RBFConfigKeys.DFS_ROUTER_RPC_ADDRESS_KEY, "127.0.0.1:0");
config.set(RBFConfigKeys.DFS_ROUTER_ADMIN_ADDRESS_KEY, "127.0.0.1:0");
config.set(RBFConfigKeys.DFS_ROUTER_ADMIN_BIND_HOST_KEY, "0.0.0.0");
config.set(RBFConfigKeys.DFS_ROUTER_HTTP_ADDRESS_KEY, "127.0.0.1:0");
config.set(RBFConfigKeys.DFS_ROUTER_HTTPS_ADDRESS_KEY, "127.0.0.1:0");
config.set(RBFConfigKeys.DFS_ROUTER_HTTP_BIND_HOST_KEY, "0.0.0.0");
config.setBoolean(RBFConfigKeys.DFS_ROUTER_HEARTBEAT_ENABLE, enable);
router.init(config);
if (enable) {
@ -284,8 +293,6 @@ private void checkNamenodeHeartBeatEnableDefault(boolean enable)
} else {
assertNull(router.getNamenodeHeartbeatServices());
}
} finally {
router.close();
}
}
}