use of jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitExecTimeout 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.buildTriggers.vcs.git.command.errors.GitExecTimeout in project teamcity-git by JetBrains.
the class CommandUtil method isRecoverable.
public static boolean isRecoverable(@NotNull Exception e, AuthSettings authSettings, int attempt, int maxAttempts) {
boolean attemptsLeft = attempt < maxAttempts;
if (e instanceof ProcessTimeoutException || e instanceof GitExecTimeout)
return attemptsLeft;
if (!(e instanceof VcsException))
return false;
final VcsException ve = (VcsException) e;
if (isTimeoutError(ve) || isConnectionRefused(ve) || isConnectionReset(ve))
return attemptsLeft;
if (isCanceledError(ve))
return false;
if (e instanceof GitIndexCorruptedException)
return false;
if (authSettings.doesTokenNeedRefresh() && attempt == 1)
return true;
return attemptsLeft && !isRemoteAccessError(ve);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitExecTimeout in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method do_not_delete_mirror_on_timeout.
public void do_not_delete_mirror_on_timeout() throws Exception {
MockFS fs = new MockFS();
myVcsSupport = myBuilder.setFS(fs).build();
String unreachableRepository = "git://some.org/unreachable.git";
File mirror = myBuilder.getMirrorManager().getMirrorDir(unreachableRepository);
// if plugin will remove mirror it will fail and try to remap
fs.makeDeleteFail(mirror);
myRoot = vcsRoot().withAgentGitPath(getGitPath()).withFetchUrl(unreachableRepository).build();
try {
String revision = "abababababababababababababababababababab";
AgentRunningBuild build = runningBuild().useLocalMirrors(true).withAgentConfiguration(myBuilder.getAgentConfiguration()).sharedConfigParams("teamcity.git.idle.timeout.seconds", "1").build();
myVcsSupport.updateSources(myRoot, CheckoutRules.DEFAULT, revision, myCheckoutDir, build, false);
fail("update on unreachable repository should fail");
} catch (VcsException e) {
if (e instanceof GitExecTimeout) {
File mirrorAfterFailure = myBuilder.getMirrorManager().getMirrorDir(unreachableRepository);
then(mirrorAfterFailure).overridingErrorMessage("Mirror changed after error " + e.toString()).isEqualTo(// failure should not cause delete or remap
mirror);
} else {
// on some platforms fetch from unknown host doesn't result in timeout error
throw new SkipException("Not a timeout error: " + e.toString());
}
}
}
Aggregations