Search in sources :

Example 11 with MiniHS2

use of org.apache.hive.jdbc.miniHS2.MiniHS2 in project hive by apache.

the class TestJdbcWithLocalClusterSpark method beforeTest.

@BeforeClass
public static void beforeTest() throws Exception {
    Class.forName(MiniHS2.getJdbcDriverName());
    conf = createHiveConf();
    conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    String dataFileDir = conf.get("test.data.files").replace('\\', '/').replace("c:", "");
    dataFilePath = new Path(dataFileDir, "kv1.txt");
    DriverManager.setLoginTimeout(0);
    conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    miniHS2 = new MiniHS2(conf, MiniClusterType.MR);
    Map<String, String> overlayProps = new HashMap<String, String>();
    overlayProps.put(ConfVars.HIVE_SERVER2_SESSION_HOOK.varname, LocalClusterSparkSessionHook.class.getName());
    miniHS2.start(overlayProps);
    createDb();
}
Also used : Path(org.apache.hadoop.fs.Path) HashMap(java.util.HashMap) MiniHS2(org.apache.hive.jdbc.miniHS2.MiniHS2) BeforeClass(org.junit.BeforeClass)

Example 12 with MiniHS2

use of org.apache.hive.jdbc.miniHS2.MiniHS2 in project hive by apache.

the class TestMultiSessionsHS2WithLocalClusterSpark method beforeTest.

@BeforeClass
public static void beforeTest() throws Exception {
    Class.forName(MiniHS2.getJdbcDriverName());
    conf = createHiveConf();
    conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    String dataFileDir = conf.get("test.data.files").replace('\\', '/').replace("c:", "");
    dataFilePath = new Path(dataFileDir, "kv1.txt");
    DriverManager.setLoginTimeout(0);
    conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    miniHS2 = new MiniHS2(conf, MiniClusterType.MR);
    Map<String, String> overlayProps = new HashMap<String, String>();
    overlayProps.put(ConfVars.HIVE_SERVER2_SESSION_HOOK.varname, LocalClusterSparkSessionHook.class.getName());
    miniHS2.start(overlayProps);
    createDb();
}
Also used : Path(org.apache.hadoop.fs.Path) HashMap(java.util.HashMap) MiniHS2(org.apache.hive.jdbc.miniHS2.MiniHS2) BeforeClass(org.junit.BeforeClass)

Example 13 with MiniHS2

use of org.apache.hive.jdbc.miniHS2.MiniHS2 in project hive by apache.

the class TestNoSaslAuth method beforeTest.

@BeforeClass
public static void beforeTest() throws Exception {
    Class.forName(MiniHS2.getJdbcDriverName());
    HiveConf conf = new HiveConf();
    conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    conf.setBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
    conf.setVar(ConfVars.HIVE_SERVER2_SESSION_HOOK, NoSaslSessionHook.class.getName());
    conf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, "NOSASL");
    miniHS2 = new MiniHS2(conf);
    Map<String, String> overlayProps = new HashMap<String, String>();
    miniHS2.start(overlayProps);
}
Also used : HashMap(java.util.HashMap) HiveConf(org.apache.hadoop.hive.conf.HiveConf) MiniHS2(org.apache.hive.jdbc.miniHS2.MiniHS2) BeforeClass(org.junit.BeforeClass)

Example 14 with MiniHS2

use of org.apache.hive.jdbc.miniHS2.MiniHS2 in project hive by apache.

the class TestSSL method testMetastoreWithSSL.

/**
   * Test HMS server with SSL
   * @throws Exception
   */
@Test
public void testMetastoreWithSSL() throws Exception {
    setMetastoreSslConf(conf);
    setSslConfOverlay(confOverlay);
    // Test in http mode
    setHttpConfOverlay(confOverlay);
    miniHS2 = new MiniHS2.Builder().withRemoteMetastore().withConf(conf).cleanupLocalDirOnStartup(false).build();
    miniHS2.start(confOverlay);
    String tableName = "sslTab";
    Path dataFilePath = new Path(dataFileDir, "kv1.txt");
    // make SSL connection
    hs2Conn = DriverManager.getConnection(miniHS2.getJdbcURL("default", SSL_CONN_PARAMS), System.getProperty("user.name"), "bar");
    // Set up test data
    setupTestTableWithData(tableName, dataFilePath, hs2Conn);
    Statement stmt = hs2Conn.createStatement();
    ResultSet res = stmt.executeQuery("SELECT * FROM " + tableName);
    int rowCount = 0;
    while (res.next()) {
        ++rowCount;
        assertEquals("val_" + res.getInt(1), res.getString(2));
    }
    // read result over SSL
    assertEquals(500, rowCount);
    hs2Conn.close();
}
Also used : Path(org.apache.hadoop.fs.Path) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) MiniHS2(org.apache.hive.jdbc.miniHS2.MiniHS2) Test(org.junit.Test)

Example 15 with MiniHS2

use of org.apache.hive.jdbc.miniHS2.MiniHS2 in project hive by apache.

the class TestBeelinePasswordOption method preTests.

/**
   * Start up a local Hive Server 2 for these tests
   */
@BeforeClass
public static void preTests() throws Exception {
    HiveConf hiveConf = new HiveConf();
    // Set to non-zk lock manager to prevent HS2 from trying to connect
    hiveConf.setVar(HiveConf.ConfVars.HIVE_LOCK_MANAGER, "org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager");
    miniHS2 = new MiniHS2(hiveConf);
    miniHS2.start(new HashMap<String, String>());
    createTable();
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) MiniHS2(org.apache.hive.jdbc.miniHS2.MiniHS2) BeforeClass(org.junit.BeforeClass)

Aggregations

MiniHS2 (org.apache.hive.jdbc.miniHS2.MiniHS2)19 BeforeClass (org.junit.BeforeClass)16 HiveConf (org.apache.hadoop.hive.conf.HiveConf)15 HashMap (java.util.HashMap)8 Path (org.apache.hadoop.fs.Path)6 SessionStateUserAuthenticator (org.apache.hadoop.hive.ql.security.SessionStateUserAuthenticator)5 File (java.io.File)2 URL (java.net.URL)2 Statement (java.sql.Statement)2 SQLStdHiveAuthorizerFactory (org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory)2 Test (org.junit.Test)2 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 MiniClusterType (org.apache.hive.jdbc.miniHS2.MiniHS2.MiniClusterType)1 Before (org.junit.Before)1