diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java index 46a6a9de81..d9407e7f40 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java @@ -106,13 +106,15 @@ public TestStorageContainerManagerHttpServer(Policy policy) { Assert.assertTrue(implies(policy.isHttpEnabled(), canAccess("http", server.getHttpAddress()))); - Assert.assertTrue( - implies(!policy.isHttpEnabled(), server.getHttpAddress() == null)); + Assert.assertTrue(implies(policy.isHttpEnabled() && + !policy.isHttpsEnabled(), + !canAccess("https", server.getHttpsAddress()))); Assert.assertTrue(implies(policy.isHttpsEnabled(), canAccess("https", server.getHttpsAddress()))); - Assert.assertTrue( - implies(!policy.isHttpsEnabled(), server.getHttpsAddress() == null)); + Assert.assertTrue(implies(policy.isHttpsEnabled() && + !policy.isHttpEnabled(), + !canAccess("http", server.getHttpAddress()))); } finally { if (server != null) { diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHttpServer.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHttpServer.java index 3e11a13b14..fc85d8ebc7 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHttpServer.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHttpServer.java @@ -95,8 +95,8 @@ public TestOzoneManagerHttpServer(Policy policy) { @Test public void testHttpPolicy() throws Exception { conf.set(DFSConfigKeys.DFS_HTTP_POLICY_KEY, policy.name()); conf.set(ScmConfigKeys.OZONE_SCM_HTTPS_ADDRESS_KEY, "localhost:0"); - InetSocketAddress addr = InetSocketAddress.createUnresolved("localhost", 0); + OzoneManagerHttpServer server = null; try { server = new OzoneManagerHttpServer(conf, null); @@ -104,13 +104,14 @@ public TestOzoneManagerHttpServer(Policy policy) { Assert.assertTrue(implies(policy.isHttpEnabled(), canAccess("http", server.getHttpAddress()))); - Assert.assertTrue( - implies(!policy.isHttpEnabled(), server.getHttpAddress() == null)); + Assert.assertTrue(implies(policy.isHttpEnabled() && + !policy.isHttpsEnabled(), + !canAccess("https", server.getHttpsAddress()))); Assert.assertTrue(implies(policy.isHttpsEnabled(), canAccess("https", server.getHttpsAddress()))); - Assert.assertTrue( - implies(!policy.isHttpsEnabled(), server.getHttpsAddress() == null)); + Assert.assertTrue(implies(policy.isHttpsEnabled(), + !canAccess("http", server.getHttpsAddress()))); } finally { if (server != null) {