mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
LRU semantic for workdir cache (#1735)
Introduces a maximum size for the simple workdir cache. On cache overflow workdirs are evicted using an LRU strategy. Furthermore parallel requests for the same repository will now block until the workdir is released.
This commit is contained in:
@@ -35,6 +35,7 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import sonia.scm.repository.GitRepositoryConfig;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.GitTestHelper;
|
||||
import sonia.scm.repository.PreProcessorUtil;
|
||||
@@ -149,6 +150,32 @@ public class SimpleGitWorkingCopyFactoryTest extends AbstractGitCommandTestBase
|
||||
assertBranchCheckedOutAndClean(workdir, "master");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReclaimCleanDirectoryConfiguredDefaultBranch() throws Exception {
|
||||
SimpleGitWorkingCopyFactory factory = new SimpleGitWorkingCopyFactory(new NoneCachingWorkingCopyPool(workdirProvider), new SimpleMeterRegistry());
|
||||
File workdir = createExistingClone(factory);
|
||||
|
||||
GitContext context = createContext();
|
||||
GitRepositoryConfig config = context.getConfig();
|
||||
config.setDefaultBranch("master");
|
||||
context.setConfig(config);
|
||||
factory.reclaim(context, workdir, null);
|
||||
|
||||
assertBranchCheckedOutAndClean(workdir, "master");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReclaimCleanDirectoryGloballyConfiguredDefaultBranch() throws Exception {
|
||||
SimpleGitWorkingCopyFactory factory = new SimpleGitWorkingCopyFactory(new NoneCachingWorkingCopyPool(workdirProvider), new SimpleMeterRegistry());
|
||||
File workdir = createExistingClone(factory);
|
||||
|
||||
GitContext context = createContext();
|
||||
context.getGlobalConfig().setDefaultBranch("master");
|
||||
factory.reclaim(context, workdir, null);
|
||||
|
||||
assertBranchCheckedOutAndClean(workdir, "master");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReclaimCleanDirectoryWithOtherBranch() throws Exception {
|
||||
SimpleGitWorkingCopyFactory factory = new SimpleGitWorkingCopyFactory(new NoneCachingWorkingCopyPool(workdirProvider), new SimpleMeterRegistry());
|
||||
@@ -192,6 +219,7 @@ public class SimpleGitWorkingCopyFactoryTest extends AbstractGitCommandTestBase
|
||||
factory.reclaim(createContext(), workdir, "master");
|
||||
|
||||
assertBranchCheckedOutAndClean(workdir, "master");
|
||||
assertThat(newDirectory).doesNotExist();
|
||||
}
|
||||
|
||||
public File createExistingClone(SimpleGitWorkingCopyFactory factory) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user