sercanCyberVision commented on code in PR #4403:
URL: https://github.com/apache/hive/pull/4403#discussion_r1226683193


##########
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);

Review Comment:
   @deniskuzZ good idea to avoid all the possible conflicts. The test has its 
own `HiveConf`, so I have set `scratchdir` properties as below;
   ```
   String tmpDir = System.getProperty("test.tmp.dir");
   conf.set("hive.exec.scratchdir", tmpDir + "/hive-27317-hdfsscratchdir");
   conf.set("hive.exec.local.scratchdir", tmpDir + 
"/hive-27317-localscratchdir");
   ```
   
   @veghlaci05 about deleting the files/dirs; as the both tmp dirs are specific 
to the test now, I have deleted the both of them after the test;
   ```
   fs.delete(localTmpDir, true);
   fs.delete(scratchDir, true);
   ```
   
   The result is as expected, it creates specified tmp dirs;
   ```
   > ll target/tmp/
   drwxrwxrwx  3 sercan sercan 4096 Jun 12 09:22 hive-27317-hdfsscratchdir/
   drwxrwxrwx  3 sercan sercan 4096 Jun 12 09:22 hive-27317-localscratchdir/
   ```
   and deletes both of them after the test.



-- 
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]

Reply via email to