use of jetbrains.buildServer.vcs.impl.VcsRootImpl 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);
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl 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);
}
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl 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);
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class GitVcsSupportTest method gc_enabled_by_user.
@Test
public void gc_enabled_by_user() throws Exception {
final File repo = createTempDir();
ZipUtil.extract(new File(getTestDataPath(), "TW-65641-1.zip"), repo, null);
final GitVcsSupport support = getSupport();
final VcsRootImpl root = getRoot("master", false, repo);
final OperationContext context = support.createContext(root, "fetch");
final GitVcsRoot gitRoot = context.getGitRoot();
final File mirror = gitRoot.getRepositoryDir();
ZipUtil.extract(new File(getTestDataPath(), "TW-65641.zip"), mirror, null);
// make sure old pack files won't be kept
final StoredConfig config = context.getRepository().getConfig();
config.setString("gc", null, "prunepackexpire", "now");
// enable gc externally
config.setInt("gc", null, "auto", 1);
config.save();
final File gitObjects = new File(mirror + "/objects");
Assert.assertTrue(gitObjects.isDirectory());
final HashSet<String> before = listObjectsRecursively(mirror);
support.collectChanges(root, "2faa6375bf6139923245a625a47bef046e5e6550", "ba04d81036c5953d17469f532e520fc1ecbcd3f1", CheckoutRules.DEFAULT);
// enough time for auto gc to start
Thread.sleep(5000);
new WaitFor() {
@Override
protected boolean condition() {
return !new File(mirror, "gc.log.lock").isFile();
}
};
final HashSet<String> after = listObjectsRecursively(mirror);
Assert.assertFalse(after.containsAll(before));
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class GitUrlSupportTest method toGitRoot.
private GitVcsRoot toGitRoot(@NotNull VcsUrl url) throws VcsException {
Map<String, String> properties = myUrlSupport.convertToVcsRootProperties(url, createRootContext());
assertNotNull(properties);
VcsRootImpl myRoot = new VcsRootImpl(1, properties);
return new GitVcsRoot(myMirrorManager, myRoot, new URIishHelperImpl());
}
Aggregations