use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class TestClientSideAuthorizationProvider method testSimplePrivileges.
@Test
public void testSimplePrivileges() throws Exception {
String dbName = getTestDbName();
String tblName = getTestTableName();
String userName = ugi.getUserName();
allowCreateDatabase(userName);
driver.run("create database " + dbName);
Database db = msc.getDatabase(dbName);
String dbLocn = db.getLocationUri();
disallowCreateDatabase(userName);
validateCreateDb(db, dbName);
disallowCreateInDb(dbName, userName, dbLocn);
driver.run("use " + dbName);
try {
driver.run(String.format("create table %s (a string) partitioned by (b string)", tblName));
} catch (CommandProcessorException e) {
// failure from not having permissions to create table
assertNoPrivileges(e);
}
allowCreateInDb(dbName, userName, dbLocn);
driver.run("use " + dbName);
driver.run(String.format("create table %s (a string) partitioned by (b string)", tblName));
Table tbl = msc.getTable(dbName, tblName);
validateCreateTable(tbl, tblName, dbName);
String fakeUser = "mal";
List<String> fakeGroupNames = new ArrayList<String>();
fakeGroupNames.add("groupygroup");
InjectableDummyAuthenticator.injectUserName(fakeUser);
InjectableDummyAuthenticator.injectGroupNames(fakeGroupNames);
InjectableDummyAuthenticator.injectMode(true);
allowSelectOnTable(tbl.getTableName(), fakeUser, tbl.getSd().getLocation());
driver.run(String.format("select * from %s limit 10", tblName));
try {
driver.run(String.format("create table %s (a string) partitioned by (b string)", tblName + "mal"));
} catch (CommandProcessorException e) {
assertNoPrivileges(e);
}
disallowCreateInTbl(tbl.getTableName(), userName, tbl.getSd().getLocation());
try {
driver.run("alter table " + tblName + " add partition (b='2011')");
} catch (CommandProcessorException e) {
assertNoPrivileges(e);
}
InjectableDummyAuthenticator.injectMode(false);
allowCreateInTbl(tbl.getTableName(), userName, tbl.getSd().getLocation());
driver.run("alter table " + tblName + " add partition (b='2011')");
allowDropOnTable(tblName, userName, tbl.getSd().getLocation());
allowDropOnDb(dbName, userName, db.getLocationUri());
driver.run("drop database if exists " + getTestDbName() + " cascade");
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class CompactorTestUtil method executeStatementOnDriverAndReturnResults.
/**
* Execute Hive CLI statement and get back result.
* @param cmd arbitrary statement to execute
* @param driver execution driver
* @return the result of the query
* @throws Exception failed to execute statement
*/
static List<String> executeStatementOnDriverAndReturnResults(String cmd, IDriver driver) throws Exception {
LOG.debug("Executing: " + cmd);
try {
driver.run(cmd);
} catch (CommandProcessorException e) {
throw new IOException("Failed to execute \"" + cmd + "\". Driver returned: " + e);
}
List<String> rs = new ArrayList<>();
driver.setMaxRows(400);
driver.getResults(rs);
return rs;
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class AbstractCoreBlobstoreCliDriver method runTestHelper.
protected void runTestHelper(String tname, String fname, String fpath, boolean expectSuccess) {
long startTime = System.currentTimeMillis();
qt.getConf().set(HCONF_TEST_BLOBSTORE_PATH_UNIQUE, testBlobstorePathUnique);
try {
System.err.println("Begin query: " + fname);
qt.setInputFile(fpath);
qt.cliInit();
try {
qt.executeClient();
if (!expectSuccess) {
qt.failedQuery(null, 0, fname, debugHint);
}
} catch (CommandProcessorException e) {
if (expectSuccess) {
qt.failedQuery(e.getCause(), e.getResponseCode(), fname, debugHint);
}
}
QTestProcessExecResult result = qt.checkCliDriverResults();
if (result.getReturnCode() != 0) {
String message = Strings.isNullOrEmpty(result.getCapturedOutput()) ? debugHint : "\r\n" + result.getCapturedOutput();
qt.failedDiff(result.getReturnCode(), fname, message);
}
} catch (Exception e) {
qt.failedWithException(e, fname, debugHint);
}
long elapsedTime = System.currentTimeMillis() - startTime;
System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
assertTrue("Test passed", true);
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class CoreNegativeCliDriver method runTest.
@Override
public void runTest(String tname, String fname, String fpath) throws Exception {
long startTime = System.currentTimeMillis();
try {
System.err.println("Begin query: " + fname);
qt.setInputFile(fpath);
qt.cliInit();
try {
qt.executeClient();
qt.failed(fname, QTestUtil.DEBUG_HINT);
} catch (CommandProcessorException e) {
// this is the expected outcome
}
QTestProcessExecResult result = qt.checkCliDriverResults();
if (result.getReturnCode() != 0) {
String message = Strings.isNullOrEmpty(result.getCapturedOutput()) ? QTestUtil.DEBUG_HINT : "\r\n" + result.getCapturedOutput();
qt.failedDiff(result.getReturnCode(), fname, message);
}
} catch (AssumptionViolatedException e) {
throw e;
} catch (Error error) {
QTestProcessExecResult qTestProcessExecResult = qt.checkNegativeResults(fname, error);
if (qTestProcessExecResult.getReturnCode() != 0) {
String message = Strings.isNullOrEmpty(qTestProcessExecResult.getCapturedOutput()) ? QTestUtil.DEBUG_HINT : "\r\n" + qTestProcessExecResult.getCapturedOutput();
qt.failedDiff(qTestProcessExecResult.getReturnCode(), fname, message);
}
} catch (Exception e) {
qt.failedWithException(e, fname, QTestUtil.DEBUG_HINT);
}
long elapsedTime = System.currentTimeMillis() - startTime;
System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
assertTrue("Test passed", true);
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class CoreKuduNegativeCliDriver method runTest.
@Override
public void runTest(String tname, String fname, String fpath) {
long startTime = System.currentTimeMillis();
try {
System.err.println("Begin query: " + fname);
qt.setInputFile(fpath);
qt.cliInit();
try {
qt.executeClient();
qt.failed(fname, null);
} catch (CommandProcessorException e) {
// this is the expected behaviour
}
QTestProcessExecResult result = qt.checkCliDriverResults();
if (result.getReturnCode() != 0) {
qt.failedDiff(result.getReturnCode(), fname, result.getCapturedOutput());
}
} catch (Exception e) {
qt.failedWithException(e, fname, null);
}
long elapsedTime = System.currentTimeMillis() - startTime;
System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
assertTrue("Test passed", true);
}
Aggregations