abstractdog commented on code in PR #6161:
URL: https://github.com/apache/hive/pull/6161#discussion_r2613188830
##########
ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestTezSessionState.java:
##########
@@ -50,4 +57,37 @@ public void testSymlinkedLocalFilesAreLocalizedOnce() throws
Exception {
// local resources point to the same original resource
Assert.assertEquals(l1.getResource().toPath(), l2.getResource().toPath());
}
+
+ @Test
+ public void testScratchDirDeletedInTheEventOfExceptionWhileOpeningSession()
throws Exception {
+ HiveConf hiveConf = new HiveConfForTest(getClass());
+ hiveConf.set("hive.security.authorization.manager",
+
"org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdConfOnlyAuthorizerFactory");
+ SessionState.start(hiveConf);
+
+ final AtomicReference<String> scratchDirPath = new AtomicReference<>();
+
+ TezSessionState sessionState = new
TezSessionState(SessionState.get().getSessionId(), hiveConf) {
+ @Override
+ void openInternalUnsafe(boolean isAsync, SessionState.LogHelper console)
throws TezException, IOException {
+ super.openInternalUnsafe(isAsync, console);
+ // save scratch dir here as it's nullified while calling the cleanup
+ scratchDirPath.set(tezScratchDir.toUri().getPath());
+ throw new RuntimeException("fake exception in openInternalUnsafe");
+ }
+ };
+
+ TezSessionState.HiveResources resources =
+ new TezSessionState.HiveResources(new
org.apache.hadoop.fs.Path("/tmp"));
+
+ try {
+ sessionState.open(resources);
+ Assert.fail("An exception should have been thrown while calling
openInternal");
+ } catch (Exception e) {
+ Assert.assertTrue(e.getMessage().equalsIgnoreCase("fake exception in
openInternalUnsafe"));
Review Comment:
btw, I just changed this to this below, looks better
```
- Assert.assertTrue(e.getMessage().equalsIgnoreCase("fake exception in
openInternalUnsafe"));
+ Assert.assertEquals("fake exception in openInternalUnsafe",
e.getMessage());
```
--
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]