From 4de3cf1968a693a9ea5330773f93b1e52b717358 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Thu, 4 Oct 2018 09:51:42 +0900 Subject: [PATCH] YARN-8840. Add missing cleanupSSLConfig() call for TestTimelineClient test. Contributed by Aki Tanaka. (cherry picked from commit 39b35036ba47064149003046a7b59feb01575d1e) --- .../client/api/impl/TestTimelineClient.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java index e3fffef6143..715f7e5ff20 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import java.io.File; import java.io.IOException; import java.net.ConnectException; import java.net.SocketTimeoutException; @@ -62,6 +61,8 @@ public class TestTimelineClient { private TimelineClientImpl client; private TimelineWriter spyTimelineWriter; + private String keystoresDir; + private String sslConfDir; @Before public void setup() { @@ -72,10 +73,13 @@ public class TestTimelineClient { } @After - public void tearDown() { + public void tearDown() throws Exception { if (client != null) { client.stop(); } + if (isSSLConfigured()) { + KeyStoreTestUtil.cleanupSSLConfig(keystoresDir, sslConfDir); + } } @Test @@ -454,11 +458,7 @@ public class TestTimelineClient { conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES, 0); conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, Policy.HTTPS_ONLY.name()); - File testDir = TestGenericTestUtils.getTestDir(); - String sslConfDir = - KeyStoreTestUtil.getClasspathDir(TestTimelineClient.class); - KeyStoreTestUtil.setupSSLConfig(testDir.getAbsolutePath(), - sslConfDir, conf, false); + setupSSLConfig(conf); client = createTimelineClient(conf); ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); @@ -492,6 +492,17 @@ public class TestTimelineClient { Assert.assertFalse("Reloader is still alive", reloaderStillAlive); } + private void setupSSLConfig(YarnConfiguration conf) throws Exception { + keystoresDir = TestGenericTestUtils.getTestDir().getAbsolutePath(); + sslConfDir = + KeyStoreTestUtil.getClasspathDir(TestTimelineClient.class); + KeyStoreTestUtil.setupSSLConfig(keystoresDir, sslConfDir, conf, false); + } + + private boolean isSSLConfigured() { + return keystoresDir != null && sslConfDir != null; + } + private static class TestTimelineDelegationTokenSecretManager extends AbstractDelegationTokenSecretManager {