use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method test_equals.
public void test_equals() throws Exception {
RepositoryRevisionCache cache1 = new RepositoryRevisionCache(myConfig, repository("1"), RevisionCacheType.COMMIT_CACHE, 100);
RepositoryRevisionCache cache2 = new RepositoryRevisionCache(myConfig, repository("1"), RevisionCacheType.COMMIT_CACHE, 100);
RepositoryRevisionCache cache3 = new RepositoryRevisionCache(myConfig, repository("1"), RevisionCacheType.HINT_CACHE, 100);
then(cache1).isEqualTo(cache2);
then(cache1).isNotEqualTo(cache3);
cache1.saveRevision("v1", true, cache1.getResetCounter());
cache1.saveRevision("v2", false, cache1.getResetCounter());
cache2.saveRevision("v1", true, cache2.getResetCounter());
cache2.saveRevision("v2", false, cache2.getResetCounter());
then(cache1).isEqualTo(cache2);
cache1.saveRevision("v3", true, cache1.getResetCounter());
then(cache1).isNotEqualTo(cache2);
cache2.saveRevision("v3", true, cache2.getResetCounter());
cache2.saveRevision("v4", false, cache2.getResetCounter());
then(cache1).isNotEqualTo(cache2);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method disable_persist.
public void disable_persist() throws Exception {
myConfigBuilder.setPersistentCacheEnabled(false);
File repo = repository("1");
RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
repoCache.saveRevision("v1", false, repoCache.getResetCounter());
then(RepositoryRevisionCache.getCacheFile(repo, RevisionCacheType.COMMIT_CACHE)).doesNotExist();
myConfigBuilder.setPersistentCacheEnabled(true);
repoCache.saveRevision("v1", false, repoCache.getResetCounter());
repoCache.saveRevision("v2", false, repoCache.getResetCounter());
then(RepositoryRevisionCache.getCacheFile(repo, RevisionCacheType.COMMIT_CACHE)).exists();
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method should_not_save_revision_if_there_was_reset.
@TestFor(issues = { "TW-23460" })
@Test(dataProvider = "reset")
public void should_not_save_revision_if_there_was_reset(@NotNull BiConsumer<RevisionsCache, File> reset) throws Exception {
File repo = repository("1");
Semaphore s1 = new Semaphore(1);
s1.acquire();
Semaphore s2 = new Semaphore(1);
s2.acquire();
Thread mapFullPath = new Thread(() -> {
try {
RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
long resetCounter = repoCache.getResetCounter();
if (repoCache.hasRevision("v1") == null) {
s1.release();
// long commit lookup (we didn't find it)
s2.acquire();
repoCache.saveRevision("v1", false, resetCounter);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
});
mapFullPath.start();
// collect changes which resets cache:
s1.acquire();
reset.accept(myCache, repo);
s2.release();
mapFullPath.join();
then(myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE).hasRevision("v1")).isNull();
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method disabled_persist_remove_cache_file.
public void disabled_persist_remove_cache_file() throws Exception {
// in order to not load stale data after restart
File repo = repository("1");
RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
repoCache.saveRevision("v1", false, repoCache.getResetCounter());
myConfigBuilder.setPersistentCacheEnabled(false);
repoCache.saveRevision("v1", true, repoCache.getResetCounter());
myConfigBuilder.setPersistentCacheEnabled(true);
RepositoryRevisionCache repoCache2 = new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
// should have no information on v1 after restart, especially 'false'
then(repoCache2.hasRevision("v1")).isNull();
}
use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.
the class RevisionsCacheTest method reset_negative_entries_with_new_commits.
public void reset_negative_entries_with_new_commits() throws Exception {
File repo = repository("1");
RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
repoCache.saveRevision("v1", false, repoCache.getResetCounter());
repoCache.saveRevision("v2", true, repoCache.getResetCounter());
repoCache.saveRevision("v3", false, repoCache.getResetCounter());
myCache.resetNegativeEntries(repo, setOf("v3", "v4"));
then(repoCache.hasRevision("v1")).isFalse();
then(repoCache.hasRevision("v2")).isTrue();
then(repoCache.hasRevision("v3")).isTrue();
then(repoCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE));
}
Aggregations