Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-351

Torque-Generator, runOnlyOnSourceChange

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0
    • 5.0
    • Generator
    • None

    Description

      I get an test failure in torque-generator running mvn clean test:

       

      Test set: org.apache.torque.generator.control.RunOnlyOnSourceChangeTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.14 sec <<< FAILURE!
      testRunOnlyOnSourceChange(org.apache.torque.generator.control.RunOnlyOnSourceChangeTest) Time elapsed: 1.14 sec <<< FAILURE!
      java.lang.AssertionError: Tue Jul 03 11:13:31 CEST 2018 not equal to Tue Jul 03 11:13:32 CEST 2018 expected:<1530609211675> but was:<1530609212737>
      at org.junit.Assert.fail(Assert.java:91)
      at org.junit.Assert.failNotEquals(Assert.java:645)
      at org.junit.Assert.assertEquals(Assert.java:126)
      at org.junit.Assert.assertEquals(Assert.java:470)
      at org.apache.torque.generator.control.RunOnlyOnSourceChangeTest.testRunOnlyOnSourceChange(RunOnlyOnSourceChangeTest.java:112)
      

      It fails at this line (the first teste after initialization and the content was moved)

       

       

      assertTrue(unchangedTargetFile1LastModified == assertFile(targetDir1, "unchangedOutput.txt", "unchangedValue"));
      

       

      Apparently unchangedOutput.txt should not have changed the lastModified.... (I expanded the assert to get a little more information.) The reported time difference (about 1000msec) is due to 

       Thread.sleep(1000);
      

      in the test and is apparently only there because checkSourceModified returns true (I read TORQUE-338, this might be also still another issue), i.e. it's not the reason, why itt fails, but a consequence of it.

      Investigating the source code I found, that, if I comment out this

       

      if (lastGenerationTime.before(sourceLastModified))
      {
      log.debug("checkSourceModified(): "
      + "lastGenerationTime was before source was modified ("
      + lastGenerationTime
      + " < "
      + sourceLastModified
      + "), return true");
      sourceModifiedCache.put(sourceChangeKey, true);
      return true;
      }
      

      in 

      org.apache.torque.generator.control.Controller.checkSourceModified(Source, ControllerState, UnitConfiguration)

      which is called, if isRunOnlyOnSourceChange is true for the unitConfiguration, the failure is gone.

      The time difference there between lastGenerationTime and sourceLastModified is alwasy below 100ms (sometimes only 25ms), and might be due to the OS environment. This might be a windows problem? One solution might be to remove the milliseconds.

      If I replace the code with 

      final GregorianCalendar gcLastGenerationTime = new GregorianCalendar();
      gcLastGenerationTime.setTime( lastGenerationTime );
      gcLastGenerationTime.set(Calendar.MILLISECOND, 0);
      
      final GregorianCalendar gcSourceLastModified = new GregorianCalendar();
      gcSourceLastModified.setTime( sourceLastModified );
      gcSourceLastModified.set(Calendar.MILLISECOND, 0);
      
      if (gcLastGenerationTime.before(gcSourceLastModified))
      

      all the tests run successfully.

      Attachments

        Activity

          People

            tv Thomas Vandahl
            gm_kall Georg Kallidis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: