diff options
author | Harald Musum <musum@yahooinc.com> | 2022-07-04 09:40:04 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-07-04 09:40:04 +0200 |
commit | 323e47be1bed282823a85ba0ca10a839f5ebbe93 (patch) | |
tree | 069832230dde9170f0ed391377407c4d203f8a09 /configserver/src/test/java | |
parent | 676056859c7aa8b52c024bcec75b395994413c82 (diff) |
Add config for when to expire local sessions with unknown status
Diffstat (limited to 'configserver/src/test/java')
-rw-r--r-- | configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java | 12 |
1 files changed, 8 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 ee2a979be7a..46cf84e19c1 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 @@ -464,7 +464,8 @@ public class ApplicationRepositoryTest { // and check that expiring local sessions still works int sessionId = 6; TenantName tenantName = tester.tenant().getName(); - java.nio.file.Path dir = Files.createDirectory(new TenantFileSystemDirs(serverdb, tenantName).getUserApplicationDir(sessionId).toPath()); + Instant session6CreateTime = clock.instant(); + Files.createDirectory(new TenantFileSystemDirs(serverdb, tenantName).getUserApplicationDir(sessionId).toPath()); LocalSession localSession2 = new LocalSession(tenant1, sessionId, FilesApplicationPackage.fromFile(testApp), @@ -479,7 +480,7 @@ public class ApplicationRepositoryTest { // so will be candidate for expiry) Session session = sessionRepository.createRemoteSession(7); sessionRepository.createSetStatusTransaction(session, Session.Status.UNKNOWN); - assertEquals(2, sessionRepository.getLocalSessions().size()); // Still 2, no new local session + assertEquals(2, sessionRepository.getLocalSessions().size()); // Still 2, no new local session // Check that trying to expire local session when there exists a local session without any data in zookeeper // should not delete session if this is a new file ... @@ -489,8 +490,11 @@ public class ApplicationRepositoryTest { clock.advance(Duration.ofSeconds(60)); deleteExpiredLocalSessionsAndAssertNumberOfSessions(1, tester, sessionRepository); - // Set older created timestamp for session dir for local session without any data in zookeeper, should be deleted - setCreatedTime(dir, Instant.now().minus(Duration.ofDays(31))); + // Reset clock to the time session was created, session should NOT be deleted + clock.setInstant(session6CreateTime); + deleteExpiredLocalSessionsAndAssertNumberOfSessions(1, tester, sessionRepository); + // Advance time, session SHOULD be deleted + clock.advance(Duration.ofHours(configserverConfig.keepSessionsWithUnknownStatusHours()).plus(Duration.ofMinutes(1))); deleteExpiredLocalSessionsAndAssertNumberOfSessions(0, tester, sessionRepository); } |