You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2016/10/20 22:12:43 UTC

[06/23] hive git commit: HIVE-15006. Rename TestBeelineWithHS2ConnectionFile to avoid it being interpreted as a test file.. (Siddharth Seth, reviewed by Prasanth Jayachandran)

HIVE-15006. Rename TestBeelineWithHS2ConnectionFile to avoid it being interpreted as a test file.. (Siddharth Seth, reviewed by Prasanth Jayachandran)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a7dbd4e0
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a7dbd4e0
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a7dbd4e0

Branch: refs/heads/hive-14535
Commit: a7dbd4e0da7e3eaac1889b0b75b68ad9677deac5
Parents: 9072575
Author: Siddharth Seth <ss...@apache.org>
Authored: Wed Oct 19 22:24:23 2016 -0700
Committer: Siddharth Seth <ss...@apache.org>
Committed: Wed Oct 19 22:24:23 2016 -0700

----------------------------------------------------------------------
 .../BeelineWithHS2ConnectionFileTestBase.java   | 218 +++++++++++++++++++
 .../TestBeelineConnectionUsingHiveSite.java     |   2 +-
 .../TestBeelineWithHS2ConnectionFile.java       | 218 -------------------
 .../TestBeelineWithUserHs2ConnectionFile.java   |   3 +-
 4 files changed, 220 insertions(+), 221 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/a7dbd4e0/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java
new file mode 100644
index 0000000..2fb6453
--- /dev/null
+++ b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java
@@ -0,0 +1,218 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hive.beeline.hs2connection;
+
+import static org.junit.Assert.assertFalse;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.sql.DriverManager;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
+import org.apache.hive.beeline.BeeLine;
+import org.apache.hive.jdbc.miniHS2.MiniHS2;
+import org.apache.hive.service.cli.CLIServiceClient;
+import org.apache.hive.service.cli.HiveSQLException;
+import org.apache.hive.service.cli.OperationHandle;
+import org.apache.hive.service.cli.RowSet;
+import org.apache.hive.service.cli.SessionHandle;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+public abstract class BeelineWithHS2ConnectionFileTestBase {
+  protected MiniHS2 miniHS2;
+  protected HiveConf hiveConf = new HiveConf();
+  protected final String tableName = "testBeelineTable";
+  protected String dataFileDir = hiveConf.get("test.data.files");
+  protected static final String LOCALHOST_KEY_STORE_NAME = "keystore.jks";
+  protected static final String TRUST_STORE_NAME = "truststore.jks";
+  protected static final String KEY_STORE_TRUST_STORE_PASSWORD = "HiveJdbc";
+  protected static final String HS2_HTTP_MODE = "http";
+  protected static final String HS2_HTTP_ENDPOINT = "cliservice";
+  private final String fileLocation =
+      System.getProperty("java.io.tmpdir") + "testHs2ConnectionConfig.xml";
+  protected static final String JAVA_TRUST_STORE_PROP = "javax.net.ssl.trustStore";
+  protected static final String JAVA_TRUST_STORE_PASS_PROP = "javax.net.ssl.trustStorePassword";
+
+  protected Map<String, String> confOverlay = new HashMap<>();
+
+  protected class TestBeeLine extends BeeLine {
+    UserHS2ConnectionFileParser testHs2ConfigFileManager;
+    ByteArrayOutputStream os;
+
+    TestBeeLine(List<String> defaultHS2ConnectionFiles) {
+      testHs2ConfigFileManager = new UserHS2ConnectionFileParser(defaultHS2ConnectionFiles);
+      os = new ByteArrayOutputStream();
+      PrintStream beelineOutputStream = new PrintStream(os);
+      setOutputStream(beelineOutputStream);
+      setErrorStream(beelineOutputStream);
+    }
+
+    TestBeeLine() {
+      testHs2ConfigFileManager = new UserHS2ConnectionFileParser(null);
+      os = new ByteArrayOutputStream();
+      PrintStream beelineOutputStream = new PrintStream(os);
+      setOutputStream(beelineOutputStream);
+      setErrorStream(beelineOutputStream);
+    }
+
+    public String getOutput() throws UnsupportedEncodingException {
+      return os.toString("UTF8");
+    }
+
+    @Override
+    public HS2ConnectionFileParser getUserHS2ConnFileParser() {
+      return testHs2ConfigFileManager;
+    }
+
+    @Override
+    public HS2ConnectionFileParser getHiveSiteHS2ConnectionFileParser() {
+      HiveSiteHS2ConnectionFileParser ret = new HiveSiteHS2ConnectionFileParser();
+      ret.setHiveConf(miniHS2.getHiveConf());
+      return ret;
+    }
+  }
+
+  /*
+   * Wrapper class to write a HS2ConnectionConfig file
+   */
+  protected class Hs2ConnectionXmlConfigFileWriter {
+    private final PrintWriter writer;
+    private final File file;
+    private final Configuration conf;
+
+    protected Hs2ConnectionXmlConfigFileWriter() throws IOException {
+      file = new File(fileLocation);
+      conf = new Configuration(false);
+      try {
+        if (file.exists()) {
+          file.delete();
+        }
+        file.createNewFile();
+        writer = new PrintWriter(file.getAbsolutePath(), "UTF-8");
+      } finally {
+        file.deleteOnExit();
+      }
+    }
+
+    protected void writeProperty(String key, String value) {
+      conf.set(key, value);
+    }
+
+    protected String path() {
+      return file.getAbsolutePath();
+    }
+
+    protected void close() throws IOException {
+      try {
+        conf.writeXml(writer);
+      } finally {
+        writer.close();
+      }
+    }
+  }
+
+  @BeforeClass
+  public static void beforeTest() throws Exception {
+    MiniHS2.cleanupLocalDir();
+    Class.forName(MiniHS2.getJdbcDriverName());
+  }
+
+  @AfterClass
+  public static void afterClass() throws IOException {
+    MiniHS2.cleanupLocalDir();
+  }
+
+  @Before
+  public void before() throws Exception {
+    DriverManager.setLoginTimeout(0);
+    if (!System.getProperty("test.data.files", "").isEmpty()) {
+      dataFileDir = System.getProperty("test.data.files");
+    }
+    dataFileDir = dataFileDir.replace('\\', '/').replace("c:", "");
+    hiveConf = new HiveConf();
+    miniHS2 = getNewMiniHS2();
+    confOverlay = new HashMap<String, String>();
+    confOverlay.put(ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
+    confOverlay.put(ConfVars.HIVE_SERVER2_TRANSPORT_MODE.varname, "binary");
+  }
+
+  protected MiniHS2 getNewMiniHS2() throws Exception {
+    return new MiniHS2.Builder().withConf(hiveConf).cleanupLocalDirOnStartup(false).build();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if (miniHS2 != null && miniHS2.isStarted()) {
+      miniHS2.stop();
+    }
+    miniHS2 = null;
+    System.clearProperty(JAVA_TRUST_STORE_PROP);
+    System.clearProperty(JAVA_TRUST_STORE_PASS_PROP);
+  }
+
+  protected void createTable() throws HiveSQLException {
+    CLIServiceClient serviceClient = miniHS2.getServiceClient();
+    SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
+    serviceClient.executeStatement(sessHandle, "DROP TABLE IF EXISTS " + tableName, confOverlay);
+    serviceClient.executeStatement(sessHandle, "CREATE TABLE " + tableName + " (id INT)",
+        confOverlay);
+    OperationHandle opHandle =
+        serviceClient.executeStatement(sessHandle, "SHOW TABLES", confOverlay);
+    RowSet rowSet = serviceClient.fetchResults(opHandle);
+    assertFalse(rowSet.numRows() == 0);
+  }
+
+  protected String testBeeLineConnection(String path, String[] beelineArgs,
+      String expectedOutput) throws IOException {
+    TestBeeLine beeLine = null;
+    try {
+      if(path != null) {
+        List<String> testLocations = new ArrayList<>();
+        testLocations.add(path);
+        beeLine = new TestBeeLine(testLocations);
+      } else {
+        beeLine = new TestBeeLine();
+      }
+      beeLine.begin(beelineArgs, null);
+      String output = beeLine.getOutput();
+      System.out.println(output);
+      Assert.assertNotNull(output);
+      Assert.assertTrue("Output " + output + " does not contain " + expectedOutput,
+          output.toLowerCase().contains(expectedOutput.toLowerCase()));
+      return output;
+    } finally {
+      if (beeLine != null) {
+        beeLine.close();
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/a7dbd4e0/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineConnectionUsingHiveSite.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineConnectionUsingHiveSite.java b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineConnectionUsingHiveSite.java
index 1ad764b..8bff87c 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineConnectionUsingHiveSite.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineConnectionUsingHiveSite.java
@@ -22,7 +22,7 @@ import java.io.File;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.junit.Test;
 
-public class TestBeelineConnectionUsingHiveSite extends TestBeelineWithHS2ConnectionFile {
+public class TestBeelineConnectionUsingHiveSite extends BeelineWithHS2ConnectionFileTestBase {
   @Test
   public void testBeelineConnectionHttp() throws Exception {
     setupHs2();

http://git-wip-us.apache.org/repos/asf/hive/blob/a7dbd4e0/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithHS2ConnectionFile.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithHS2ConnectionFile.java b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithHS2ConnectionFile.java
deleted file mode 100644
index 7fc3d52..0000000
--- a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithHS2ConnectionFile.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hive.beeline.hs2connection;
-
-import static org.junit.Assert.assertFalse;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.sql.DriverManager;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
-import org.apache.hive.beeline.BeeLine;
-import org.apache.hive.jdbc.miniHS2.MiniHS2;
-import org.apache.hive.service.cli.CLIServiceClient;
-import org.apache.hive.service.cli.HiveSQLException;
-import org.apache.hive.service.cli.OperationHandle;
-import org.apache.hive.service.cli.RowSet;
-import org.apache.hive.service.cli.SessionHandle;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-public abstract class TestBeelineWithHS2ConnectionFile {
-  protected MiniHS2 miniHS2;
-  protected HiveConf hiveConf = new HiveConf();
-  protected final String tableName = "testBeelineTable";
-  protected String dataFileDir = hiveConf.get("test.data.files");
-  protected static final String LOCALHOST_KEY_STORE_NAME = "keystore.jks";
-  protected static final String TRUST_STORE_NAME = "truststore.jks";
-  protected static final String KEY_STORE_TRUST_STORE_PASSWORD = "HiveJdbc";
-  protected static final String HS2_HTTP_MODE = "http";
-  protected static final String HS2_HTTP_ENDPOINT = "cliservice";
-  private final String fileLocation =
-      System.getProperty("java.io.tmpdir") + "testHs2ConnectionConfig.xml";
-  protected static final String JAVA_TRUST_STORE_PROP = "javax.net.ssl.trustStore";
-  protected static final String JAVA_TRUST_STORE_PASS_PROP = "javax.net.ssl.trustStorePassword";
-
-  protected Map<String, String> confOverlay = new HashMap<>();
-
-  protected class TestBeeLine extends BeeLine {
-    UserHS2ConnectionFileParser testHs2ConfigFileManager;
-    ByteArrayOutputStream os;
-
-    TestBeeLine(List<String> defaultHS2ConnectionFiles) {
-      testHs2ConfigFileManager = new UserHS2ConnectionFileParser(defaultHS2ConnectionFiles);
-      os = new ByteArrayOutputStream();
-      PrintStream beelineOutputStream = new PrintStream(os);
-      setOutputStream(beelineOutputStream);
-      setErrorStream(beelineOutputStream);
-    }
-
-    TestBeeLine() {
-      testHs2ConfigFileManager = new UserHS2ConnectionFileParser(null);
-      os = new ByteArrayOutputStream();
-      PrintStream beelineOutputStream = new PrintStream(os);
-      setOutputStream(beelineOutputStream);
-      setErrorStream(beelineOutputStream);
-    }
-
-    public String getOutput() throws UnsupportedEncodingException {
-      return os.toString("UTF8");
-    }
-
-    @Override
-    public HS2ConnectionFileParser getUserHS2ConnFileParser() {
-      return testHs2ConfigFileManager;
-    }
-
-    @Override
-    public HS2ConnectionFileParser getHiveSiteHS2ConnectionFileParser() {
-      HiveSiteHS2ConnectionFileParser ret = new HiveSiteHS2ConnectionFileParser();
-      ret.setHiveConf(miniHS2.getHiveConf());
-      return ret;
-    }
-  }
-
-  /*
-   * Wrapper class to write a HS2ConnectionConfig file
-   */
-  protected class Hs2ConnectionXmlConfigFileWriter {
-    private final PrintWriter writer;
-    private final File file;
-    private final Configuration conf;
-
-    protected Hs2ConnectionXmlConfigFileWriter() throws IOException {
-      file = new File(fileLocation);
-      conf = new Configuration(false);
-      try {
-        if (file.exists()) {
-          file.delete();
-        }
-        file.createNewFile();
-        writer = new PrintWriter(file.getAbsolutePath(), "UTF-8");
-      } finally {
-        file.deleteOnExit();
-      }
-    }
-
-    protected void writeProperty(String key, String value) {
-      conf.set(key, value);
-    }
-
-    protected String path() {
-      return file.getAbsolutePath();
-    }
-
-    protected void close() throws IOException {
-      try {
-        conf.writeXml(writer);
-      } finally {
-        writer.close();
-      }
-    }
-  }
-
-  @BeforeClass
-  public static void beforeTest() throws Exception {
-    MiniHS2.cleanupLocalDir();
-    Class.forName(MiniHS2.getJdbcDriverName());
-  }
-
-  @AfterClass
-  public static void afterClass() throws IOException {
-    MiniHS2.cleanupLocalDir();
-  }
-
-  @Before
-  public void before() throws Exception {
-    DriverManager.setLoginTimeout(0);
-    if (!System.getProperty("test.data.files", "").isEmpty()) {
-      dataFileDir = System.getProperty("test.data.files");
-    }
-    dataFileDir = dataFileDir.replace('\\', '/').replace("c:", "");
-    hiveConf = new HiveConf();
-    miniHS2 = getNewMiniHS2();
-    confOverlay = new HashMap<String, String>();
-    confOverlay.put(ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
-    confOverlay.put(ConfVars.HIVE_SERVER2_TRANSPORT_MODE.varname, "binary");
-  }
-
-  protected MiniHS2 getNewMiniHS2() throws Exception {
-    return new MiniHS2.Builder().withConf(hiveConf).cleanupLocalDirOnStartup(false).build();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    if (miniHS2 != null && miniHS2.isStarted()) {
-      miniHS2.stop();
-    }
-    miniHS2 = null;
-    System.clearProperty(JAVA_TRUST_STORE_PROP);
-    System.clearProperty(JAVA_TRUST_STORE_PASS_PROP);
-  }
-
-  protected void createTable() throws HiveSQLException {
-    CLIServiceClient serviceClient = miniHS2.getServiceClient();
-    SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
-    serviceClient.executeStatement(sessHandle, "DROP TABLE IF EXISTS " + tableName, confOverlay);
-    serviceClient.executeStatement(sessHandle, "CREATE TABLE " + tableName + " (id INT)",
-        confOverlay);
-    OperationHandle opHandle =
-        serviceClient.executeStatement(sessHandle, "SHOW TABLES", confOverlay);
-    RowSet rowSet = serviceClient.fetchResults(opHandle);
-    assertFalse(rowSet.numRows() == 0);
-  }
-
-  protected String testBeeLineConnection(String path, String[] beelineArgs,
-      String expectedOutput) throws IOException {
-    TestBeeLine beeLine = null;
-    try {
-      if(path != null) {
-        List<String> testLocations = new ArrayList<>();
-        testLocations.add(path);
-        beeLine = new TestBeeLine(testLocations);
-      } else {
-        beeLine = new TestBeeLine();
-      }
-      beeLine.begin(beelineArgs, null);
-      String output = beeLine.getOutput();
-      System.out.println(output);
-      Assert.assertNotNull(output);
-      Assert.assertTrue("Output " + output + " does not contain " + expectedOutput,
-          output.toLowerCase().contains(expectedOutput.toLowerCase()));
-      return output;
-    } finally {
-      if (beeLine != null) {
-        beeLine.close();
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/a7dbd4e0/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithUserHs2ConnectionFile.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithUserHs2ConnectionFile.java b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithUserHs2ConnectionFile.java
index 0f86186..3684f14 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithUserHs2ConnectionFile.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/TestBeelineWithUserHs2ConnectionFile.java
@@ -21,10 +21,9 @@ import java.io.File;
 import java.net.URI;
 
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
-import org.apache.hive.beeline.hs2connection.HS2ConnectionFileParser;
 import org.junit.Test;
 
-public class TestBeelineWithUserHs2ConnectionFile extends TestBeelineWithHS2ConnectionFile {
+public class TestBeelineWithUserHs2ConnectionFile extends BeelineWithHS2ConnectionFileTestBase {
 
   @Test
   public void testBeelineConnectionHttp() throws Exception {