From 4fa009989bd641388aeb9b1bd9c90e9ddbfe84c0 Mon Sep 17 00:00:00 2001 From: Ajay Yadav <7813154+ajayydv@users.noreply.github.com> Date: Wed, 13 Mar 2019 12:01:08 -0700 Subject: [PATCH] HDDS-1254. Fix failure in TestOzoneManagerHttpServer & TestStorageContainerManagerHttpServer. Contributed by Ajay Kumar. (#598) --- .../scm/TestStorageContainerManagerHttpServer.java | 10 ++++++---- .../hadoop/ozone/om/TestOzoneManagerHttpServer.java | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) 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) {