HIVE-13707: Fix TestLlapOutputFormat
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/89ec219e Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/89ec219e Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/89ec219e Branch: refs/heads/master Commit: 89ec219e170d7ce59bf223cdce2fb521ba0a1518 Parents: 763e696 Author: Jason Dere <jd...@hortonworks.com> Authored: Fri May 6 10:05:49 2016 -0700 Committer: Jason Dere <jd...@hortonworks.com> Committed: Fri May 6 10:05:49 2016 -0700 ---------------------------------------------------------------------- .../hadoop/hive/llap/TestLlapOutputFormat.java | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/89ec219e/ql/src/test/org/apache/hadoop/hive/llap/TestLlapOutputFormat.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/llap/TestLlapOutputFormat.java b/ql/src/test/org/apache/hadoop/hive/llap/TestLlapOutputFormat.java index 907d5b0..1d592fb 100644 --- a/ql/src/test/org/apache/hadoop/hive/llap/TestLlapOutputFormat.java +++ b/ql/src/test/org/apache/hadoop/hive/llap/TestLlapOutputFormat.java @@ -20,8 +20,8 @@ package org.apache.hadoop.hive.llap; import org.junit.Assert; import org.junit.Test; -import org.junit.Before; -import org.junit.After; +import org.junit.BeforeClass; +import org.junit.AfterClass; import java.net.Socket; @@ -60,18 +60,22 @@ public class TestLlapOutputFormat { private static final Logger LOG = LoggerFactory.getLogger(TestLlapOutputFormat.class); - private LlapOutputFormatService service; + private static LlapOutputFormatService service; - @Before - public void setUp() throws IOException { + @BeforeClass + public static void setUp() throws Exception { LOG.debug("Setting up output service"); + Configuration conf = new Configuration(); + // Pick random avail port + HiveConf.setIntVar(conf, HiveConf.ConfVars.LLAP_DAEMON_OUTPUT_SERVICE_PORT, 0); + LlapOutputFormatService.initializeAndStart(conf); service = LlapOutputFormatService.get(); LlapProxy.setDaemon(true); LOG.debug("Output service up"); } - @After - public void tearDown() throws IOException, InterruptedException { + @AfterClass + public static void tearDown() throws IOException, InterruptedException { LOG.debug("Tearing down service"); service.stop(); LOG.debug("Tearing down complete"); @@ -87,8 +91,7 @@ public class TestLlapOutputFormat { LlapOutputFormat format = new LlapOutputFormat(); HiveConf conf = new HiveConf(); - Socket socket = new Socket("localhost", - conf.getIntVar(HiveConf.ConfVars.LLAP_DAEMON_OUTPUT_SERVICE_PORT)); + Socket socket = new Socket("localhost", service.getPort()); LOG.debug("Socket connected");