Hadoop HDFS
  1. Hadoop HDFS
  2. HDFS-530

Refactor TestFileAppend* to remove code duplications

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.21.0
    • Component/s: test
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      Clearly, TestFileAppend* were created in a copy-cat mode which produces a number of duplications.
      As more tests for the new append feature are going to be developed, I'd like to get rid of these duplications and allow some a better code reuse.

      1. HDFS-530.patch
        21 kB
        Konstantin Boudnik
      2. HDFS-530.patch
        18 kB
        Konstantin Boudnik
      3. HDFS-530.patch
        18 kB
        Konstantin Boudnik

        Activity

        Hide
        Konstantin Boudnik added a comment -
        • few common methods are moved to AppendTestUtil class to reduce code duplication; side effects in some methods are replaced with adequate return types
        • some common declarations are moved to AppendTestUtil and converted to constants
        • a potential synchronization problem is addressed by declaring a synchronized object final
          -  ArrayList<Path> testFiles = new ArrayList<Path>();
          +  final ArrayList<Path> testFiles = new ArrayList<Path>();
          
        • JavaDoc warnings are fixed
        • code redundancies are fixed here and there. I.e.
          -                   dataset.detachBlock(b, 1) == false);
          +            !dataset.detachBlock(b, 1));
          
        • a bit of performance optimization is done
        Show
        Konstantin Boudnik added a comment - few common methods are moved to AppendTestUtil class to reduce code duplication; side effects in some methods are replaced with adequate return types some common declarations are moved to AppendTestUtil and converted to constants a potential synchronization problem is addressed by declaring a synchronized object final - ArrayList<Path> testFiles = new ArrayList<Path>(); + final ArrayList<Path> testFiles = new ArrayList<Path>(); JavaDoc warnings are fixed code redundancies are fixed here and there. I.e. - dataset.detachBlock(b, 1) == false); + !dataset.detachBlock(b, 1)); a bit of performance optimization is done
        Hide
        gary murry added a comment -

        +1 the patch looks good.

        Show
        gary murry added a comment - +1 the patch looks good.
        Hide
        Konstantin Boudnik added a comment -

        One more common method is pulled to AppendTestIUtil.

        Local execution of test-patch seems to be Ok

        +1 overall.
        
            +1 @author.  The patch does not contain any @author tags.
        
            +1 tests included.  The patch appears to include 12 new or modified tests.
        
            +1 javadoc.  The javadoc tool did not generate any warning messages.
        
            +1 javac.  The applied patch does not increase the total number of javac compiler warnings.
        
            +1 findbugs.  The patch does not introduce any new Findbugs warnings.
        
            +1 release audit.  The applied patch does not increase the total number of release audit warnings.
        
        Show
        Konstantin Boudnik added a comment - One more common method is pulled to AppendTestIUtil. Local execution of test-patch seems to be Ok +1 overall. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 12 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings.
        Hide
        Tsz Wo Nicholas Sze added a comment -

        For this issue, I think we only has to run the tests affected since this is a test code refactoring.

        Show
        Tsz Wo Nicholas Sze added a comment - For this issue, I think we only has to run the tests affected since this is a test code refactoring.
        Hide
        Konstantin Boudnik added a comment -

        Yet another redundant method is removed.

        Affected tests are passing:

        run-test-hdfs:
            [junit] Running org.apache.hadoop.hdfs.TestFileAppend
            [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 13.682 sec
            [junit] Running org.apache.hadoop.hdfs.TestFileAppend2
            [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 110.166 sec
            [junit] Running org.apache.hadoop.hdfs.TestFileAppend3
            [junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 16.689 sec
        
        checkfailure:
        
        BUILD SUCCESSFUL
        
        Show
        Konstantin Boudnik added a comment - Yet another redundant method is removed. Affected tests are passing: run-test-hdfs: [junit] Running org.apache.hadoop.hdfs.TestFileAppend [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 13.682 sec [junit] Running org.apache.hadoop.hdfs.TestFileAppend2 [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 110.166 sec [junit] Running org.apache.hadoop.hdfs.TestFileAppend3 [junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 16.689 sec checkfailure: BUILD SUCCESSFUL
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12415693/HDFS-530.patch
        against trunk revision 801500.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 12 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/testReport/
        Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Checkstyle results: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/artifact/trunk/build/test/checkstyle-errors.html
        Console output: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12415693/HDFS-530.patch against trunk revision 801500. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 12 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/testReport/ Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Checkstyle results: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/artifact/trunk/build/test/checkstyle-errors.html Console output: http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-vesta.apache.org/46/console This message is automatically generated.
        Hide
        Tsz Wo Nicholas Sze added a comment -

        I have committed this. Thanks, Cos!

        Show
        Tsz Wo Nicholas Sze added a comment - I have committed this. Thanks, Cos!
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Hdfs-trunk #42 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Hdfs-trunk/42/)
        . Refactor TestFileAppend* to remove code duplication. Contributed by Konstantin Boudnik

        Show
        Hudson added a comment - Integrated in Hadoop-Hdfs-trunk #42 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Hdfs-trunk/42/ ) . Refactor TestFileAppend* to remove code duplication. Contributed by Konstantin Boudnik

          People

          • Assignee:
            Konstantin Boudnik
            Reporter:
            Konstantin Boudnik
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development