Search in sources :

Example 91 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitPatchTest method submodules_and_checkout_rules2.

@TestFor(issues = "TW-50097")
@Test(dataProvider = "patchInSeparateProcess")
public void submodules_and_checkout_rules2(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    VcsRoot root = getRoot("sub-submodule", true);
    checkPatch(root, "submodules_and_checkout_rules2", null, "ce6044093939bb47283439d97a1c80f759669ff5", new CheckoutRules("+:first-level-submodule/sub-sub"));
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 92 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitServerUtilTest method url_with_newline.

@TestFor(issues = "TW-50043")
@Test(dataProviderClass = GitVcsRootTest.class, dataProvider = "urlsWithNewLines")
public void url_with_newline(@NotNull String url) throws Exception {
    File dir = myTempFiles.createTempDir();
    try {
        GitServerUtil.getRepository(dir, new URIish(url));
        fail("No error for url '" + url + "'");
    } catch (VcsException e) {
    // expected
    }
}
Also used : URIish(org.eclipse.jgit.transport.URIish) VcsException(jetbrains.buildServer.vcs.VcsException) File(java.io.File) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 93 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitVcsSupportTest method should_update_local_ref_when_it_locked.

@TestFor(issues = "TW-16351")
@Test(dataProvider = "doFetchInSeparateProcess", dataProviderClass = FetchOptionsDataProvider.class)
public void should_update_local_ref_when_it_locked(boolean fetchInSeparateProcess) throws Exception {
    setInternalProperty(Constants.CUSTOM_CLONE_PATH_ENABLED, "true");
    File remoteRepositoryDir = new File(myTmpDir, "repo_for_fetch");
    copyRepository(dataFile("repo_for_fetch.1"), remoteRepositoryDir);
    myConfigBuilder.setSeparateProcessForFetch(fetchInSeparateProcess);
    GitVcsSupport support = getSupport();
    VcsRootImpl root = getRoot("master", false, remoteRepositoryDir);
    String branch = root.getProperty(Constants.BRANCH_NAME);
    File customRootDir = new File(myTmpDir, "custom-dir");
    root.addProperty(Constants.PATH, customRootDir.getAbsolutePath());
    RepositoryStateData state = support.getCurrentState(root);
    String v1 = GitUtils.versionRevision(state.getBranchRevisions().get(state.getDefaultBranchName()));
    support.collectChanges(root, "a7274ca8e024d98c7d59874f19f21d26ee31d41d", "add81050184d3c818560bdd8839f50024c188586", CheckoutRules.DEFAULT);
    // now remote repository contains new commits
    copyRepository(dataFile("repo_for_fetch.2"), remoteRepositoryDir);
    File branchLockFile = createBranchLockFile(customRootDir, branch);
    assertTrue(branchLockFile.exists());
    state = support.getCurrentState(root);
    String v2 = GitUtils.versionRevision(state.getBranchRevisions().get(state.getDefaultBranchName()));
    // local repository is updated
    assertFalse(v2.equals(v1));
    support.collectChanges(root, v1, v2, CheckoutRules.DEFAULT);
}
Also used : VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) FileUtil.writeFile(jetbrains.buildServer.util.FileUtil.writeFile) File(java.io.File) LockFile(org.eclipse.jgit.internal.storage.file.LockFile) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 94 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitVcsSupportTest method fetch_process_should_respect_fetch_timeout.

@Test
@TestFor(issues = "TW-17910")
public void fetch_process_should_respect_fetch_timeout() throws Exception {
    // MockFetcher waits for 10 seconds
    // set teamcity.execution.timeout = 2, we should not get TimeoutException
    Properties beforeTestProperties = System.getProperties();
    final String defaultProcessExecutionTimeoutProperty = "teamcity.execution.timeout";
    System.setProperty(defaultProcessExecutionTimeoutProperty, "2");
    try {
        String classpath = myConfigBuilder.build().getFetchClasspath() + File.pathSeparator + ClasspathUtil.composeClasspath(new Class[] { MockFetcher.class }, null, null);
        myConfigBuilder.setSeparateProcessForFetch(true).setFetchClasspath(classpath).setFetcherClassName(MockFetcher.class.getName());
        final GitVcsSupport support = getSupport();
        final VcsRootImpl root = (VcsRootImpl) getRoot("master");
        support.collectChanges(root, VERSION_TEST_HEAD, MERGE_BRANCH_VERSION, CheckoutRules.DEFAULT);
    } catch (Exception e) {
        fail(e.getMessage());
    } finally {
        System.setProperties(beforeTestProperties);
    }
}
Also used : VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties) MissingSubmoduleCommitException(jetbrains.buildServer.buildTriggers.vcs.git.submodules.MissingSubmoduleCommitException) JSchException(com.jcraft.jsch.JSchException) NotSupportedException(org.eclipse.jgit.errors.NotSupportedException) MissingSubmoduleConfigException(jetbrains.buildServer.buildTriggers.vcs.git.submodules.MissingSubmoduleConfigException) TransportException(org.eclipse.jgit.errors.TransportException) MissingSubmoduleEntryException(jetbrains.buildServer.buildTriggers.vcs.git.submodules.MissingSubmoduleEntryException) IOException(java.io.IOException) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 95 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class GitVcsSupportTest method test_long_input_for_fetcher_process.

/*
   * Test reproduces a bug in Fetcher code: Fetcher worked only if all parameters of VcsRoot
   * sent to process input as string were smaller than 512 bytes (most of the cases) or size mod 512 = 0.
   */
@TestFor(issues = "TW-13330")
@Test
public void test_long_input_for_fetcher_process() throws IOException, VcsException {
    myConfigBuilder.setSeparateProcessForFetch(true);
    GitVcsSupport support = getSupport();
    VcsRootImpl root = (VcsRootImpl) getRoot("version-test");
    root.addProperty("param", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + // with such long param size of input for fetcher process is greater than 512 bytes
    "bbbbbbbbbbbbbbbbbbbbb");
    support.collectChanges(root, "2276eaf76a658f96b5cf3eb25f3e1fda90f6b653", "f3f826ce85d6dad25156b2d7550cedeb1a422f4c", CheckoutRules.DEFAULT);
}
Also used : VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

TestFor (jetbrains.buildServer.util.TestFor)129 Test (org.testng.annotations.Test)81 File (java.io.File)65 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)56 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)26 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)21 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)17 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)12 VcsException (jetbrains.buildServer.vcs.VcsException)11 URIish (org.eclipse.jgit.transport.URIish)11 Repository (org.eclipse.jgit.lib.Repository)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)7 AfterMethod (org.testng.annotations.AfterMethod)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Method (java.lang.reflect.Method)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)6 Build (jetbrains.buildServer.server.rest.model.build.Build)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 FileUtil.writeFile (jetbrains.buildServer.util.FileUtil.writeFile)6