You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2019/04/05 23:45:52 UTC
[lucene-solr] branch master updated: set the lastmod of the files
to be deleted to be 1 day ago so that '-remove_old_solr_logs 0' doesn't run
afoul of coarse granularity timestamps on windows jenkins machines if the
test starts and runs quickly
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 0b7421e set the lastmod of the files to be deleted to be 1 day ago so that '-remove_old_solr_logs 0' doesn't run afoul of coarse granularity timestamps on windows jenkins machines if the test starts and runs quickly
0b7421e is described below
commit 0b7421eca6715602c6233106a7501eaa29a91eb5
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Fri Apr 5 16:45:41 2019 -0700
set the lastmod of the files to be deleted to be 1 day ago so that '-remove_old_solr_logs 0' doesn't run afoul of coarse granularity timestamps on windows jenkins machines if the test starts and runs quickly
---
solr/core/src/test/org/apache/solr/util/UtilsToolTest.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java b/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java
index 4272ad7..0ac3591 100644
--- a/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java
+++ b/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java
@@ -118,6 +118,20 @@ public class UtilsToolTest extends SolrTestCaseJ4 {
@Test
public void testRelativePath() throws Exception {
+
+ // NOTE...
+ //
+ // some filesystems have coarse granularity for last modified attribute (ie: multiple milliseconds)
+ // which means if the test runs very quickly after the creation / setLastMod of these file,
+ // then "setLastMod(X days ago)" may be equal to (or even greater that) "now - X days" causing
+ // "-remove_old_solr_logs X" to ignore them.
+ // so make sure we use at least "setLastMod(X+1 days ago)"
+
+ Files.setLastModifiedTime(dir.resolve("solr_log_20160102"),
+ FileTime.from(Instant.now().minus(Period.ofDays(1))));
+ Files.setLastModifiedTime(dir.resolve("solr_log_20160304"),
+ FileTime.from(Instant.now().minus(Period.ofDays(2))));
+
String[] args = {"utils", "-remove_old_solr_logs", "0", "-l", dir.getFileName().toString(), "-s", dir.getParent().toString()};
assertEquals(files.size(), fileCount());
assertEquals(0, runTool(args));