Search in sources :

Example 51 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class BulkPatchBuilderTest method test_local_idea.

@Test(enabled = false)
public void test_local_idea() throws Exception {
    // /does not work for real repository: Fetcher call is mostly endless
    final String ultimate_local = "E:\\Work\\idea-ultimate\\.git";
    VcsRoot root = vcsRoot().withFetchUrl(ultimate_local).withRepositoryPathOnServer(ultimate_local).withBranch("master").build();
    final BulkPatchBuilder patcher = patcher(new PatchLogger() {

        public void log(@NotNull final String message) {
        }
    });
    runFullPatch(root, patcher);
}
Also used : BulkPatchBuilder(jetbrains.buildServer.vcs.BulkPatchService.BulkPatchBuilder) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test)

Example 52 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class GitPerformanceTests method incrementalIntellijFetch.

@Test
public // @Test(invocationCount = 100)
void incrementalIntellijFetch() throws Exception {
    final VcsRootImpl root = VcsRootBuilder.vcsRoot().withBranchSpec("+:refs/heads/*").withFetchUrl("ssh://git@git.jetbrains.team/intellij.git").withAuthMethod(AuthenticationMethod.PRIVATE_KEY_DEFAULT).build();
    final ServerPaths sp = new ServerPaths("/Users/victory/Tests/server_paths");
    final ServerPluginConfig config = new PluginConfigBuilder(sp).setSeparateProcessForFetch(true).build();
    final GitSupportBuilder builder = GitSupportBuilder.gitSupport().withServerPaths(sp).withPluginConfig(config).withFetchCommand(new NativeGitCommands(config, () -> new GitExec("git", new GitVersion(2, 34, 0)), new VcsRootSshKeyManager() {

        @Nullable
        @Override
        public TeamCitySshKey getKey(@NotNull VcsRoot root) {
            return null;
        }
    }));
    GitVcsSupport support = builder.build();
    final RepositoryStateData currentState = support.getCurrentState(root);
    final long startTime = new Date().getTime();
    System.out.println("Fetching repository...");
    final OperationContext ctx = support.createContext(root, "fetch");
    try {
        support.getCollectChangesPolicy().ensureRepositoryStateLoadedFor(ctx, currentState, true);
    } finally {
        ctx.close();
    }
    final long totalTime = new Date().getTime() - startTime;
    System.out.println("Fetch time: " + totalTime + "ms");
}
Also used : NativeGitCommands(jetbrains.buildServer.buildTriggers.vcs.git.command.NativeGitCommands) GitExec(jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) NotNull(org.jetbrains.annotations.NotNull) Date(java.util.Date) VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) RepositoryStateData(jetbrains.buildServer.vcs.RepositoryStateData) VcsRootSshKeyManager(jetbrains.buildServer.ssh.VcsRootSshKeyManager) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) Test(org.testng.annotations.Test)

Example 53 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class CleanerTest method test_clean.

@Test(dataProvider = "true,false")
public void test_clean(Boolean useJgitGC) throws VcsException, InterruptedException {
    final int mirrorExpirationTimeoutMillis = 8000;
    myConfigBuilder.setMirrorExpirationTimeoutMillis(mirrorExpirationTimeoutMillis);
    if (useJgitGC) {
        myConfigBuilder.setRunJGitGC(true);
        myConfigBuilder.setRunNativeGC(false);
    } else {
        myConfigBuilder.setRunJGitGC(false);
        myConfigBuilder.setRunNativeGC(true);
    }
    initCleanup();
    File baseMirrorsDir = myRepositoryManager.getBaseMirrorsDir();
    generateGarbage(baseMirrorsDir);
    Thread.sleep(2 * myConfig.getMirrorExpirationTimeoutMillis());
    final VcsRoot root = GitTestUtil.getVcsRoot();
    mySupport.collectChanges(root, "70dbcf426232f7a33c7e5ebdfbfb26fc8c467a46", "a894d7d58ffde625019a9ecf8267f5f1d1e5c341", CheckoutRules.DEFAULT);
    // make sure repo timestamp will be updated
    setInternalProperty("teamcity.git.accessTimeUpdateRateMinutes", "0");
    // it will create dir in cache directory
    mySupport.getCurrentState(root);
    File repositoryDir = getRepositoryDir(root);
    final File timestamp = new File(repositoryDir, "timestamp");
    assertTrue(timestamp.isFile());
    assertTrue(System.currentTimeMillis() - mySupport.getRepositoryManager().getLastUsedTime(repositoryDir) < mirrorExpirationTimeoutMillis);
    myCleanup.run();
    assertTrue(myCleanupCalled.get());
    File[] files = baseMirrorsDir.listFiles(new FileFilter() {

        public boolean accept(File f) {
            return f.isDirectory();
        }
    });
    assertEquals(1, files.length);
    assertEquals(repositoryDir, files[0]);
    // check that repository is fine after git gc
    mySupport.getCurrentState(root);
}
Also used : VcsRoot(jetbrains.buildServer.vcs.VcsRoot) FileFilter(java.io.FileFilter) File(java.io.File) Test(org.testng.annotations.Test)

Example 54 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class AutoCheckoutTest method should_respect_root_settings_when_checking_multi_root_constraints.

@TestFor(issues = "TW-49786")
public void should_respect_root_settings_when_checking_multi_root_constraints() throws Exception {
    myVcsSupport = vcsSupportWithRealGit();
    // second root has broken git path, we should not take it into account
    // during canCheckout() for the first VCS root
    VcsRoot root1 = vcsRoot().withId(1).withAgentGitPath(getGitPath()).withFetchUrl("http://some.org/repo1.git").build();
    VcsRoot root2 = vcsRoot().withId(2).withAgentGitPath("wrongGitPath").withFetchUrl("http://some.org/repo2.git").build();
    AgentRunningBuild build = runningBuild().addRootEntry(root1, "+:dir1").addRootEntry(root2, "+:dir2").build();
    AgentCheckoutAbility canCheckout1 = myVcsSupport.canCheckout(root1, new CheckoutRules("+:dir1"), build);
    AgentCheckoutAbility canCheckout2 = myVcsSupport.canCheckout(root2, new CheckoutRules("+:dir2"), build);
    then(canCheckout1.getCanNotCheckoutReason()).isNull();
    then(canCheckout2.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NO_VCS_CLIENT);
    then(canCheckout2.getCanNotCheckoutReason().getDetails()).contains("Unable to run git at path wrongGitPath");
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) TestFor(jetbrains.buildServer.util.TestFor)

Example 55 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class AutoCheckoutTest method include_rule_with_mapping_is_used_without_sparse_checkout.

public void include_rule_with_mapping_is_used_without_sparse_checkout() throws IOException, VcsException {
    myVcsSupport = vcsSupportWithFakeGitOfVersion(GIT_WITH_SPARSE_CHECKOUT);
    VcsRoot vcsRoot = vcsRootWithAgentGitPath();
    AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "false").addRootEntry(vcsRoot, "+:a/b/c => d").build();
    AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, new CheckoutRules("+:a/b/c => d"), build);
    then(canCheckout.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NOT_SUPPORTED_CHECKOUT_RULES);
    then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Unsupported rules for agent-side checkout: +:a/b/c => d");
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Aggregations

VcsRoot (jetbrains.buildServer.vcs.VcsRoot)59 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)25 TestFor (jetbrains.buildServer.util.TestFor)17 Test (org.testng.annotations.Test)16 GitVcsSupport (jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)15 AgentCheckoutAbility (jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)10 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)9 File (java.io.File)8 VcsException (jetbrains.buildServer.vcs.VcsException)8 URIish (org.eclipse.jgit.transport.URIish)5 RevWalk (org.eclipse.jgit.revwalk.RevWalk)3 CredentialsProvider (org.eclipse.jgit.transport.CredentialsProvider)3 NotNull (org.jetbrains.annotations.NotNull)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GitVersion (jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)2 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)2 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)2 TeamCitySshKey (jetbrains.buildServer.ssh.TeamCitySshKey)2 BulkPatchBuilder (jetbrains.buildServer.vcs.BulkPatchService.BulkPatchBuilder)2 RepositoryStateData (jetbrains.buildServer.vcs.RepositoryStateData)2