[ 
https://issues.apache.org/jira/browse/BOOKKEEPER-814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

zhaijia updated BOOKKEEPER-814:
-------------------------------
    Attachment: BOOKKEEPER-814.patch

Here is the patch.
The test class, which not delete tmp dir, is got By searching the /tmp dir, and 
surefire-reports.

In most of the error, tmp file is managed as this below, and not deleted at the 
end:
{code:title=Bar.java|borderStyle=solid}
      File tmpDir = File.createTempFile("bookie", "test");
      tmpDir.delete();
      tmpDir.mkdir();
{code}

The fix is more or less like this, using a List to record the tmpdirs, and 
remove them at @After func:
{code:title=Bar.java|borderStyle=solid}
    final List<File> tempDirs = new ArrayList<File>();

    File createTempDir(String prefix, String suffix) throws IOException {
        File dir = IOUtils.createTempDir(prefix, suffix);
        tempDirs.add(dir);
        return dir;
    }

    @After
    public void tearDown() throws Exception {
        for (File dir : tempDirs) {
            FileUtils.deleteDirectory(dir);
        }
        tempDirs.clear();
    }
{code}



> clean up temp files that generated by test cases.
> -------------------------------------------------
>
>                 Key: BOOKKEEPER-814
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-814
>             Project: Bookkeeper
>          Issue Type: Bug
>          Components: bookkeeper-server
>    Affects Versions: 4.3.0, 4.4.0
>            Reporter: zhaijia
>            Assignee: zhaijia
>             Fix For: 4.4.0
>
>         Attachments: BOOKKEEPER-814.patch
>
>   Original Estimate: 72h
>  Remaining Estimate: 72h
>
> Currently some of bookkeeper test cases are using temp files for unit tests. 
> Those temp files aren't cleaned up after unit tests finished. 
> If running several times of these test cases, /tmp directory will soon be 
> full.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to