deniskuzZ commented on code in PR #6161:
URL: https://github.com/apache/hive/pull/6161#discussion_r2593966058
##########
ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestTezSessionState.java:
##########
@@ -50,4 +57,38 @@ 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");
+ }
+ };
+
+ SessionState.LogHelper console = new
SessionState.LogHelper(LoggerFactory.getLogger("TestTezSessionState"));
+ TezSessionState.HiveResources resources =
+ new TezSessionState.HiveResources(new
org.apache.hadoop.fs.Path("/tmp"));
+
+ try {
+ sessionState.openInternal(null, false, console, resources);
Review Comment:
could we use `sessionState.open(resources)` ?
--
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]