use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestStorageBasedMetastoreAuthorizationDrops method dropPartitionByOtherUser.
/**
* @param perm permissions for table dir
* @param expectedRet expected return code
* @throws Exception
*/
public void dropPartitionByOtherUser(String perm, int expectedRet) throws Exception {
String dbName = getTestDbName();
String tblName = getTestTableName();
setPermissions(clientHiveConf.getVar(ConfVars.METASTOREWAREHOUSE), "-rwxrwxrwx");
CommandProcessorResponse resp = driver.run("create database " + dbName);
Assert.assertEquals(0, resp.getResponseCode());
Database db = msc.getDatabase(dbName);
validateCreateDb(db, dbName);
setPermissions(db.getLocationUri(), "-rwxrwxrwx");
String dbDotTable = dbName + "." + tblName;
resp = driver.run("create table " + dbDotTable + "(i int) partitioned by (b string)");
Assert.assertEquals(0, resp.getResponseCode());
Table tab = msc.getTable(dbName, tblName);
setPermissions(tab.getSd().getLocation(), perm);
resp = driver.run("alter table " + dbDotTable + " add partition (b='2011')");
Assert.assertEquals(0, resp.getResponseCode());
InjectableDummyAuthenticator.injectMode(true);
resp = driver.run("alter table " + dbDotTable + " drop partition (b='2011')");
Assert.assertEquals(expectedRet, resp.getResponseCode());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestStorageBasedMetastoreAuthorizationReads method testCmd.
private void testCmd(Driver driver, String cmd, boolean isSuccess) throws CommandNeedRetryException {
CommandProcessorResponse resp = driver.run(cmd);
Assert.assertEquals(isSuccess, resp.getResponseCode() == 0);
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestDbTxnManager2 method testShowLocksAgentInfo.
@Test
public void testShowLocksAgentInfo() throws Exception {
CommandProcessorResponse cpr = driver.run("create table if not exists XYZ (a int, b int)");
checkCmdOnDriver(cpr);
checkCmdOnDriver(driver.compileAndRespond("select a from XYZ where b = 8"));
txnMgr.acquireLocks(driver.getPlan(), ctx, "XYZ");
List<ShowLocksResponseElement> locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 1, locks.size());
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "XYZ", null, locks);
Assert.assertEquals("Wrong AgentInfo", driver.getPlan().getQueryId(), locks.get(0).getAgentInfo());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class FolderPermissionBase method testExternalTable.
@Test
public void testExternalTable() throws Exception {
String tableName = "externaltable";
String myLocation = warehouseDir + "/myfolder";
FileSystem fs = FileSystem.get(new URI(myLocation), conf);
fs.mkdirs(new Path(myLocation));
setPermission(myLocation);
CommandProcessorResponse ret = driver.run("CREATE TABLE " + tableName + " (key string, value string) LOCATION '" + myLocation + "'");
Assert.assertEquals(0, ret.getResponseCode());
ret = driver.run("insert into table " + tableName + " select key,value from mysrc");
Assert.assertEquals(0, ret.getResponseCode());
Assert.assertTrue(listStatus(myLocation).size() > 0);
for (String child : listStatus(myLocation)) {
verifyPermission(child);
}
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class FolderPermissionBase method testTruncateTable.
/**
* Tests the permission to the table doesn't change after the truncation
* @throws Exception
*/
@Test
public void testTruncateTable() throws Exception {
String tableName = "truncatetable";
String partition = warehouseDir + "/" + tableName + "/part1=1";
CommandProcessorResponse ret = driver.run("CREATE TABLE " + tableName + " (key STRING, value STRING) PARTITIONED BY (part1 INT)");
Assert.assertEquals(0, ret.getResponseCode());
setPermission(warehouseDir + "/" + tableName);
ret = driver.run("insert into table " + tableName + " partition(part1='1') select key,value from mysrc where part1='1' and part2='1'");
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(warehouseDir + "/" + tableName);
verifyPermission(warehouseDir + "/" + tableName);
verifyPermission(partition);
ret = driver.run("TRUNCATE TABLE " + tableName);
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(warehouseDir + "/" + tableName);
verifyPermission(warehouseDir + "/" + tableName);
ret = driver.run("insert into table " + tableName + " partition(part1='1') select key,value from mysrc where part1='1' and part2='1'");
Assert.assertEquals(0, ret.getResponseCode());
verifyPermission(warehouseDir + "/" + tableName);
assertExistence(partition);
verifyPermission(partition);
// Also test the partition folder if the partition is truncated
ret = driver.run("TRUNCATE TABLE " + tableName + " partition(part1='1')");
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(partition);
verifyPermission(partition);
}
Aggregations