Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.0, 3.0.0-alpha2
    • Component/s: test
    • Labels:
      None
    • Target Version/s:
    • Hadoop Flags:
      Reviewed

      Description

      Saw this failure in an internal build. Reran the test 30 times and it failed once with the same type of failure.

      org.junit.ComparisonFailure: Unexpected -stat output: 2016-09-30 03:48:56
      2016-09-30 03:48:57
       expected:<...6
      2016-09-30 03:48:5[7]
      > but was:<...6
      2016-09-30 03:48:5[6]
      >
      	at org.junit.Assert.assertEquals(Assert.java:115)
      	at org.apache.hadoop.hdfs.TestDFSShell.testStat(TestDFSShell.java:2082)
      
      1. HDFS-10934.001.patch
        1 kB
        Eric Badger
      2. HDFS-10934.002.patch
        1 kB
        Eric Badger

        Issue Links

          Activity

          Hide
          ebadger Eric Badger added a comment -

          After talking offline with Daryn Sharp, we came to the conclusion that the test isn't completely valid. The test creates a file and stores the modification time. Then they do a stat on the directory to make sure that the times are the same. However, the file is closed in between those two things happening and so the file modification time is updated. Closing the file doesn't update the modification time on the directory, so the times are not the same.

          I'm attaching a patch that creates a file, but leaves it open. This way the modification time of the file will be the same of the modification time of the directory.

          cc Mingliang Liu

          Show
          ebadger Eric Badger added a comment - After talking offline with Daryn Sharp , we came to the conclusion that the test isn't completely valid. The test creates a file and stores the modification time. Then they do a stat on the directory to make sure that the times are the same. However, the file is closed in between those two things happening and so the file modification time is updated. Closing the file doesn't update the modification time on the directory, so the times are not the same. I'm attaching a patch that creates a file, but leaves it open. This way the modification time of the file will be the same of the modification time of the directory. cc Mingliang Liu
          Hide
          hadoopqa Hadoop QA added a comment -
          +1 overall



          Vote Subsystem Runtime Comment
          0 reexec 0m 16s Docker mode activated.
          +1 @author 0m 0s The patch does not contain any @author tags.
          +1 test4tests 0m 0s The patch appears to include 1 new or modified test files.
          +1 mvninstall 7m 28s trunk passed
          +1 compile 0m 49s trunk passed
          +1 checkstyle 0m 37s trunk passed
          +1 mvnsite 1m 8s trunk passed
          +1 mvneclipse 0m 15s trunk passed
          +1 findbugs 2m 9s trunk passed
          +1 javadoc 1m 6s trunk passed
          +1 mvninstall 1m 0s the patch passed
          +1 compile 0m 54s the patch passed
          +1 javac 0m 54s the patch passed
          +1 checkstyle 0m 31s the patch passed
          +1 mvnsite 1m 5s the patch passed
          +1 mvneclipse 0m 12s the patch passed
          +1 whitespace 0m 0s The patch has no whitespace issues.
          +1 findbugs 2m 14s the patch passed
          +1 javadoc 1m 3s the patch passed
          +1 unit 67m 9s hadoop-hdfs in the patch passed.
          +1 asflicense 0m 20s The patch does not generate ASF License warnings.
          89m 53s



          Subsystem Report/Notes
          Docker Image:yetus/hadoop:9560f25
          JIRA Issue HDFS-10934
          JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12831125/HDFS-10934.001.patch
          Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle
          uname Linux 45dcd1d8f378 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
          Build tool maven
          Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh
          git revision trunk / 0670149
          Default Java 1.8.0_101
          findbugs v3.0.0
          Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/16945/testReport/
          modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
          Console output https://builds.apache.org/job/PreCommit-HDFS-Build/16945/console
          Powered by Apache Yetus 0.4.0-SNAPSHOT http://yetus.apache.org

          This message was automatically generated.

          Show
          hadoopqa Hadoop QA added a comment - +1 overall Vote Subsystem Runtime Comment 0 reexec 0m 16s Docker mode activated. +1 @author 0m 0s The patch does not contain any @author tags. +1 test4tests 0m 0s The patch appears to include 1 new or modified test files. +1 mvninstall 7m 28s trunk passed +1 compile 0m 49s trunk passed +1 checkstyle 0m 37s trunk passed +1 mvnsite 1m 8s trunk passed +1 mvneclipse 0m 15s trunk passed +1 findbugs 2m 9s trunk passed +1 javadoc 1m 6s trunk passed +1 mvninstall 1m 0s the patch passed +1 compile 0m 54s the patch passed +1 javac 0m 54s the patch passed +1 checkstyle 0m 31s the patch passed +1 mvnsite 1m 5s the patch passed +1 mvneclipse 0m 12s the patch passed +1 whitespace 0m 0s The patch has no whitespace issues. +1 findbugs 2m 14s the patch passed +1 javadoc 1m 3s the patch passed +1 unit 67m 9s hadoop-hdfs in the patch passed. +1 asflicense 0m 20s The patch does not generate ASF License warnings. 89m 53s Subsystem Report/Notes Docker Image:yetus/hadoop:9560f25 JIRA Issue HDFS-10934 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12831125/HDFS-10934.001.patch Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle uname Linux 45dcd1d8f378 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Build tool maven Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh git revision trunk / 0670149 Default Java 1.8.0_101 findbugs v3.0.0 Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/16945/testReport/ modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs Console output https://builds.apache.org/job/PreCommit-HDFS-Build/16945/console Powered by Apache Yetus 0.4.0-SNAPSHOT http://yetus.apache.org This message was automatically generated.
          Hide
          liuml07 Mingliang Liu added a comment -

          Eric Badger, it's a nice catch! I think the patch will fix this.

          I then realized that perhaps I should not rely on the assumption mtime1 == mtime2 in the first place. We simple mkdir, create file (and close it), get file status, get dir status, and do the assertions against respective mtime. The file status and dir status are free to be different. This way, the test code is more straightforward and a bit easier to read/maintain. Any thoughts? Thanks.

          Show
          liuml07 Mingliang Liu added a comment - Eric Badger , it's a nice catch! I think the patch will fix this. I then realized that perhaps I should not rely on the assumption mtime1 == mtime2 in the first place. We simple mkdir, create file (and close it), get file status, get dir status, and do the assertions against respective mtime. The file status and dir status are free to be different. This way, the test code is more straightforward and a bit easier to read/maintain. Any thoughts? Thanks.
          Hide
          ebadger Eric Badger added a comment -

          I then realized that perhaps I should not rely on the assumption mtime1 == mtime2 in the first place.

          Mingliang Liu, if I'm reading the test correctly, the test never checks that mtime1 == mtime2. It calls doFsStat() on both the file and directory, but checks the directory time against mtime1 and then the file against mtime2. I agree that the file status and directory status are generally free to be different, which is why I kept the file open so that they would be equal in this case (file created in directory, no other operations). It was slightly peculiar to me that we were testing the modification time of the directory (mtime2) against the modification time of the file, but it works in this contrived case.

          The easier way to fix this test would be to change testDir1 to testFile2 in the following line

          final FileStatus status2 = dfs.getFileStatus(testDir1);
          

          It no longer tests that the directory gets modified when a file is created, but I don't believe that is the goal of this test.

          Show
          ebadger Eric Badger added a comment - I then realized that perhaps I should not rely on the assumption mtime1 == mtime2 in the first place. Mingliang Liu , if I'm reading the test correctly, the test never checks that mtime1 == mtime2 . It calls doFsStat() on both the file and directory, but checks the directory time against mtime1 and then the file against mtime2. I agree that the file status and directory status are generally free to be different, which is why I kept the file open so that they would be equal in this case (file created in directory, no other operations). It was slightly peculiar to me that we were testing the modification time of the directory (mtime2) against the modification time of the file, but it works in this contrived case. The easier way to fix this test would be to change testDir1 to testFile2 in the following line final FileStatus status2 = dfs.getFileStatus(testDir1); It no longer tests that the directory gets modified when a file is created, but I don't believe that is the goal of this test.
          Hide
          liuml07 Mingliang Liu added a comment -

          Changing the status2 from testDir1 to testFile2 is not enough. We have to also move it after creating files (or leave it open) as creating a new file will change the modification time of its parent directory. I assumed the file/directory last modification time (though never asserted) would be the same because of this. And it turned out to be not reliable. You're right that closing the file will change the file modification time but not its parent directory. And they may differ.

          So I thought 1) mkdir, 2) create file (and close it), 3) get file and dir status, and 4) do the assertions against respective mtimes were preferred to fix this. Thanks.

          Show
          liuml07 Mingliang Liu added a comment - Changing the status2 from testDir1 to testFile2 is not enough. We have to also move it after creating files (or leave it open) as creating a new file will change the modification time of its parent directory. I assumed the file/directory last modification time (though never asserted) would be the same because of this. And it turned out to be not reliable. You're right that closing the file will change the file modification time but not its parent directory. And they may differ. So I thought 1) mkdir, 2) create file (and close it), 3) get file and dir status, and 4) do the assertions against respective mtimes were preferred to fix this. Thanks.
          Hide
          liuml07 Mingliang Liu added a comment -

          What I proposed is some code snippet liket:

          diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java
          index fc90db5..558bcda 100644
          --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java
          +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java
          @@ -2127,11 +2127,11 @@ public void testStat() throws Exception {
                 fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
                 final Path testDir1 = new Path("testStat", "dir1");
                 dfs.mkdirs(testDir1);
          -      final FileStatus status1 = dfs.getFileStatus(testDir1);
          -      final String mtime1 = fmt.format(new Date(status1.getModificationTime()));
                 final Path testFile2 = new Path(testDir1, "file2");
                 DFSTestUtil.createFile(dfs, testFile2, 2 * blockSize, (short) 3, 0);
          -      final FileStatus status2 = dfs.getFileStatus(testDir1);
          +      final FileStatus status1 = dfs.getFileStatus(testDir1);
          +      final String mtime1 = fmt.format(new Date(status1.getModificationTime()));
          +      final FileStatus status2 = dfs.getFileStatus(testFile2);
                 final String mtime2 = fmt.format(new Date(status2.getModificationTime()));
           
                 final ByteArrayOutputStream out = new ByteArrayOutputStream();
          

          Do you think it makes sense or do you provide a similar patch? Thanks.

          Show
          liuml07 Mingliang Liu added a comment - What I proposed is some code snippet liket: diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java index fc90db5..558bcda 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java @@ -2127,11 +2127,11 @@ public void testStat() throws Exception { fmt.setTimeZone(TimeZone.getTimeZone( "UTC" )); final Path testDir1 = new Path( "testStat" , "dir1" ); dfs.mkdirs(testDir1); - final FileStatus status1 = dfs.getFileStatus(testDir1); - final String mtime1 = fmt.format( new Date(status1.getModificationTime())); final Path testFile2 = new Path(testDir1, "file2" ); DFSTestUtil.createFile(dfs, testFile2, 2 * blockSize, ( short ) 3, 0); - final FileStatus status2 = dfs.getFileStatus(testDir1); + final FileStatus status1 = dfs.getFileStatus(testDir1); + final String mtime1 = fmt.format( new Date(status1.getModificationTime())); + final FileStatus status2 = dfs.getFileStatus(testFile2); final String mtime2 = fmt.format( new Date(status2.getModificationTime())); final ByteArrayOutputStream out = new ByteArrayOutputStream(); Do you think it makes sense or do you provide a similar patch? Thanks.
          Hide
          ebadger Eric Badger added a comment -

          We have to also move it after creating files (or leave it open) as creating a new file will change the modification time of its parent directory.

          Mingliang Liu, yes that's right. Good catch!

          Uploading a patch following your code snippet.

          Show
          ebadger Eric Badger added a comment - We have to also move it after creating files (or leave it open) as creating a new file will change the modification time of its parent directory. Mingliang Liu , yes that's right. Good catch! Uploading a patch following your code snippet.
          Hide
          hadoopqa Hadoop QA added a comment -
          -1 overall



          Vote Subsystem Runtime Comment
          0 reexec 0m 14s Docker mode activated.
          +1 @author 0m 0s The patch does not contain any @author tags.
          +1 test4tests 0m 0s The patch appears to include 1 new or modified test files.
          +1 mvninstall 6m 52s trunk passed
          +1 compile 0m 45s trunk passed
          +1 checkstyle 0m 27s trunk passed
          +1 mvnsite 0m 50s trunk passed
          +1 mvneclipse 0m 12s trunk passed
          +1 findbugs 1m 42s trunk passed
          +1 javadoc 0m 55s trunk passed
          +1 mvninstall 0m 46s the patch passed
          +1 compile 0m 42s the patch passed
          +1 javac 0m 42s the patch passed
          +1 checkstyle 0m 25s the patch passed
          +1 mvnsite 0m 47s the patch passed
          +1 mvneclipse 0m 10s the patch passed
          +1 whitespace 0m 0s The patch has no whitespace issues.
          +1 findbugs 1m 46s the patch passed
          +1 javadoc 0m 52s the patch passed
          -1 unit 73m 6s hadoop-hdfs in the patch failed.
          +1 asflicense 0m 18s The patch does not generate ASF License warnings.
          92m 2s



          Reason Tests
          Failed junit tests hadoop.hdfs.server.datanode.TestDataNodeHotSwapVolumes
            hadoop.hdfs.server.datanode.TestDataNodeLifeline



          Subsystem Report/Notes
          Docker Image:yetus/hadoop:9560f25
          JIRA Issue HDFS-10934
          JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12831329/HDFS-10934.002.patch
          Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle
          uname Linux 2e66255ff8c0 3.13.0-95-generic #142-Ubuntu SMP Fri Aug 12 17:00:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
          Build tool maven
          Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh
          git revision trunk / 0da54e8
          Default Java 1.8.0_101
          findbugs v3.0.0
          unit https://builds.apache.org/job/PreCommit-HDFS-Build/16979/artifact/patchprocess/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt
          Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/16979/testReport/
          modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
          Console output https://builds.apache.org/job/PreCommit-HDFS-Build/16979/console
          Powered by Apache Yetus 0.4.0-SNAPSHOT http://yetus.apache.org

          This message was automatically generated.

          Show
          hadoopqa Hadoop QA added a comment - -1 overall Vote Subsystem Runtime Comment 0 reexec 0m 14s Docker mode activated. +1 @author 0m 0s The patch does not contain any @author tags. +1 test4tests 0m 0s The patch appears to include 1 new or modified test files. +1 mvninstall 6m 52s trunk passed +1 compile 0m 45s trunk passed +1 checkstyle 0m 27s trunk passed +1 mvnsite 0m 50s trunk passed +1 mvneclipse 0m 12s trunk passed +1 findbugs 1m 42s trunk passed +1 javadoc 0m 55s trunk passed +1 mvninstall 0m 46s the patch passed +1 compile 0m 42s the patch passed +1 javac 0m 42s the patch passed +1 checkstyle 0m 25s the patch passed +1 mvnsite 0m 47s the patch passed +1 mvneclipse 0m 10s the patch passed +1 whitespace 0m 0s The patch has no whitespace issues. +1 findbugs 1m 46s the patch passed +1 javadoc 0m 52s the patch passed -1 unit 73m 6s hadoop-hdfs in the patch failed. +1 asflicense 0m 18s The patch does not generate ASF License warnings. 92m 2s Reason Tests Failed junit tests hadoop.hdfs.server.datanode.TestDataNodeHotSwapVolumes   hadoop.hdfs.server.datanode.TestDataNodeLifeline Subsystem Report/Notes Docker Image:yetus/hadoop:9560f25 JIRA Issue HDFS-10934 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12831329/HDFS-10934.002.patch Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle uname Linux 2e66255ff8c0 3.13.0-95-generic #142-Ubuntu SMP Fri Aug 12 17:00:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Build tool maven Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh git revision trunk / 0da54e8 Default Java 1.8.0_101 findbugs v3.0.0 unit https://builds.apache.org/job/PreCommit-HDFS-Build/16979/artifact/patchprocess/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/16979/testReport/ modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs Console output https://builds.apache.org/job/PreCommit-HDFS-Build/16979/console Powered by Apache Yetus 0.4.0-SNAPSHOT http://yetus.apache.org This message was automatically generated.
          Hide
          liuml07 Mingliang Liu added a comment -

          Committed to trunk through branch-2.8. Thanks for the contribution, Eric Badger.

          Show
          liuml07 Mingliang Liu added a comment - Committed to trunk through branch-2.8 . Thanks for the contribution, Eric Badger .
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #10537 (See https://builds.apache.org/job/Hadoop-trunk-Commit/10537/)
          HDFS-10934. TestDFSShell#testStat fails intermittently. Contributed by (liuml07: rev f61e3d13e9610cbd09886359553f27d6480f6735)

          • (edit) hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #10537 (See https://builds.apache.org/job/Hadoop-trunk-Commit/10537/ ) HDFS-10934 . TestDFSShell#testStat fails intermittently. Contributed by (liuml07: rev f61e3d13e9610cbd09886359553f27d6480f6735) (edit) hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java

            People

            • Assignee:
              ebadger Eric Badger
              Reporter:
              ebadger Eric Badger
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development