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 commit is contained in:
Chris Hostetter 2019-04-05 16:45:41 -07:00
parent 37166ce4e9
commit 0b7421eca6
1 changed files with 14 additions and 0 deletions

View File

@ -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));