Search in sources :

Example 6 with ScheduledQueryExecutionService

use of org.apache.hadoop.hive.ql.scheduled.ScheduledQueryExecutionService in project hive by apache.

the class TestScheduledQueryIntegration method testScheduledQueryExecutionImpersonation.

@Test
public void testScheduledQueryExecutionImpersonation() throws ParseException, Exception {
    envSetup.getTestCtx().hiveConf.setVar(HiveConf.ConfVars.HIVE_SCHEDULED_QUERIES_EXECUTOR_IDLE_SLEEP_TIME, "1s");
    envSetup.getTestCtx().hiveConf.setVar(HiveConf.ConfVars.HIVE_SCHEDULED_QUERIES_EXECUTOR_PROGRESS_REPORT_INTERVAL, "1s");
    setupAuthorization();
    try (ScheduledQueryExecutionService schqS = ScheduledQueryExecutionService.startScheduledQueryExecutorService(envSetup.getTestCtx().hiveConf)) {
        runAsUser("user1", "create scheduled query s1 cron '* * * * * ? *' defined as create table tx1 as select 12 as i", true);
        Thread.sleep(20000);
    }
    // table exists - and owner is able to select from it
    runAsUser("user1", "select * from tx1");
    // other user can't drop it
    try {
        runAsUser("user2", "drop table tx1");
        fail("should have failed");
    } catch (CommandProcessorException cpe) {
        assertEquals(40000, cpe.getResponseCode());
    }
    // but the owner can drop it
    runAsUser("user1", "drop table tx1");
}
Also used : CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) ScheduledQueryExecutionService(org.apache.hadoop.hive.ql.scheduled.ScheduledQueryExecutionService) Test(org.junit.Test)

Aggregations

ScheduledQueryExecutionService (org.apache.hadoop.hive.ql.scheduled.ScheduledQueryExecutionService)6 Test (org.junit.Test)6 FileSystem (org.apache.hadoop.fs.FileSystem)4 Path (org.apache.hadoop.fs.Path)4 Ignore (org.junit.Ignore)4 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 Database (org.apache.hadoop.hive.metastore.api.Database)1 IDriver (org.apache.hadoop.hive.ql.IDriver)1 DumpMetaData (org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData)1 ReplicationMetric (org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric)1 CommandProcessorException (org.apache.hadoop.hive.ql.processors.CommandProcessorException)1 ScheduledQueryExecutionContext (org.apache.hadoop.hive.ql.scheduled.ScheduledQueryExecutionContext)1