commit 1efffb1212728dde7174ebac1cb199653e5a2df1 Merge: e1b692c 7f9b8ca Author: Marco Miller Date: Tue Oct 6 14:13:30 2020 -0400 Merge branch 'stable-3.2' into master * stable-3.2: Update git submodules Update git submodules TestProjectCreation: Add permissionsOnly setting Bump Bazel version to 3.5.1 Upgrade jackson-core to 2.11.3 Update git submodules Register graceful shutdown for version command Register graceful shutdown for show queue command Register graceful shutdown for show connections command Register graceful shutdown for show caches command Register graceful shutdown for set reviewers command Register graceful shutdown for set project command Register graceful shutdown for set parent command Register graceful shutdown for set members command Register graceful shutdown for set logging level command Register graceful shutdown for set head command Register graceful shutdown for set account command Register graceful shutdown for review command Register graceful shutdown for rename group command Register graceful shutdown for reload config command Register graceful shutdown for query command Register graceful shutdown for list plugins command Register graceful shutdown for plugin admin commands Register graceful shutdown for list user refs command Register graceful shutdown for list projects command Register graceful shutdown for list members command Register graceful shutdown for list logging level command Register graceful shutdown for list groups command Register graceful shutdown for kill command Register graceful shutdown for index start command Register graceful shutdown for index changes in project command Register graceful shutdown for index changes command Register graceful shutdown for index activate command Register graceful shutdown for gc command Register graceful shutdown for flush caches command Register graceful shutdown for create project command Register graceful shutdown for create group command Register graceful shutdown for create branch command Register graceful shutdown for create account command Register graceful shutdown for close connection command Register graceful shutdown for prolog test commands Register graceful shutdown for ban commit command Register graceful shutdown for apropos command Limit graceful shutdown to SSH sessions serving git requests Update git submodules Change-Id: Ida356170ca8ea3678d7ce4e2172f0ae46006a675 diff --cc java/com/google/gerrit/acceptance/AbstractDaemonTest.java index 78a621c,f29cdb2..c35c9c2 --- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java +++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java @@@ -429,16 -438,16 +438,19 @@@ public abstract class AbstractDaemonTes baseConfig.setInt("receive", null, "changeUpdateThreads", 4); Module module = createModule(); + Module auditModule = createAuditModule(); + Module sshModule = createSshModule(); if (classDesc.equals(methodDesc) && !classDesc.sandboxed() && !methodDesc.sandboxed()) { if (commonServer == null) { commonServer = - GerritServer.initAndStart(temporaryFolder, classDesc, baseConfig, module, auditModule); - GerritServer.initAndStart(temporaryFolder, classDesc, baseConfig, module, sshModule); ++ GerritServer.initAndStart( ++ temporaryFolder, classDesc, baseConfig, module, auditModule, sshModule); } server = commonServer; } else { server = - GerritServer.initAndStart(temporaryFolder, methodDesc, baseConfig, module, auditModule); - GerritServer.initAndStart(temporaryFolder, methodDesc, baseConfig, module, sshModule); ++ GerritServer.initAndStart( ++ temporaryFolder, methodDesc, baseConfig, module, auditModule, sshModule); } server.getTestInjector().injectMembers(this); @@@ -531,11 -540,11 +543,16 @@@ return null; } + /** Override to bind an alternative audit Guice module */ + public Module createAuditModule() { + return null; + } + + /** Override to bind an additional Guice module for SSH injector */ + public Module createSshModule() { + return null; + } + protected void initSsh() throws Exception { if (testRequiresSsh && SshMode.useSsh() diff --cc java/com/google/gerrit/acceptance/GerritServer.java index 5942c0f,3d7d9a7..0025396 --- a/java/com/google/gerrit/acceptance/GerritServer.java +++ b/java/com/google/gerrit/acceptance/GerritServer.java @@@ -331,14 -326,14 +332,15 @@@ public class GerritServer implements Au Description desc, Config baseConfig, @Nullable Module testSysModule, - @Nullable Module testAuditModule) ++ @Nullable Module testAuditModule, + @Nullable Module testSshModule) throws Exception { Path site = temporaryFolder.newFolder().toPath(); try { if (!desc.memory()) { init(desc, baseConfig, site); } - return start(desc, baseConfig, site, testSysModule, testAuditModule, null); - return start(desc, baseConfig, site, testSysModule, testSshModule, null); ++ return start(desc, baseConfig, site, testSysModule, testAuditModule, testSshModule, null); } catch (Exception e) { throw e; } @@@ -366,7 -362,7 +369,8 @@@ Config baseConfig, Path site, @Nullable Module testSysModule, + @Nullable Module testAuditModule, + @Nullable Module testSshModule, @Nullable InMemoryRepositoryManager inMemoryRepoManager, String... additionalArgs) throws Exception { @@@ -614,7 -608,24 +621,24 @@@ server.close(); server.daemon.stop(); -- return start(server.desc, cfg, site, null, null, inMemoryRepoManager); ++ return start(server.desc, cfg, site, null, null, null, inMemoryRepoManager); + } + + public static GerritServer restart( + GerritServer server, @Nullable Module testSysModule, @Nullable Module testSshModule) + throws Exception { + checkState(server.desc.sandboxed(), "restarting as slave requires @Sandboxed"); + Config cfg = server.testInjector.getInstance(Key.get(Config.class, GerritServerConfig.class)); + Path site = server.testInjector.getInstance(Key.get(Path.class, SitePath.class)); + + InMemoryRepositoryManager inMemoryRepoManager = null; + if (hasBinding(server.testInjector, InMemoryRepositoryManager.class)) { + inMemoryRepoManager = server.testInjector.getInstance(InMemoryRepositoryManager.class); + } + + server.close(); + server.daemon.stop(); - return start(server.desc, cfg, site, testSysModule, testSshModule, inMemoryRepoManager); ++ return start(server.desc, cfg, site, testSysModule, null, testSshModule, inMemoryRepoManager); } private static boolean hasBinding(Injector injector, Class clazz) { diff --cc java/com/google/gerrit/acceptance/StandaloneSiteTest.java index 43fe4eb,43fe4eb..dcb49a5 --- a/java/com/google/gerrit/acceptance/StandaloneSiteTest.java +++ b/java/com/google/gerrit/acceptance/StandaloneSiteTest.java @@@ -187,7 -187,7 +187,14 @@@ public abstract class StandaloneSiteTes private GerritServer startImpl(@Nullable Module testSysModule, String... additionalArgs) throws Exception { return GerritServer.start( -- serverDesc, baseConfig, sitePaths.site_path, testSysModule, null, null, additionalArgs); ++ serverDesc, ++ baseConfig, ++ sitePaths.site_path, ++ testSysModule, ++ null, ++ null, ++ null, ++ additionalArgs); } protected static void runGerrit(String... args) throws Exception { diff --cc java/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImpl.java index e4d594b,80d8c09..0138290 --- a/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImpl.java +++ b/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImpl.java @@@ -90,8 -91,8 +90,9 @@@ public class ProjectOperationsImpl impl CreateProjectArgs args = new CreateProjectArgs(); args.setProjectName(name); + args.permissionsOnly = projectCreation.permissionOnly().orElse(false); - args.branch = Collections.singletonList(Constants.R_HEADS + Constants.MASTER); + args.branch = + projectCreation.branches().stream().map(RefNames::fullName).collect(toImmutableList()); args.createEmptyCommit = projectCreation.createEmptyCommit().orElse(true); projectCreation.parent().ifPresent(p -> args.newParent = p); // ProjectCreator wants non-null owner IDs. diff --cc java/com/google/gerrit/acceptance/testsuite/project/TestProjectCreation.java index 2649dea,cb68d7a..00759a0 --- a/java/com/google/gerrit/acceptance/testsuite/project/TestProjectCreation.java +++ b/java/com/google/gerrit/acceptance/testsuite/project/TestProjectCreation.java @@@ -31,10 -27,10 +31,12 @@@ public abstract class TestProjectCreati public abstract Optional parent(); + public abstract ImmutableSet branches(); + public abstract Optional createEmptyCommit(); + public abstract Optional permissionOnly(); + public abstract Optional submitType(); abstract ThrowingFunction projectCreator(); @@@ -54,19 -48,10 +56,21 @@@ public abstract TestProjectCreation.Builder submitType(SubmitType submitType); + /** + * Branches which should be created in the repository (with an empty root commit). The + * "refs/heads/" prefix of the branch name can be omitted. The specified branches are ignored if + * {@link #noEmptyCommit()} is used. + */ + public TestProjectCreation.Builder branches(String branch1, String... otherBranches) { + return branches(Sets.union(ImmutableSet.of(branch1), ImmutableSet.copyOf(otherBranches))); + } + + abstract TestProjectCreation.Builder branches(Set branches); + public abstract TestProjectCreation.Builder createEmptyCommit(boolean value); + public abstract TestProjectCreation.Builder permissionOnly(boolean value); + /** Skips the empty commit on creation. This means that project's branches will not exist. */ public TestProjectCreation.Builder noEmptyCommit() { return createEmptyCommit(false); diff --cc javatests/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImplTest.java index 62dfc63,246d764..b888102 --- a/javatests/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImplTest.java +++ b/javatests/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImplTest.java @@@ -36,11 -37,11 +36,12 @@@ import static java.util.stream.Collecto import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; +import com.google.common.truth.Correspondence; import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.TestPermission; -import com.google.gerrit.common.data.Permission; +import com.google.gerrit.entities.Permission; import com.google.gerrit.entities.Project; + import com.google.gerrit.entities.RefNames; import com.google.gerrit.extensions.api.projects.BranchInfo; import com.google.gerrit.extensions.api.projects.ConfigInput; import com.google.gerrit.server.project.ProjectConfig; @@@ -84,33 -85,10 +85,40 @@@ public class ProjectOperationsImplTest } @Test + public void specifiedBranchesAreCreatedInNewProject() throws Exception { + Project.NameKey project = + projectOperations + .newProject() + .branches("test-branch", "refs/heads/another-test-branch") + .create(); + + List branches = gApi.projects().name(project.get()).branches().get(); + assertThat(branches) + .comparingElementsUsing(hasBranchName()) + .containsAtLeast("refs/heads/test-branch", "refs/heads/another-test-branch"); + } + + @Test + public void specifiedBranchesAreNotCreatedInNewProjectIfNoEmptyCommitRequested() + throws Exception { + Project.NameKey project = + projectOperations + .newProject() + .branches("test-branch", "refs/heads/another-test-branch") + .noEmptyCommit() + .create(); + + List branches = gApi.projects().name(project.get()).branches().get(); + assertThat(branches) + .comparingElementsUsing(hasBranchName()) + .containsNoneOf("refs/heads/test-branch", "refs/heads/another-test-branch"); ++ } ++ ++ @Test + public void permissionOnly() throws Exception { + Project.NameKey key = projectOperations.newProject().permissionOnly(true).create(); + String head = gApi.projects().name(key.get()).head(); + assertThat(head).isEqualTo(RefNames.REFS_CONFIG); } @Test