Kafka
  1. Kafka
  2. KAFKA-1258

Delete temporary data directory after unit test finishes

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.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.

      1. KAFKA-1258.patch
        0.6 kB
        Manikumar Reddy

        Activity

        Hide
        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
        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
        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
        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
        Manikumar Reddy added a comment -

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

        Show
        Manikumar Reddy added a comment - Created reviewboard https://reviews.apache.org/r/23439/diff/ against branch origin/trunk
        Hide
        Manikumar Reddy 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
        Manikumar Reddy 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
        Jay Kreps added a comment -

        Committed. Thanks!

        Show
        Jay Kreps added a comment - Committed. Thanks!

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development