Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-1258

Delete temporary data directory after unit test finishes

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.8.2.0
    • Component/s: None
    • Labels:

      Description

      Today in unit testsuite most of the time when a test case is setup a temporary directory will be created with a random int as suffix, and will not be deleted after the test. After a few unit tests this will create tons of directories in java.io.tmpdir (/tmp for Linux). Would be better to remove them for clean unit tests.

        Activity

        Hide
        jkreps Jay Kreps added a comment -

        Yeah this annoys me too. The core problem is that java provides File.deleteOnExit but this doesn't work for directories. Instead what we should do is change TestUtils.createTempDir to add a shutdown hook that deletes the directory recursively.

        Show
        jkreps Jay Kreps added a comment - Yeah this annoys me too. The core problem is that java provides File.deleteOnExit but this doesn't work for directories. Instead what we should do is change TestUtils.createTempDir to add a shutdown hook that deletes the directory recursively.
        Hide
        sriramsub Sriram Subramanian added a comment -

        Look into http://junit.org/javadoc/4.9/org/junit/rules/TemporaryFolder.html. Helps to manage temp folders in junit. It may be supported only in java 7.

        Show
        sriramsub Sriram Subramanian added a comment - Look into http://junit.org/javadoc/4.9/org/junit/rules/TemporaryFolder.html . Helps to manage temp folders in junit. It may be supported only in java 7.
        Hide
        omkreddy Manikumar added a comment -

        Created reviewboard https://reviews.apache.org/r/23439/diff/
        against branch origin/trunk

        Show
        omkreddy Manikumar added a comment - Created reviewboard https://reviews.apache.org/r/23439/diff/ against branch origin/trunk
        Hide
        omkreddy Manikumar added a comment -

        Junit 4.7 can be used to manage temporary folders. But this requires
        changes in all the test cases and some base test classes.

        Submitted patch by adding shutdown hook to TestUtils.tempDir method.

        Show
        omkreddy Manikumar added a comment - Junit 4.7 can be used to manage temporary folders. But this requires changes in all the test cases and some base test classes. Submitted patch by adding shutdown hook to TestUtils.tempDir method.
        Hide
        jkreps Jay Kreps added a comment -

        Committed. Thanks!

        Show
        jkreps Jay Kreps added a comment - Committed. Thanks!

          People

          • Assignee:
            omkreddy Manikumar
            Reporter:
            guozhang Guozhang Wang
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development