conf.set("hive.exec.scratchdir", tmpDir + "/hs2");
// Set a scratch dir permission
String fsPermissionStr = "700";
conf.set("hive.scratch.dir.permission", fsPermissionStr);
// Start an instance of HiveServer2 which uses miniMR
miniHS2 = new MiniHS2(conf);
Map<String, String> confOverlay = new HashMap<String, String>();
miniHS2.start(confOverlay);
userName = System.getProperty("user.name");
hs2Conn = getConnection(miniHS2.getJdbcURL(), userName, "password");
// FS
FileSystem fs = miniHS2.getLocalFS();
FsPermission expectedFSPermission = new FsPermission(HiveConf.getVar(conf,
HiveConf.ConfVars.SCRATCHDIRPERMISSION));
// Verify scratch dir paths and permission
// HDFS scratch dir
scratchDirPath = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIR) + "/" + userName);
verifyScratchDir(conf, fs, scratchDirPath, expectedFSPermission, userName, false);
// Local scratch dir
scratchDirPath = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.LOCALSCRATCHDIR));
verifyScratchDir(conf, fs, scratchDirPath, expectedFSPermission, userName, true);
// Downloaded resources dir
scratchDirPath = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.DOWNLOADED_RESOURCES_DIR));
verifyScratchDir(conf, fs, scratchDirPath, expectedFSPermission, userName, true);
// 2. Test with doAs=true
// Restart HiveServer2 with doAs=true
if (miniHS2.isStarted()) {
miniHS2.stop();
}
conf.setBoolean("hive.server2.enable.doAs", true);
// Start HS2
miniHS2 = new MiniHS2(conf);
miniHS2.start(confOverlay);
// Test for user "neo"
userName = "neo";
hs2Conn = getConnection(miniHS2.getJdbcURL(), userName, "the-one");