sercanCyberVision commented on code in PR #4403:
URL: https://github.com/apache/hive/pull/4403#discussion_r1225599590
##########
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/session/TestClearDanglingScratchDir.java:
##########
@@ -129,4 +132,68 @@ public void testClearDanglingScratchDir() throws Exception
{
Assert.assertEquals(StringUtils.countMatches(stderr.toString(),
"removed"), 1);
ss.close();
}
+
+ /**
+ * Testing behaviour of ClearDanglingScratchDir service over local tmp
files/dirs
+ * @throws Exception
+ */
+ @Test
+ public void testLocalDanglingFilesCleaning() throws Exception {
+ HiveConf conf = new HiveConf();
+ conf.set("fs.default.name", "file:///");
+ FileSystem fs = FileSystem.get(conf);
+
+ // constants
+ String appId = "appId_" + System.currentTimeMillis();
+ String userName = System.getProperty("user.name");
+ String hdfs = "hdfs";
+ String inuse = "inuse.lck";
+ String l = File.separator;
+
+ // simulating hdfs dangling dir and its inuse.lck file
+ // Note: Give scratch dirs all the write permissions
+ FsPermission allPermissions = new FsPermission((short)00777);
+ Path scratchDir = new Path(HiveConf.getVar(conf,
HiveConf.ConfVars.SCRATCHDIR));
+ Utilities.createDirsWithPermission(conf, scratchDir, allPermissions, true);
+ Path hdfsRootDir = new Path(scratchDir + l + userName + l + hdfs);
+ Path hdfsSessionDir = new Path(hdfsRootDir + l + userName + l + appId);
+ Path hdfsSessionLock = new Path(hdfsSessionDir + l + inuse);
+ fs.create(hdfsSessionLock);
+
+ // simulating local dangling files
+ String localTmpDir = HiveConf.getVar(conf,
HiveConf.ConfVars.LOCALSCRATCHDIR);
+ Path localSessionDir = new Path(localTmpDir + l + appId);
+ Path localPipeOutFileRemove = new Path(localTmpDir + l
+ + appId + "-started-with-session-name.pipeout");
+ Path localPipeOutFileNotRemove = new Path(localTmpDir + l
+ + "not-started-with-session-name-" + appId + ".pipeout");
+ Path localPipeOutFileFailRemove = new Path(localTmpDir + l
+ + appId + "-started-with-session-name-but-fail-delete.pipeout");
+
+ // Create dirs/files
+ Utilities.createDirsWithPermission(conf, localSessionDir, allPermissions,
true);
Review Comment:
Local scratchdir is all writable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]