Merge branch 'stable-2.16'

* stable-2.16:
  Mark greenmail as testonly
  Bazel: Fix testonly values in BUILD and .bzl files
  ListBranchesIT: Also assert on the expected ref of refs/meta/config
  Consistently define default serialVersionUID
  Scripts: Use bash in shebang
  GroupsUpdate: Evict group caches on group creation

Change-Id: Ide87f2555d458c93c351d48693af520a3a80b656
This commit is contained in:
David Pursehouse
2018-12-20 22:28:53 +09:00
60 changed files with 101 additions and 65 deletions

2
BUILD
View File

@@ -67,7 +67,7 @@ API_DEPS = [
genrule2(
name = "api",
testonly = 1,
testonly = True,
srcs = API_DEPS,
outs = ["api.zip"],
cmd = " && ".join([

View File

@@ -2,7 +2,7 @@ load("//tools/bzl:java.bzl", "java_library2")
java_library(
name = "lib",
testonly = 1,
testonly = True,
resource_strip_prefix = "resources",
resources = ["//resources/com/google/gerrit/acceptance"],
visibility = ["//visibility:public"],
@@ -57,7 +57,7 @@ java_library(
java_binary(
name = "framework",
testonly = 1,
testonly = True,
main_class = "Dummy",
visibility = ["//visibility:public"],
runtime_deps = [":framework-lib"],
@@ -65,7 +65,7 @@ java_binary(
java_library2(
name = "framework-lib",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
exported_deps = [
"//java/com/google/gerrit/gpg",
@@ -132,7 +132,7 @@ load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc(
name = "framework-javadoc",
testonly = 1,
testonly = True,
libs = [":framework-lib"],
pkgs = ["com.google.gerrit.acceptance"],
title = "Gerrit Acceptance Test Framework Documentation",

View File

@@ -1,6 +1,6 @@
java_library(
name = "common-data-test-util",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -1,6 +1,6 @@
java_library(
name = "common-test-util",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -1,6 +1,6 @@
java_library(
name = "restapi-test-util",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -1,4 +1,4 @@
package(default_testonly = 1)
package(default_testonly = True)
java_library(
name = "testing",

View File

@@ -1,6 +1,6 @@
java_library(
name = "gpg-test-util",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -53,9 +53,10 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@SuppressWarnings("serial")
@Singleton
class BecomeAnyAccountLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final DynamicItem<WebSession> webSession;
private final Accounts accounts;
private final AccountCache accountCache;

View File

@@ -46,9 +46,10 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/** Handles username/password based authentication against the directory. */
@SuppressWarnings("serial")
@Singleton
class LdapLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final AccountManager accountManager;

View File

@@ -52,9 +52,10 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/** Handles OpenID based login flow. */
@SuppressWarnings("serial")
@Singleton
class LoginForm extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final ImmutableMap<String, String> ALL_PROVIDERS =

View File

@@ -23,9 +23,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** Handles the {@code /OpenID} URL for web based single-sign-on. */
@SuppressWarnings("serial")
@Singleton
class OpenIdLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final OpenIdServiceImpl impl;
@Inject

View File

@@ -32,9 +32,10 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
@Singleton
class GitLogoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final long modified;
private final byte[] raw;

View File

@@ -32,10 +32,13 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
abstract class GitwebCssServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Singleton
static class Site extends GitwebCssServlet {
private static final long serialVersionUID = 1L;
@Inject
Site(SitePaths paths) throws IOException {
super(paths.site_css);
@@ -44,6 +47,8 @@ abstract class GitwebCssServlet extends HttpServlet {
@Singleton
static class Default extends GitwebCssServlet {
private static final long serialVersionUID = 1L;
@Inject
Default(GitwebCgiConfig gwcc) throws IOException {
super(gwcc.getGitwebCss());

View File

@@ -32,9 +32,10 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
@Singleton
class GitwebJavaScriptServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final long modified;
private final byte[] raw;

View File

@@ -89,9 +89,10 @@ import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Repository;
/** Invokes {@code gitweb.cgi} for the project given in {@code p}. */
@SuppressWarnings("serial")
@Singleton
class GitwebServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String PROJECT_LIST_ACTION = "project_list";

View File

@@ -47,9 +47,10 @@ import org.eclipse.jgit.lib.ObjectId;
* this site, and will execute it with the site's own protection domain. This opens a massive
* security hole so we package the content into a zip file.
*/
@SuppressWarnings("serial")
@Singleton
public class CatServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final ChangeEditUtil changeEditUtil;
private final PatchSetUtil psUtil;
private final ChangeNotes.Factory changeNotesFactory;

View File

@@ -34,9 +34,10 @@ import javax.servlet.http.HttpServletResponse;
* as it would lose any history token that appears in the URL. Instead we send an HTML page which
* instructs the browser to replace the URL, but preserve the history token.
*/
@SuppressWarnings("serial")
@Singleton
public class LegacyGerritServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final byte[] raw;
private final byte[] compressed;

View File

@@ -46,9 +46,10 @@ import javax.servlet.http.HttpServletResponse;
* Port 8010
* }</pre>
*/
@SuppressWarnings("serial")
@Singleton
public class SshInfoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final SshInfo sshd;
@Inject

View File

@@ -1554,8 +1554,9 @@ public class RestApiServlet extends HttpServlet {
return new TemporaryBuffer.Heap(est, max);
}
@SuppressWarnings("serial")
private static class AmbiguousViewException extends Exception {
private static final long serialVersionUID = 1L;
AmbiguousViewException(String message) {
super(message);
}

View File

@@ -1,4 +1,4 @@
package(default_testonly = 1)
package(default_testonly = True)
java_library(
name = "testing",

View File

@@ -50,4 +50,6 @@ public abstract class AccountDirectory {
public abstract void fillAccountInfo(Iterable<? extends AccountInfo> in, Set<FillOptions> options)
throws PermissionBackendException;
private static final long serialVersionUID = 1L;
}

View File

@@ -1,4 +1,4 @@
package(default_testonly = 1)
package(default_testonly = True)
java_library(
name = "testing",

View File

@@ -17,8 +17,9 @@ package com.google.gerrit.server.config;
import com.google.gerrit.reviewdb.client.Project;
/** Special name of the project that all projects derive from. */
@SuppressWarnings("serial")
public class AllProjectsName extends Project.NameKey {
private static final long serialVersionUID = 1L;
public AllProjectsName(String name) {
super(name);
}

View File

@@ -17,8 +17,9 @@ package com.google.gerrit.server.config;
import com.google.gerrit.reviewdb.client.Project;
/** Special name of the project in which meta data for all users is stored. */
@SuppressWarnings("serial")
public class AllUsersName extends Project.NameKey {
private static final long serialVersionUID = 1L;
public AllUsersName(String name) {
super(name);
}

View File

@@ -129,8 +129,9 @@ public class QueryDocumentationExecutor {
return parser != null && searcher != null;
}
@SuppressWarnings("serial")
public static class DocQueryException extends Exception {
private static final long serialVersionUID = 1L;
DocQueryException() {}
DocQueryException(String msg) {

View File

@@ -345,6 +345,9 @@ public class GroupsUpdate {
}
private void updateCachesOnGroupCreation(InternalGroup createdGroup) throws IOException {
groupCache.evict(createdGroup.getGroupUUID());
groupCache.evict(createdGroup.getId());
groupCache.evict(createdGroup.getNameKey());
indexer.get().index(createdGroup.getGroupUUID());
createdGroup.getMembers().forEach(groupIncludeCache::evictGroupsWithMember);
createdGroup.getSubgroups().forEach(groupIncludeCache::evictParentGroupsOf);

View File

@@ -2,7 +2,7 @@ package(default_visibility = ["//visibility:public"])
java_library(
name = "testing",
testonly = 1,
testonly = True,
srcs = glob(["*.java"]),
deps = [
"//java/com/google/gerrit/common:server",

View File

@@ -2,7 +2,7 @@ package(default_visibility = ["//visibility:public"])
java_library(
name = "testing",
testonly = 1,
testonly = True,
srcs = glob(["*.java"]),
deps = [
"//java/com/google/gerrit/common:server",

View File

@@ -1,6 +1,6 @@
java_library(
name = "project-test-util",
testonly = 1,
testonly = True,
srcs = glob(["*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -1,4 +1,4 @@
package(default_testonly = 1)
package(default_testonly = True)
java_library(
name = "testing",

View File

@@ -1,6 +1,6 @@
java_library(
name = "gerrit-test-util",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
exports = [

View File

@@ -1,6 +1,6 @@
java_library(
name = "truth",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.api.group;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.acceptance.GitUtil.deleteRef;
import static com.google.gerrit.acceptance.GitUtil.fetch;
import static com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo;
@@ -206,6 +207,15 @@ public class GroupsIT extends AbstractDaemonTest {
assertThat(groupsWithMemberAfterRemoval).doesNotContain(groupUuid);
}
@Test
public void cachedGroupByNameIsUpdatedOnCreation() throws Exception {
String newGroupName = name("newGroup");
AccountGroup.NameKey nameKey = new AccountGroup.NameKey(newGroupName);
assertThat(groupCache.get(nameKey)).isEmpty();
gApi.groups().create(newGroupName);
assertThat(groupCache.get(nameKey)).isPresent();
}
@Test
public void addExistingMember_OK() throws Exception {
String g = "Administrators";

View File

@@ -13,7 +13,7 @@ acceptance_tests(
java_library(
name = "push_for_review",
testonly = 1,
testonly = True,
srcs = ["AbstractPushForReview.java"],
deps = [
"//java/com/google/gerrit/acceptance:lib",
@@ -23,7 +23,7 @@ java_library(
java_library(
name = "submodule_util",
testonly = 1,
testonly = True,
srcs = ["AbstractSubmoduleSubscription.java"],
deps = ["//java/com/google/gerrit/acceptance:lib"],
)

View File

@@ -41,7 +41,7 @@ acceptance_tests(
java_library(
name = "util",
testonly = 1,
testonly = True,
srcs = [
"AbstractReindexTests.java",
"IndexUpgradeController.java",

View File

@@ -9,7 +9,7 @@ acceptance_tests(
java_library(
name = "util",
testonly = 1,
testonly = True,
srcs = [
"AccountAssert.java",
"CapabilityInfo.java",

View File

@@ -30,7 +30,7 @@ acceptance_tests(
java_library(
name = "submit_util",
testonly = 1,
testonly = True,
srcs = SUBMIT_UTIL_SRCS,
deps = [
"//java/com/google/gerrit/acceptance:lib",

View File

@@ -41,7 +41,7 @@ java_library(
java_library(
name = "push_tag_util",
testonly = 1,
testonly = True,
srcs = [
"AbstractPushTag.java",
],

View File

@@ -55,10 +55,11 @@ public class ListBranchesIT extends AbstractDaemonTest {
public void listBranches() throws Exception {
String master = pushTo("refs/heads/master").getCommit().name();
String dev = pushTo("refs/heads/dev").getCommit().name();
String refsConfig = getRemoteHead(project, RefNames.REFS_CONFIG).name();
assertRefs(
ImmutableList.of(
branch("HEAD", "master", false),
branch(RefNames.REFS_CONFIG, null, false),
branch(RefNames.REFS_CONFIG, refsConfig, false),
branch("refs/heads/dev", dev, true),
branch("refs/heads/master", master, false)),
list().get());
@@ -90,7 +91,8 @@ public class ListBranchesIT extends AbstractDaemonTest {
@Test
public void listBranchesUsingPagination() throws Exception {
BranchInfo head = branch("HEAD", "master", false);
BranchInfo refsConfig = branch(RefNames.REFS_CONFIG, null, false);
BranchInfo refsConfig =
branch(RefNames.REFS_CONFIG, getRemoteHead(project, RefNames.REFS_CONFIG).name(), false);
BranchInfo master =
branch("refs/heads/master", pushTo("refs/heads/master").getCommit().getName(), false);
BranchInfo branch1 =

View File

@@ -1,6 +1,6 @@
java_library(
name = "util",
testonly = 1,
testonly = True,
srcs = glob(["*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -21,7 +21,7 @@ acceptance_tests(
java_library(
name = "util",
testonly = 1,
testonly = True,
srcs = ["AbstractMailIT.java"],
deps = DEPS + ["//java/com/google/gerrit/acceptance:lib"],
)

View File

@@ -2,7 +2,7 @@ load("//javatests/com/google/gerrit/acceptance:tests.bzl", "acceptance_tests")
java_library(
name = "util",
testonly = 1,
testonly = True,
srcs = ["AbstractIndexTests.java"],
deps = ["//java/com/google/gerrit/acceptance:lib"],
)

View File

@@ -2,7 +2,7 @@ load("//tools/bzl:junit.bzl", "junit_tests")
java_library(
name = "elasticsearch_test_utils",
testonly = 1,
testonly = True,
srcs = [
"ElasticContainer.java",
"ElasticTestUtils.java",

View File

@@ -6,7 +6,7 @@ CUSTOM_TRUTH_SUBJECTS = glob([
java_library(
name = "custom-truth-subjects",
testonly = 1,
testonly = True,
srcs = CUSTOM_TRUTH_SUBJECTS,
deps = [
"//java/com/google/gerrit/extensions:api",

View File

@@ -4,7 +4,7 @@ ABSTRACT_QUERY_TEST = ["AbstractQueryAccountsTest.java"]
java_library(
name = "abstract_query_tests",
testonly = 1,
testonly = True,
srcs = ABSTRACT_QUERY_TEST,
visibility = ["//visibility:public"],
deps = [

View File

@@ -4,7 +4,7 @@ ABSTRACT_QUERY_TEST = ["AbstractQueryChangesTest.java"]
java_library(
name = "abstract_query_tests",
testonly = 1,
testonly = True,
srcs = ABSTRACT_QUERY_TEST,
visibility = ["//visibility:public"],
runtime_deps = ["//prolog:gerrit-prolog-common"],

View File

@@ -4,7 +4,7 @@ ABSTRACT_QUERY_TEST = ["AbstractQueryGroupsTest.java"]
java_library(
name = "abstract_query_tests",
testonly = 1,
testonly = True,
srcs = ABSTRACT_QUERY_TEST,
visibility = ["//visibility:public"],
deps = [

View File

@@ -4,7 +4,7 @@ ABSTRACT_QUERY_TEST = ["AbstractQueryProjectsTest.java"]
java_library(
name = "abstract_query_tests",
testonly = 1,
testonly = True,
srcs = ABSTRACT_QUERY_TEST,
visibility = ["//visibility:public"],
deps = [

View File

@@ -1,6 +1,6 @@
java_library(
name = "testutil",
testonly = 1,
testonly = True,
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [

View File

@@ -4,14 +4,14 @@ POST_JDK8_DEPS = [":javax-activation"]
java_library(
name = "javax-activation",
testonly = 1,
testonly = True,
data = ["//lib:LICENSE-DO_NOT_DISTRIBUTE"],
exports = ["@javax-activation//jar"],
)
java_library(
name = "greenmail",
testonly = 1,
testonly = True,
data = ["//lib:LICENSE-Apache2.0"],
exports = ["@greenmail//jar"],
runtime_deps = select({

View File

@@ -2,7 +2,7 @@ load("//lib/jgit:jgit.bzl", "jgit_dep")
java_library(
name = "junit",
testonly = 1,
testonly = True,
data = ["//lib:LICENSE-DO_NOT_DISTRIBUTE"],
visibility = ["//visibility:public"],
exports = [jgit_dep("@jgit-junit//jar")],

View File

@@ -1,5 +1,5 @@
package(
default_testonly = 1,
default_testonly = True,
default_visibility = ["//visibility:private"],
)

View File

@@ -38,7 +38,7 @@ java_library(
java_library(
name = "testcontainers-elasticsearch",
testonly = 1,
testonly = True,
data = ["//lib:LICENSE-testcontainers"],
visibility = ["//visibility:public"],
exports = ["@testcontainers-elasticsearch//jar"],

View File

@@ -23,7 +23,7 @@ polygerrit_bundle(
bower_component_bundle(
name = "test_components",
testonly = 1,
testonly = True,
deps = [
"//lib/js:iron-test-helpers",
"//lib/js:test-fixture",

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -ex

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -ex

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Usage
#

View File

@@ -25,13 +25,13 @@ DEPS = [
java_library(
name = "classpath",
testonly = 1,
testonly = True,
runtime_deps = LIBS + PGMLIBS + DEPS,
)
classpath_collector(
name = "main_classpath_collect",
testonly = 1,
testonly = True,
deps = LIBS + PGMLIBS + DEPS + TEST_DEPS +
["//plugins/%s:%s__plugin" % (n, n) for n in CORE_PLUGINS + CUSTOM_PLUGINS] +
["//plugins/%s:%s__plugin_test_deps" % (n, n) for n in CUSTOM_PLUGINS_TEST_DEPS],

View File

@@ -50,7 +50,7 @@ def maven_package(
srcs = api_targets,
outs = ["api_install.sh"],
executable = True,
testonly = 1,
testonly = True,
)
if repository and url:
@@ -70,7 +70,7 @@ def maven_package(
srcs = api_targets,
outs = ["api_deploy.sh"],
executable = True,
testonly = 1,
testonly = True,
)
war_cmd = mvn_cmd[:]