Use TestProtocol to clone in-process for AbstractDaemonTest

This new JGit feature associates a particular request object with a
URL and processes all git protocol requests in-memory in a separate
thread. For acceptance tests, this request object also describes a
request scope context, such that each connection runs in its own
connection thread with its own Guice request context.

The TestProtocol instance uses custom Upload/ReceivePackFactory
implementations that parallel the implementations within the HTTP and
SSH code paths. On the one hand, this is yet another implementation
that must be modified when changing the git filter stack, but on the
other hand, there were already multiple stacks to begin with. In this
case, I think the performance improvement is also worth the cost.

With this change, single acceptance test methods can run in about
100ms even on my Macbook Air. Startup cost is still relatively high
due to server initialization, but this change opens the door to
reducing that well by removing HTTP and SSH servers from tests
entirely.

Change-Id: Icddd7d2ac448ea3f59909f8ef61f95feb1d67b64
This commit is contained in:
Dave Borowitz
2015-03-11 10:35:31 -07:00
parent f96e6e3851
commit f893c4f87c
11 changed files with 425 additions and 19 deletions

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.acceptance.edit;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -270,7 +269,7 @@ public class ChangeEditIT extends AbstractDaemonTest {
@TestProjectInput(createEmptyCommit = false)
public void updateRootCommitMessage() throws Exception {
// Re-clone empty repo; TestRepository doesn't let us reset to unborn head.
testRepo = cloneProject(project, sshSession);
testRepo = cloneProject(project);
changeId = newChange(admin.getIdent());
change = getChange(changeId);