This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new f84b8f2  Change calculation of new file times to avoid Travis failures
f84b8f2 is described below

commit f84b8f23a975b3999137afc3796a73d557fed00b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Aug 18 16:37:00 2020 +0100

    Change calculation of new file times to avoid Travis failures
    
    Sometimes deployment would take ~8s on Travis. Using a new modification
    time of current time - 10 seconds meant the new time was within 1s of
    the old time and, therefore, not seen as different by Tomcat.
---
 .../startup/TestHostConfigAutomaticDeployment.java         | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java 
b/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
index d37b765..9769f77 100644
--- a/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
+++ b/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
@@ -1090,6 +1090,8 @@ public class TestHostConfigAutomaticDeployment extends 
TomcatBaseTest {
         File war = null;
         File dir = null;
 
+        long testStartTime = System.currentTimeMillis();
+
         if (startXml && !startExternalWar && !startExternalDir) {
             xml = createXmlInConfigBaseForAppbase();
         }
@@ -1117,14 +1119,16 @@ public class TestHostConfigAutomaticDeployment extends 
TomcatBaseTest {
         host.backgroundProcess();
 
         // Update the last modified time. Make sure that the OS reports a 
change
-        // in modification time that HostConfig can detect.
+        // in modification time that HostConfig can detect. Change is made
+        // relative to test start time to ensure new modification times are
+        // sufficiently different.
         switch (toModify) {
             case XML:
                 if (xml == null) {
                     Assert.fail();
                 } else {
                     Assert.assertTrue("Failed to set last modified for [" + 
xml + "]", xml.setLastModified(
-                            System.currentTimeMillis() - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
+                            testStartTime - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
                 }
                 break;
             case EXT:
@@ -1132,7 +1136,7 @@ public class TestHostConfigAutomaticDeployment extends 
TomcatBaseTest {
                     Assert.fail();
                 } else {
                     Assert.assertTrue("Failed to set last modified for [" + 
ext + "]", ext.setLastModified(
-                            System.currentTimeMillis() - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
+                            testStartTime - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
                 }
                 break;
             case WAR:
@@ -1140,7 +1144,7 @@ public class TestHostConfigAutomaticDeployment extends 
TomcatBaseTest {
                     Assert.fail();
                 } else {
                     Assert.assertTrue("Failed to set last modified for [" + 
war + "]", war.setLastModified(
-                            System.currentTimeMillis() - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
+                            testStartTime - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
                 }
                 break;
             case DIR:
@@ -1148,7 +1152,7 @@ public class TestHostConfigAutomaticDeployment extends 
TomcatBaseTest {
                     Assert.fail();
                 } else {
                     Assert.assertTrue("Failed to set last modified for [" + 
dir + "]", dir.setLastModified(
-                            System.currentTimeMillis() - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
+                            testStartTime - 10 * 
HostConfig.FILE_MODIFICATION_RESOLUTION_MS));
                 }
                 break;
             default:


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to