use of jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method hint_cache_size_should_be_enough_to_keep_all_repositories.
public void hint_cache_size_should_be_enough_to_keep_all_repositories() throws Exception {
// create more repositories than configured cache size
myConfigBuilder.setMapFullPathRevisionCacheSize(2);
List<File> repositories = new ArrayList<>();
for (int i = 0; i < 4; i++) {
repositories.add(repository(String.valueOf(i)));
}
myCache = new RevisionsCache(myConfig);
// and doesn't contain revisions from other repositories
for (File repo : repositories) {
RepositoryRevisionCache cache = myCache.getRepositoryCache(repo, RevisionCacheType.HINT_CACHE);
int repoNum = Integer.parseInt(repo.getName());
for (int i = 0; i < 4; i++) {
boolean contains = repoNum == i;
cache.saveRevision("v" + i, contains, cache.getResetCounter());
}
}
// check that all revisions are in cache
for (File repo : repositories) {
int repoNum = Integer.parseInt(repo.getName());
RepositoryRevisionCache cache = myCache.getRepositoryCache(repo, RevisionCacheType.HINT_CACHE);
for (int i = 0; i < 4; i++) {
boolean contains = repoNum == i;
then(cache.hasRevision("v" + i)).isEqualTo(contains);
}
}
RepositoryRevisionCache cache5 = myCache.getRepositoryCache(repository("5"), RevisionCacheType.HINT_CACHE);
cache5.saveRevision("v1", false, cache5.getResetCounter());
cache5.saveRevision("v2", false, cache5.getResetCounter());
cache5.saveRevision("v3", false, cache5.getResetCounter());
then(cache5.hasRevision("v1")).isFalse();
then(cache5.hasRevision("v2")).isFalse();
then(cache5.hasRevision("v3")).isFalse();
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
super.setUp();
myConfigBuilder = pluginConfig().setTempFiles(myTempFiles);
myConfig = myConfigBuilder.build();
myCache = new RevisionsCache(myConfig);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method should_contain_last_n_revisions.
@Test(dataProvider = "true,false")
public void should_contain_last_n_revisions(boolean afterRestart) throws Exception {
int cacheSize = 10;
myConfigBuilder.setMapFullPathRevisionCacheSize(cacheSize);
ServerPluginConfig config = myConfigBuilder.build();
myCache = new RevisionsCache(config);
File repo = repository("1");
RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
for (int i = 0; i < 100; i++) {
repoCache.saveRevision("v" + i, true, repoCache.getResetCounter());
}
if (afterRestart) {
myCache = new RevisionsCache(config);
repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
}
for (int i = 100 - cacheSize; i < 100; i++) {
then(repoCache.hasRevision("v" + i)).overridingErrorMessage("Doesn't contain entry for revision v" + i).isTrue();
}
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method reset_negative_entries_different_types.
public void reset_negative_entries_different_types() throws Exception {
File repo = repository("1");
RepositoryRevisionCache commitCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
commitCache.saveRevision("v1", false, commitCache.getResetCounter());
commitCache.saveRevision("v2", true, commitCache.getResetCounter());
commitCache.saveRevision("v3", false, commitCache.getResetCounter());
RepositoryRevisionCache hintCache = myCache.getRepositoryCache(repo, RevisionCacheType.HINT_CACHE);
hintCache.saveRevision("v4", false, hintCache.getResetCounter());
myCache.resetNegativeEntries(repo);
for (RevisionCacheType type : RevisionCacheType.values()) {
then(myCache.getRepositoryCache(repo, type).hasRevision("v1")).isNull();
then(myCache.getRepositoryCache(repo, type).hasRevision("v3")).isNull();
then(myCache.getRepositoryCache(repo, type).hasRevision("v4")).isNull();
}
then(commitCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE));
then(hintCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.HINT_CACHE));
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method reset_negative_entries.
public void reset_negative_entries() throws Exception {
File repo = repository("1");
RepositoryRevisionCache commitCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
commitCache.saveRevision("v1", false, commitCache.getResetCounter());
commitCache.saveRevision("v2", true, commitCache.getResetCounter());
commitCache.saveRevision("v3", false, commitCache.getResetCounter());
myCache.resetNegativeEntries(repo);
then(commitCache.hasRevision("v1")).isNull();
then(commitCache.hasRevision("v3")).isNull();
then(commitCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE));
}
Aggregations