Merge branch 'stable-2.12' into stable-2.13

* stable-2.12:
  Fix broken submit tests
  Add @Sandboxed annotation for classes and methods
  Add tests for submit whole topic on multiple projects/branches
  Update download-commands plugin

It seems no longer necessary to run the submit tests sandboxed, so
remove that annotation.

Change-Id: I442ed6efc045bff51259b8d08915b8a1cc1e2eb0
This commit is contained in:
David Pursehouse
2016-11-14 11:51:15 -08:00
6 changed files with 173 additions and 14 deletions

View File

@@ -29,6 +29,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.common.primitives.Chars;
import com.google.gerrit.acceptance.AcceptanceTestRequestScope.Context;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
@@ -322,7 +323,8 @@ public abstract class AbstractDaemonTest {
baseConfig.setString("gerrit", null, "tempSiteDir",
tempSiteDir.getRoot().getPath());
baseConfig.setInt("receive", null, "changeUpdateThreads", 4);
if (classDesc.equals(methodDesc)) {
if (classDesc.equals(methodDesc) && !classDesc.sandboxed() &&
!methodDesc.sandboxed()) {
if (commonServer == null) {
commonServer = GerritServer.start(classDesc, baseConfig);
}
@@ -940,4 +942,13 @@ public abstract class AbstractDaemonTest {
(EmailHeader.String)message.headers().get("Reply-To");
assertThat(replyTo.getString()).isEqualTo(email);
}
protected TestRepository<?> createProjectWithPush(String name,
@Nullable Project.NameKey parent,
SubmitType submitType) throws Exception {
Project.NameKey project = createProject(name, parent, true, submitType);
grant(Permission.PUSH, project, "refs/heads/*");
grant(Permission.SUBMIT, project, "refs/for/refs/heads/*");
return cloneProject(project);
}
}

View File

@@ -42,6 +42,7 @@ import org.eclipse.jgit.lib.RepositoryCache;
import org.eclipse.jgit.util.FS;
import java.io.File;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -61,7 +62,8 @@ public class GerritServer {
return new AutoValue_GerritServer_Description(
configName,
true, // @UseLocalDisk is only valid on methods.
!hasNoHttpd(testDesc.getTestClass()),
!has(NoHttpd.class, testDesc.getTestClass()),
has(Sandboxed.class, testDesc.getTestClass()),
null, // @GerritConfig is only valid on methods.
null); // @GerritConfigs is only valid on methods.
@@ -73,14 +75,17 @@ public class GerritServer {
configName,
testDesc.getAnnotation(UseLocalDisk.class) == null,
testDesc.getAnnotation(NoHttpd.class) == null
&& !hasNoHttpd(testDesc.getTestClass()),
&& !has(NoHttpd.class, testDesc.getTestClass()),
testDesc.getAnnotation(Sandboxed.class) != null ||
has(Sandboxed.class, testDesc.getTestClass()),
testDesc.getAnnotation(GerritConfig.class),
testDesc.getAnnotation(GerritConfigs.class));
}
private static boolean hasNoHttpd(Class<?> clazz) {
private static boolean has(
Class<? extends Annotation> annotation, Class<?> clazz) {
for (; clazz != null; clazz = clazz.getSuperclass()) {
if (clazz.getAnnotation(NoHttpd.class) != null) {
if (clazz.getAnnotation(annotation) != null) {
return true;
}
}
@@ -90,6 +95,7 @@ public class GerritServer {
@Nullable abstract String configName();
abstract boolean memory();
abstract boolean httpd();
abstract boolean sandboxed();
@Nullable abstract GerritConfig config();
@Nullable abstract GerritConfigs configs();

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Target({TYPE, METHOD})
@Retention(RUNTIME)
public @interface Sandboxed {
}