Github user sohami commented on a diff in the pull request: https://github.com/apache/drill/pull/753#discussion_r102585253 --- Diff: exec/java-exec/src/test/java/org/apache/drill/test/ClusterFixture.java --- @@ -295,8 +396,96 @@ public void close() throws Exception { if (ex != null) { throw ex; } + + // Delete any local files, if we wrote to the local + // persistent store. But, leave the files if the user wants + // to review them, for debugging, say. Note that, even if the + // files are preserved here, they will be removed when the + // next cluster fixture starts, else the CTTAS initialization + // will fail. + + if (! preserveLocalFiles) { + try { + removeLocalFiles(); + } catch (Exception e) { + ex = ex == null ? e : ex; + } + } + + // Remove temporary directories created for this cluster session. + + try { + removeTempDirs(); + } catch (Exception e) { + ex = ex == null ? e : ex; + } } + /** + * Removes files stored locally in the "local store provider." + * Required because CTTAS setup fails if these files are left from one + * run to the next. + * + * @throws IOException if a directory cannot be deleted + */ + + private void removeLocalFiles() throws IOException { + + // Don't delete if this is not a local Drillbit. + + if (! isLocal) { + return; + } + + // Don't delete if we did not write. + + if (! config.getBoolean(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE)) { + return; + } + + // Remove the local files if they exist. + + String localStoreLocation = config.getString(ExecConstants.SYS_STORE_PROVIDER_LOCAL_PATH); + File storeDir = new File(localStoreLocation); + if (! storeDir.exists()) { + return; + } + if (storeDir.exists()) { --- End diff -- Check not needed since we are already checking above. Also we can directly use the `removeDir` method below.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---