use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method should_not_retry_fetch_mirror_for_exec_timeout.
@Test(enabled = false)
@TestFor(issues = "TW-56415")
public void should_not_retry_fetch_mirror_for_exec_timeout() throws Exception {
MockFS fs = new MockFS();
LoggingGitMetaFactory loggingFactory = new LoggingGitMetaFactory();
myVcsSupport = myBuilder.setGitMetaFactory(loggingFactory).setFS(fs).build();
File repo = dataFile("repo_for_fetch.1");
File remoteRepo = myTempFiles.createTempDir();
copyRepository(repo, remoteRepo);
// run build to prepare mirror
VcsRootImpl root = vcsRoot().withAgentGitPath(getGitPath()).withFetchUrl(GitUtils.toURL(remoteRepo)).build();
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, "add81050184d3c818560bdd8839f50024c188586", myCheckoutDir, createRunningBuild(true), false);
// update remote repo: add personal branch
delete(remoteRepo);
File updatedRepo = dataFile("repo_for_fetch.2.personal");
copyRepository(updatedRepo, remoteRepo);
// make first two fetches in local mirror to fail:
loggingFactory.addCallback(FetchCommand.class.getName() + ".call", new GitCommandProxyCallback() {
volatile boolean thrown = false;
@Override
public Optional<Object> call(final Method method, final Object[] args) throws VcsException {
if (!thrown) {
thrown = true;
throw new GitExecTimeout();
}
fail("Should not try to fetch again");
return null;
}
});
File mirror = myBuilder.getMirrorManager().getMirrorDir(GitUtils.toURL(remoteRepo));
// try to fetch unknown branch, first fetch fails with exec timeout, repo would be remapped
VcsRootImpl root2 = vcsRoot().withAgentGitPath(getGitPath()).withBranch("refs/heads/personal").withFetchUrl(GitUtils.toURL(remoteRepo)).build();
AgentRunningBuild build = runningBuild().useLocalMirrors(true).sharedConfigParams("teamcity.git.fetchMirrorRetryTimeouts", "0,0").withAgentConfiguration(myBuilder.getAgentConfiguration()).build();
try {
myVcsSupport.updateSources(root2, CheckoutRules.DEFAULT, "d47dda159b27b9a8c4cee4ce98e4435eb5b17168", myCheckoutDir, build, false);
fail("GitExecTimeout exception expected");
} catch (GitExecTimeout ignored) {
}
// try again, should succeed without remapping, means previous code has not changed mirror directory
loggingFactory.addCallback(FetchCommand.class.getName() + ".call", (method, args) -> null);
myVcsSupport.updateSources(root2, CheckoutRules.DEFAULT, "d47dda159b27b9a8c4cee4ce98e4435eb5b17168", myCheckoutDir, build, false);
File mirrorAfterBuild = myBuilder.getMirrorManager().getMirrorDir(GitUtils.toURL(remoteRepo));
// repository was not remapped to another dir
then(mirrorAfterBuild).isEqualTo(mirror);
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method short_lived_agent_auto_clone.
@Test
public void short_lived_agent_auto_clone() throws Exception {
myBuild.getAgentConfiguration().addConfigurationParameter(AgentMiscConstants.IS_EPHEMERAL_AGENT_PROP, "true");
final File remote = dataFile("repo_for_shallow_fetch.git");
final File shallowMarker = new File(myCheckoutDir, ".git/shallow");
final VcsRootImpl root = createRoot(remote, "refs/heads/main");
root.addProperty(Constants.CHECKOUT_POLICY, AgentCheckoutPolicy.AUTO.name());
myVcsSupport.updateSources(root, new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myCheckoutDir, myBuild, false);
assertTrue(shallowMarker.exists());
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method should_use_branch_specified_in_build_parameter.
@Test(dataProvider = "mirrors")
public void should_use_branch_specified_in_build_parameter(Boolean useMirrors) throws Exception {
final File remote = myTempFiles.createTempDir();
copyRepository(dataFile("repo_for_fetch.2.personal"), remote);
VcsRootImpl root = createRoot(remote, "master");
AgentRunningBuild build = createRunningBuild(map(PluginConfigImpl.USE_MIRRORS, String.valueOf(useMirrors)));
String commitFromFeatureBranch = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, commitFromFeatureBranch, myCheckoutDir, build, false);
Repository r = new RepositoryBuilder().setWorkTree(myCheckoutDir).build();
assertEquals("master", r.getBranch());
build = createRunningBuild(map(PluginConfigImpl.USE_MIRRORS, String.valueOf(useMirrors), GitUtils.getGitRootBranchParamName(root), "refs/heads/personal"));
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, commitFromFeatureBranch, myCheckoutDir, build, false);
r = new RepositoryBuilder().setWorkTree(myCheckoutDir).build();
assertEquals("personal", r.getBranch());
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AutoCheckoutTest method should_check_shared_paths_not_clashing.
public void should_check_shared_paths_not_clashing() throws Exception {
myVcsSupport = vcsSupportWithFakeGitOfVersion(GIT_CLEAN_LEARNED_EXCLUDE);
final VcsRoot vcsRoot = vcsRoot().withFetchUrl("/some/path").withAgentGitPath(getGitPath()).build();
{
final AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").addRoot(vcsRoot).addRootEntry(new VcsRootImpl(2, "svn"), "some/path=>.").build();
AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, CheckoutRules.DEFAULT, build);
then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root", "into the same directory as VCS root");
}
{
final AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").addRoot(vcsRoot).addRootEntry(new VcsRootImpl(2, "svn"), ".=>some/path").build();
AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, new CheckoutRules(".=>some/path"), build);
then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root", "into the same directory as VCS root");
}
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method not_fetch_submodules.
@TestFor(issues = "TW-63901")
@Test
public void not_fetch_submodules() throws Exception {
final File repo = new File(getTempDirectory(), "TW-63901");
FileUtil.delete(repo);
copyDir(dataFile("TW-63901-1"), repo);
final File submoduleRepo = new File(getTempDirectory(), "TW-63901-submodule");
FileUtil.delete(submoduleRepo);
copyDir(dataFile("TW-63901-submodule"), submoduleRepo);
final VcsRootImpl root = createRoot(repo, "master");
root.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.CHECKOUT.name());
final AgentRunningBuild build = createRunningBuild(new HashMap<String, String>() {
{
put(PluginConfigImpl.USE_MIRRORS, "false");
put(PluginConfigImpl.USE_MIRRORS_FOR_SUBMODULES, "false");
}
});
myVcsSupport.updateSources(root, new CheckoutRules(""), "78fcadbf51f44cf78fce816be5e3943e4bb5f95c", myCheckoutDir, build, false);
assertTrue(new File(myCheckoutDir, ".gitmodules").isFile());
assertTrue(new File(myCheckoutDir, "TW-63901-submodule/f.txt").isFile());
// patch config to fetch submodules during fetch
final StoredConfig config = new RepositoryBuilder().setWorkTree(myCheckoutDir).build().getConfig();
config.setBoolean("fetch", null, "recursesubmodules", true);
config.save();
root.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.IGNORE.name());
FileUtil.delete(repo);
// new repo references submodule commit, which doesn't exist
copyDir(dataFile("TW-63901-2"), repo);
myVcsSupport.updateSources(root, new CheckoutRules(""), "565f5f32581cd1dba1305c5f5651270c33f40323", myCheckoutDir, build, false);
}
Aggregations