Search in sources :

Example 6 with RevisionsCache

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();
}
Also used : ArrayList(java.util.ArrayList) RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) File(java.io.File)

Example 7 with RevisionsCache

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);
}
Also used : RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with RevisionsCache

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();
    }
}
Also used : RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) File(java.io.File) ServerPluginConfig(jetbrains.buildServer.buildTriggers.vcs.git.ServerPluginConfig) Test(org.testng.annotations.Test)

Example 9 with RevisionsCache

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));
}
Also used : RevisionCacheType(jetbrains.buildServer.buildTriggers.vcs.git.RevisionCacheType) RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) File(java.io.File)

Example 10 with RevisionsCache

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));
}
Also used : RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) File(java.io.File)

Aggregations

RevisionsCache (jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache)10 File (java.io.File)9 RepositoryRevisionCache (jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache)9 ArrayList (java.util.ArrayList)1 RevisionCacheType (jetbrains.buildServer.buildTriggers.vcs.git.RevisionCacheType)1 ServerPluginConfig (jetbrains.buildServer.buildTriggers.vcs.git.ServerPluginConfig)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1