Merge pull request #43 from overleaf/msw-auto-gc

Queue a garbage collection job after pushing to a repo
This commit is contained in:
Michael Walker 2018-03-12 09:52:13 +00:00 committed by GitHub
commit 0908e8e607
3 changed files with 25 additions and 2 deletions

View file

@ -419,6 +419,8 @@ public class Bridge {
Log.warn("[{}] IOException on put", projectName);
throw e;
}
gcJob.queueForGc(projectName);
}
/**

View file

@ -1,5 +1,7 @@
package uk.ac.ic.wlgitbridge.bridge.gc;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.stubbing.OngoingStubbing;
import uk.ac.ic.wlgitbridge.bridge.lock.LockGuard;
@ -24,9 +26,20 @@ public class GcJobImplTest {
RepoStore repoStore = mock(RepoStore.class);
ProjectLock locks = new ProjectLockImpl();
ProjectLock locks;
GcJobImpl gcJob = new GcJobImpl(repoStore, locks, 5);
GcJobImpl gcJob;
@Before
public void setup() {
locks = new ProjectLockImpl();
gcJob = new GcJobImpl(repoStore, locks, 5);
}
@After
public void teardown() {
gcJob.stop();
}
@Test
public void addedProjectsAreAllEventuallyGcedOnce() throws Exception {

View file

@ -1,6 +1,7 @@
package uk.ac.ic.wlgitbridge.bridge.swap.job;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@ -74,6 +75,13 @@ public class SwapJobImplTest {
);
}
@After
public void teardown() {
if(swapJob != null) {
swapJob.stop();
}
}
@Test
public void startingTimerAlwaysCausesASwap() {
swapJob.lowWatermarkBytes = 16384;