diff options
author | Harald Musum <musum@yahooinc.com> | 2022-10-26 13:53:24 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-10-26 13:53:24 +0200 |
commit | eddd0562097024157ce3bd381cdbbc45996eecb9 (patch) | |
tree | ce1184182a626b03f09502d233b99dc19a1be8dd /configserver/src/test/java/com | |
parent | 89a404e9cc981201284d5778e7295427dbc2b3a8 (diff) |
Remove unused file refrences based on last modified time
Diffstat (limited to 'configserver/src/test/java/com')
-rw-r--r-- | configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index b185bb5915d..e93b80076e8 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -61,7 +61,6 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.attribute.FileTime; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -298,10 +297,13 @@ public class ApplicationRepositoryTest { keepFileReferencesDuration, 2); Collections.sort(toBeDeleted); - assertEquals(List.of("bar0", "foo"), toBeDeleted); - // bar0 and foo are the only ones that will be deleted (keeps 2 newest no matter how old they are) + List<String> expected = new ArrayList<>(List.of("foo", "bar0", "bar1")); + Collections.sort(expected); + assertEquals(expected, toBeDeleted); + // foo, bar0 and bar1 will be deleted, 2 newest ones (bar2 and baz) will be kept no matter how old they are assertFalse(filereferenceDirOldest.exists()); assertFalse(new File(fileReferencesDir, "bar0").exists()); + assertFalse(new File(fileReferencesDir, "bar1").exists()); assertTrue(filereferenceDirNewest.exists()); } @@ -309,7 +311,7 @@ public class ApplicationRepositoryTest { assertTrue(filereferenceDir.mkdir()); File file = new File(filereferenceDir, "bar"); IOUtils.writeFile(file, Utf8.toBytes("test")); - Files.setAttribute(filereferenceDir.toPath(), "lastAccessTime", FileTime.from(clock.instant())); + file.setLastModified(clock.instant().toEpochMilli()); return filereferenceDir; } |