use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestHCatStorerMulti method setUp.
@Before
public void setUp() throws Exception {
assumeTrue(!TestUtil.shouldSkip(storageFormat, DISABLED_STORAGE_FORMATS));
if (driver == null) {
HiveConf hiveConf = new HiveConf(this.getClass());
hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, TEST_WAREHOUSE_DIR);
hiveConf.setVar(HiveConf.ConfVars.HIVEMAPREDMODE, "nonstrict");
hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
driver = DriverFactory.newDriver(hiveConf);
SessionState.start(new CliSessionState(hiveConf));
}
cleanup();
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestCLIAuthzSessionContext method beforeTest.
@BeforeClass
public static void beforeTest() throws Exception {
HiveConf conf = new HiveConf();
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER, MockedHiveAuthorizerFactory.class.getName());
conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER, SessionStateUserAuthenticator.class.getName());
conf.setBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
// once SessionState for thread is set, CliDriver picks conf from it
CliSessionState ss = new CliSessionState(conf);
ss.err = new SessionStream(System.err);
ss.out = new SessionStream(System.out);
SessionState.start(ss);
TestCLIAuthzSessionContext.driver = new CliDriver();
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestMetastoreVersion method testMetastoreVersion.
/**
* Test that with no verification, and record verification enabled, hive populates the schema
* and version correctly
* @throws Exception
*/
@Test
public void testMetastoreVersion() throws Exception {
// let the schema and version be auto created
System.setProperty(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString(), "false");
System.setProperty(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION_RECORD_VERSION.toString(), "true");
hiveConf = new HiveConf(this.getClass());
SessionState.start(new CliSessionState(hiveConf));
driver = DriverFactory.newDriver(hiveConf);
try {
driver.run("show tables");
assert false;
} catch (CommandProcessorException e) {
// this is expected
}
// correct version stored by Metastore during startup
assertEquals(metastoreSchemaInfo.getHiveSchemaVersion(), getVersion(hiveConf));
setVersion(hiveConf, "foo");
assertEquals("foo", getVersion(hiveConf));
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestMetastoreVersion method testVersionMisMatch.
/**
* Store garbage version in metastore and verify that hive fails when verification is on
* @throws Exception
*/
@Test
public void testVersionMisMatch() throws Exception {
System.setProperty(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString(), "false");
hiveConf = new HiveConf(this.getClass());
SessionState.start(new CliSessionState(hiveConf));
driver = DriverFactory.newDriver(hiveConf);
driver.run("show tables");
ObjectStore.setSchemaVerified(false);
System.setProperty(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString(), "true");
hiveConf = new HiveConf(this.getClass());
setVersion(hiveConf, "fooVersion");
SessionState.start(new CliSessionState(hiveConf));
driver = DriverFactory.newDriver(hiveConf);
try {
driver.run("show tables");
assert false;
} catch (CommandProcessorException e) {
// this is expected
}
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestMetastoreVersion method testVersionRestriction.
/**
* Test schema verification property
* @throws Exception
*/
@Test
public void testVersionRestriction() throws Exception {
System.setProperty(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString(), "true");
hiveConf = new HiveConf(this.getClass());
assertTrue(hiveConf.getBoolVar(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION));
assertFalse(hiveConf.getBoolVar(HiveConf.ConfVars.METASTORE_AUTO_CREATE_ALL));
// session creation should fail since the schema didn't get created
try {
SessionState.start(new CliSessionState(hiveConf));
Hive.get(hiveConf).getMSC();
fail("An exception is expected since schema is not created.");
} catch (Exception re) {
LOG.info("Exception in testVersionRestriction: " + re, re);
String msg = HiveStringUtils.stringifyException(re);
assertTrue("Expected 'Version information not found in metastore' in: " + msg, msg.contains("Version information not found in metastore"));
}
}
Aggregations