Merge branch 'stable-2.14' into stable-2.15
* stable-2.14: AbstractElasticIndex: Don't mention "change" in exception message Consistently import org.slf4j.LoggerFactory PluginLoader: Make Logger private Documentation: clarify latest IntelliJ version use Elasticsearch builders: fix the Eclipse warnings Remove stale references to no longer used jackson libraries Add 'docker' tag to build rules for Elasticsearch tests ReindexIT: Split Elasticsearch test out to a separate class Due to change I7c1461c45 ("ReindexIT: Split Elasticsearch test out to a separate class") it is now possible to re-introduce the other changes that were reverted in previous merges from stable-2.14 to stable-2.15: - Iccf443102 ("Acceptance tests: Replace embedded ES with docker testcontainer") - I57e5d0718 ("Acceptance tests: Remove ES bootstrap boilerplate") Although the reindex tests for Elasticsearch still don't work on the stable-2.15 branch (issue 8799), they are now isolated in their own class and the tests can be skipped using the @Ignore annotation. Change-Id: Ia19ea3fc68d80e0d20ff3cbed2baa49981db401e
This commit is contained in:
@@ -239,6 +239,12 @@ To exclude tests that have been marked as flaky:
|
|||||||
bazel test --test_tag_filters=-flaky //...
|
bazel test --test_tag_filters=-flaky //...
|
||||||
----
|
----
|
||||||
|
|
||||||
|
To exclude tests that require a Docker host:
|
||||||
|
|
||||||
|
----
|
||||||
|
bazel test --test_tag_filters=-docker //...
|
||||||
|
----
|
||||||
|
|
||||||
To ignore cached test results:
|
To ignore cached test results:
|
||||||
|
|
||||||
----
|
----
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
= Gerrit Code Review - IntelliJ Setup
|
= Gerrit Code Review - IntelliJ Setup
|
||||||
|
|
||||||
== Prerequisites
|
== Prerequisites
|
||||||
You need an installation of IntelliJ of version 2016.2.
|
You need an installation of IntelliJ version 2016.2 or later. The latest version
|
||||||
|
might not yet be in-sync with the Bazel plugin for IntelliJ. It usually becomes
|
||||||
|
so quite quickly after new IDEA versions get released, though. It should then be
|
||||||
|
possible to use the fairly latest IntelliJ release with an updated Bazel plugin.
|
||||||
|
|
||||||
In addition, Java 8 must be specified on your path or via `JAVA_HOME` so that
|
In addition, Java 8 must be specified on your path or via `JAVA_HOME` so that
|
||||||
building with Bazel via the Bazel plugin is possible.
|
building with Bazel via the Bazel plugin is possible.
|
||||||
|
@@ -0,0 +1,189 @@
|
|||||||
|
// Copyright (C) 2014 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.pgm;
|
||||||
|
|
||||||
|
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
|
import static com.google.gerrit.extensions.client.ListGroupsOption.MEMBERS;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.io.MoreFiles;
|
||||||
|
import com.google.common.io.RecursiveDeleteOption;
|
||||||
|
import com.google.gerrit.acceptance.NoHttpd;
|
||||||
|
import com.google.gerrit.acceptance.StandaloneSiteTest;
|
||||||
|
import com.google.gerrit.acceptance.pgm.IndexUpgradeController.UpgradeAttempt;
|
||||||
|
import com.google.gerrit.extensions.api.GerritApi;
|
||||||
|
import com.google.gerrit.extensions.common.ChangeInput;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gerrit.server.index.GerritIndexStatus;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeSchemaDefinitions;
|
||||||
|
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Provider;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.eclipse.jgit.storage.file.FileBasedConfig;
|
||||||
|
import org.eclipse.jgit.util.FS;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@NoHttpd
|
||||||
|
@Ignore
|
||||||
|
public abstract class AbstractReindexIT extends StandaloneSiteTest {
|
||||||
|
/** @param injector injector */
|
||||||
|
public abstract void configureIndex(Injector injector) throws Exception;
|
||||||
|
|
||||||
|
private static final String CHANGES = ChangeSchemaDefinitions.NAME;
|
||||||
|
|
||||||
|
private Project.NameKey project;
|
||||||
|
private String changeId;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void reindexFromScratch() throws Exception {
|
||||||
|
setUpChange();
|
||||||
|
|
||||||
|
MoreFiles.deleteRecursively(sitePaths.index_dir, RecursiveDeleteOption.ALLOW_INSECURE);
|
||||||
|
Files.createDirectory(sitePaths.index_dir);
|
||||||
|
assertServerStartupFails();
|
||||||
|
|
||||||
|
runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
|
||||||
|
assertReady(ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion());
|
||||||
|
|
||||||
|
try (ServerContext ctx = startServer()) {
|
||||||
|
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
|
||||||
|
// Query change index
|
||||||
|
assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId))
|
||||||
|
.containsExactly(changeId);
|
||||||
|
// Query account index
|
||||||
|
assertThat(gApi.accounts().query("admin").get().stream().map(a -> a._accountId))
|
||||||
|
.containsExactly(adminId.get());
|
||||||
|
// Query group index
|
||||||
|
assertThat(
|
||||||
|
gApi.groups()
|
||||||
|
.query("Group")
|
||||||
|
.withOption(MEMBERS)
|
||||||
|
.get()
|
||||||
|
.stream()
|
||||||
|
.flatMap(g -> g.members.stream())
|
||||||
|
.map(a -> a._accountId))
|
||||||
|
.containsExactly(adminId.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onlineUpgradeChanges() throws Exception {
|
||||||
|
int prevVersion = ChangeSchemaDefinitions.INSTANCE.getPrevious().getVersion();
|
||||||
|
int currVersion = ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion();
|
||||||
|
|
||||||
|
// Before storing any changes, switch back to the previous version.
|
||||||
|
GerritIndexStatus status = new GerritIndexStatus(sitePaths);
|
||||||
|
status.setReady(CHANGES, currVersion, false);
|
||||||
|
status.setReady(CHANGES, prevVersion, true);
|
||||||
|
status.save();
|
||||||
|
assertReady(prevVersion);
|
||||||
|
|
||||||
|
setOnlineUpgradeConfig(false);
|
||||||
|
setUpChange();
|
||||||
|
setOnlineUpgradeConfig(true);
|
||||||
|
|
||||||
|
IndexUpgradeController u = new IndexUpgradeController(1);
|
||||||
|
try (ServerContext ctx = startServer(u.module())) {
|
||||||
|
assertSearchVersion(ctx, prevVersion);
|
||||||
|
assertWriteVersions(ctx, prevVersion, currVersion);
|
||||||
|
|
||||||
|
// Updating and searching old schema version works.
|
||||||
|
Provider<InternalChangeQuery> queryProvider =
|
||||||
|
ctx.getInjector().getProvider(InternalChangeQuery.class);
|
||||||
|
assertThat(queryProvider.get().byKey(new Change.Key(changeId))).hasSize(1);
|
||||||
|
assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
|
||||||
|
|
||||||
|
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
|
||||||
|
gApi.changes().id(changeId).topic("topic1");
|
||||||
|
assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
|
||||||
|
|
||||||
|
u.runUpgrades();
|
||||||
|
assertThat(u.getStartedAttempts())
|
||||||
|
.containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
|
||||||
|
assertThat(u.getSucceededAttempts())
|
||||||
|
.containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
|
||||||
|
assertThat(u.getFailedAttempts()).isEmpty();
|
||||||
|
|
||||||
|
assertReady(currVersion);
|
||||||
|
assertSearchVersion(ctx, currVersion);
|
||||||
|
assertWriteVersions(ctx, currVersion);
|
||||||
|
|
||||||
|
// Updating and searching new schema version works.
|
||||||
|
assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
|
||||||
|
assertThat(queryProvider.get().byTopicOpen("topic2")).isEmpty();
|
||||||
|
gApi.changes().id(changeId).topic("topic2");
|
||||||
|
assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
|
||||||
|
assertThat(queryProvider.get().byTopicOpen("topic2")).hasSize(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpChange() throws Exception {
|
||||||
|
project = new Project.NameKey("project");
|
||||||
|
try (ServerContext ctx = startServer()) {
|
||||||
|
configureIndex(ctx.getInjector());
|
||||||
|
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
|
||||||
|
gApi.projects().create(project.get());
|
||||||
|
|
||||||
|
ChangeInput in = new ChangeInput(project.get(), "master", "Test change");
|
||||||
|
in.newBranch = true;
|
||||||
|
changeId = gApi.changes().create(in).info().changeId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setOnlineUpgradeConfig(boolean enable) throws Exception {
|
||||||
|
FileBasedConfig cfg = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.detect());
|
||||||
|
cfg.load();
|
||||||
|
cfg.setBoolean("index", null, "onlineUpgrade", enable);
|
||||||
|
cfg.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSearchVersion(ServerContext ctx, int expected) {
|
||||||
|
assertThat(
|
||||||
|
ctx.getInjector()
|
||||||
|
.getInstance(ChangeIndexCollection.class)
|
||||||
|
.getSearchIndex()
|
||||||
|
.getSchema()
|
||||||
|
.getVersion())
|
||||||
|
.named("search version")
|
||||||
|
.isEqualTo(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertWriteVersions(ServerContext ctx, Integer... expected) {
|
||||||
|
assertThat(
|
||||||
|
ctx.getInjector()
|
||||||
|
.getInstance(ChangeIndexCollection.class)
|
||||||
|
.getWriteIndexes()
|
||||||
|
.stream()
|
||||||
|
.map(i -> i.getSchema().getVersion()))
|
||||||
|
.named("write versions")
|
||||||
|
.containsExactlyElementsIn(ImmutableSet.copyOf(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertReady(int expectedReady) throws Exception {
|
||||||
|
Set<Integer> allVersions = ChangeSchemaDefinitions.INSTANCE.getSchemas().keySet();
|
||||||
|
GerritIndexStatus status = new GerritIndexStatus(sitePaths);
|
||||||
|
assertThat(
|
||||||
|
allVersions.stream().collect(toImmutableMap(v -> v, v -> status.getReady(CHANGES, v))))
|
||||||
|
.named("ready state for index versions")
|
||||||
|
.isEqualTo(allVersions.stream().collect(toImmutableMap(v -> v, v -> v == expectedReady)));
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +1,10 @@
|
|||||||
load("//gerrit-acceptance-tests:tests.bzl", "acceptance_tests")
|
load("//gerrit-acceptance-tests:tests.bzl", "acceptance_tests")
|
||||||
|
|
||||||
acceptance_tests(
|
acceptance_tests(
|
||||||
srcs = glob(["*IT.java"]),
|
srcs = glob(
|
||||||
|
["*IT.java"],
|
||||||
|
exclude = ["ElasticReindexIT.java"],
|
||||||
|
),
|
||||||
group = "pgm",
|
group = "pgm",
|
||||||
labels = ["pgm"],
|
labels = ["pgm"],
|
||||||
vm_args = ["-Xmx512m"],
|
vm_args = ["-Xmx512m"],
|
||||||
@@ -14,3 +17,20 @@ java_library(
|
|||||||
srcs = ["IndexUpgradeController.java"],
|
srcs = ["IndexUpgradeController.java"],
|
||||||
deps = ["//gerrit-acceptance-tests:lib"],
|
deps = ["//gerrit-acceptance-tests:lib"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
acceptance_tests(
|
||||||
|
srcs = [
|
||||||
|
"AbstractReindexIT.java",
|
||||||
|
"ElasticReindexIT.java",
|
||||||
|
],
|
||||||
|
group = "elastic",
|
||||||
|
labels = [
|
||||||
|
"docker",
|
||||||
|
"elastic",
|
||||||
|
"pgm",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":util",
|
||||||
|
"//gerrit-elasticsearch:elasticsearch_test_utils",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
@@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (C) 2018 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.pgm;
|
||||||
|
|
||||||
|
import com.google.gerrit.acceptance.NoHttpd;
|
||||||
|
import com.google.gerrit.elasticsearch.ElasticContainer;
|
||||||
|
import com.google.gerrit.elasticsearch.ElasticTestUtils;
|
||||||
|
import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo;
|
||||||
|
import com.google.gerrit.testutil.ConfigSuite;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
@NoHttpd
|
||||||
|
@Ignore
|
||||||
|
public class ElasticReindexIT extends AbstractReindexIT {
|
||||||
|
private static ElasticContainer<?> container;
|
||||||
|
|
||||||
|
@ConfigSuite.Default
|
||||||
|
public static Config elasticsearch() {
|
||||||
|
ElasticNodeInfo elasticNodeInfo;
|
||||||
|
try {
|
||||||
|
container = ElasticContainer.createAndStart();
|
||||||
|
elasticNodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String indicesPrefix = UUID.randomUUID().toString();
|
||||||
|
Config cfg = new Config();
|
||||||
|
ElasticTestUtils.configure(cfg, elasticNodeInfo.port, indicesPrefix);
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureIndex(Injector injector) throws Exception {
|
||||||
|
ElasticTestUtils.createAllIndexes(injector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void stopElasticServer() {
|
||||||
|
if (container != null) {
|
||||||
|
container.stop();
|
||||||
|
container = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -14,169 +14,12 @@
|
|||||||
|
|
||||||
package com.google.gerrit.acceptance.pgm;
|
package com.google.gerrit.acceptance.pgm;
|
||||||
|
|
||||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
import static com.google.gerrit.extensions.client.ListGroupsOption.MEMBERS;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.io.MoreFiles;
|
|
||||||
import com.google.common.io.RecursiveDeleteOption;
|
|
||||||
import com.google.gerrit.acceptance.NoHttpd;
|
import com.google.gerrit.acceptance.NoHttpd;
|
||||||
import com.google.gerrit.acceptance.StandaloneSiteTest;
|
import com.google.inject.Injector;
|
||||||
import com.google.gerrit.acceptance.pgm.IndexUpgradeController.UpgradeAttempt;
|
|
||||||
import com.google.gerrit.extensions.api.GerritApi;
|
|
||||||
import com.google.gerrit.extensions.common.ChangeInput;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
|
||||||
import com.google.gerrit.server.index.GerritIndexStatus;
|
|
||||||
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
|
||||||
import com.google.gerrit.server.index.change.ChangeSchemaDefinitions;
|
|
||||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
|
||||||
import com.google.inject.Provider;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.Set;
|
|
||||||
import org.eclipse.jgit.storage.file.FileBasedConfig;
|
|
||||||
import org.eclipse.jgit.util.FS;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
@NoHttpd
|
@NoHttpd
|
||||||
public class ReindexIT extends StandaloneSiteTest {
|
public class ReindexIT extends AbstractReindexIT {
|
||||||
private static final String CHANGES = ChangeSchemaDefinitions.NAME;
|
|
||||||
|
|
||||||
private Project.NameKey project;
|
@Override
|
||||||
private String changeId;
|
public void configureIndex(Injector injector) throws Exception {}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void reindexFromScratch() throws Exception {
|
|
||||||
setUpChange();
|
|
||||||
|
|
||||||
MoreFiles.deleteRecursively(sitePaths.index_dir, RecursiveDeleteOption.ALLOW_INSECURE);
|
|
||||||
Files.createDirectory(sitePaths.index_dir);
|
|
||||||
assertServerStartupFails();
|
|
||||||
|
|
||||||
runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
|
|
||||||
assertReady(ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion());
|
|
||||||
|
|
||||||
try (ServerContext ctx = startServer()) {
|
|
||||||
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
|
|
||||||
// Query change index
|
|
||||||
assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId))
|
|
||||||
.containsExactly(changeId);
|
|
||||||
// Query account index
|
|
||||||
assertThat(gApi.accounts().query("admin").get().stream().map(a -> a._accountId))
|
|
||||||
.containsExactly(adminId.get());
|
|
||||||
// Query group index
|
|
||||||
assertThat(
|
|
||||||
gApi.groups()
|
|
||||||
.query("Group")
|
|
||||||
.withOption(MEMBERS)
|
|
||||||
.get()
|
|
||||||
.stream()
|
|
||||||
.flatMap(g -> g.members.stream())
|
|
||||||
.map(a -> a._accountId))
|
|
||||||
.containsExactly(adminId.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onlineUpgradeChanges() throws Exception {
|
|
||||||
int prevVersion = ChangeSchemaDefinitions.INSTANCE.getPrevious().getVersion();
|
|
||||||
int currVersion = ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion();
|
|
||||||
|
|
||||||
// Before storing any changes, switch back to the previous version.
|
|
||||||
GerritIndexStatus status = new GerritIndexStatus(sitePaths);
|
|
||||||
status.setReady(CHANGES, currVersion, false);
|
|
||||||
status.setReady(CHANGES, prevVersion, true);
|
|
||||||
status.save();
|
|
||||||
assertReady(prevVersion);
|
|
||||||
|
|
||||||
setOnlineUpgradeConfig(false);
|
|
||||||
setUpChange();
|
|
||||||
setOnlineUpgradeConfig(true);
|
|
||||||
|
|
||||||
IndexUpgradeController u = new IndexUpgradeController(1);
|
|
||||||
try (ServerContext ctx = startServer(u.module())) {
|
|
||||||
assertSearchVersion(ctx, prevVersion);
|
|
||||||
assertWriteVersions(ctx, prevVersion, currVersion);
|
|
||||||
|
|
||||||
// Updating and searching old schema version works.
|
|
||||||
Provider<InternalChangeQuery> queryProvider =
|
|
||||||
ctx.getInjector().getProvider(InternalChangeQuery.class);
|
|
||||||
assertThat(queryProvider.get().byKey(new Change.Key(changeId))).hasSize(1);
|
|
||||||
assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
|
|
||||||
|
|
||||||
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
|
|
||||||
gApi.changes().id(changeId).topic("topic1");
|
|
||||||
assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
|
|
||||||
|
|
||||||
u.runUpgrades();
|
|
||||||
assertThat(u.getStartedAttempts())
|
|
||||||
.containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
|
|
||||||
assertThat(u.getSucceededAttempts())
|
|
||||||
.containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
|
|
||||||
assertThat(u.getFailedAttempts()).isEmpty();
|
|
||||||
|
|
||||||
assertReady(currVersion);
|
|
||||||
assertSearchVersion(ctx, currVersion);
|
|
||||||
assertWriteVersions(ctx, currVersion);
|
|
||||||
|
|
||||||
// Updating and searching new schema version works.
|
|
||||||
assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
|
|
||||||
assertThat(queryProvider.get().byTopicOpen("topic2")).isEmpty();
|
|
||||||
gApi.changes().id(changeId).topic("topic2");
|
|
||||||
assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
|
|
||||||
assertThat(queryProvider.get().byTopicOpen("topic2")).hasSize(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpChange() throws Exception {
|
|
||||||
project = new Project.NameKey("project");
|
|
||||||
try (ServerContext ctx = startServer()) {
|
|
||||||
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
|
|
||||||
gApi.projects().create(project.get());
|
|
||||||
|
|
||||||
ChangeInput in = new ChangeInput(project.get(), "master", "Test change");
|
|
||||||
in.newBranch = true;
|
|
||||||
changeId = gApi.changes().create(in).info().changeId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setOnlineUpgradeConfig(boolean enable) throws Exception {
|
|
||||||
FileBasedConfig cfg = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.detect());
|
|
||||||
cfg.load();
|
|
||||||
cfg.setBoolean("index", null, "onlineUpgrade", enable);
|
|
||||||
cfg.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertSearchVersion(ServerContext ctx, int expected) {
|
|
||||||
assertThat(
|
|
||||||
ctx.getInjector()
|
|
||||||
.getInstance(ChangeIndexCollection.class)
|
|
||||||
.getSearchIndex()
|
|
||||||
.getSchema()
|
|
||||||
.getVersion())
|
|
||||||
.named("search version")
|
|
||||||
.isEqualTo(expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertWriteVersions(ServerContext ctx, Integer... expected) {
|
|
||||||
assertThat(
|
|
||||||
ctx.getInjector()
|
|
||||||
.getInstance(ChangeIndexCollection.class)
|
|
||||||
.getWriteIndexes()
|
|
||||||
.stream()
|
|
||||||
.map(i -> i.getSchema().getVersion()))
|
|
||||||
.named("write versions")
|
|
||||||
.containsExactlyElementsIn(ImmutableSet.copyOf(expected));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertReady(int expectedReady) throws Exception {
|
|
||||||
Set<Integer> allVersions = ChangeSchemaDefinitions.INSTANCE.getSchemas().keySet();
|
|
||||||
GerritIndexStatus status = new GerritIndexStatus(sitePaths);
|
|
||||||
assertThat(
|
|
||||||
allVersions.stream().collect(toImmutableMap(v -> v, v -> status.getReady(CHANGES, v))))
|
|
||||||
.named("ready state for index versions")
|
|
||||||
.isEqualTo(allVersions.stream().collect(toImmutableMap(v -> v, v -> v == expectedReady)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ java_library(
|
|||||||
"src/test/java/**/ElasticTestUtils.java",
|
"src/test/java/**/ElasticTestUtils.java",
|
||||||
"src/test/java/**/ElasticContainer.java",
|
"src/test/java/**/ElasticContainer.java",
|
||||||
]),
|
]),
|
||||||
visibility = ["//tools/eclipse:__pkg__"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":elasticsearch",
|
":elasticsearch",
|
||||||
"//gerrit-index:index",
|
"//gerrit-index:index",
|
||||||
@@ -54,6 +54,7 @@ junit_tests(
|
|||||||
size = "large",
|
size = "large",
|
||||||
srcs = glob(["src/test/java/**/*Test.java"]),
|
srcs = glob(["src/test/java/**/*Test.java"]),
|
||||||
tags = [
|
tags = [
|
||||||
|
"docker",
|
||||||
"elastic",
|
"elastic",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
|
@@ -147,7 +147,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
|
|||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
if (statusCode != HttpStatus.SC_OK) {
|
if (statusCode != HttpStatus.SC_OK) {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
String.format("Failed to delete change %s in index %s: %s", c, indexName, statusCode));
|
String.format("Failed to delete %s from index %s: %s", c, indexName, statusCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A Query that matches documents matching boolean combinations of other queries. A trimmed down
|
* A Query that matches documents matching boolean combinations of other queries. A trimmed down
|
||||||
* version of {@link org.elasticsearch.index.query.BoolQueryBuilder} for this very package.
|
* version of org.elasticsearch.index.query.BoolQueryBuilder for this very package.
|
||||||
*/
|
*/
|
||||||
public class BoolQueryBuilder extends QueryBuilder {
|
public class BoolQueryBuilder extends QueryBuilder {
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a query that only match on documents that the field has a value in them. A trimmed
|
* Constructs a query that only match on documents that the field has a value in them. A trimmed
|
||||||
* down version of {@link org.elasticsearch.index.query.ExistsQueryBuilder} for this very package.
|
* down version of org.elasticsearch.index.query.ExistsQueryBuilder for this very package.
|
||||||
*/
|
*/
|
||||||
class ExistsQueryBuilder extends QueryBuilder {
|
class ExistsQueryBuilder extends QueryBuilder {
|
||||||
|
|
||||||
|
@@ -17,8 +17,8 @@ package com.google.gerrit.elasticsearch.builders;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A query that matches on all documents. A trimmed down version of {@link
|
* A query that matches on all documents. A trimmed down version of
|
||||||
* org.elasticsearch.index.query.MatchAllQueryBuilder} for this very package.
|
* org.elasticsearch.index.query.MatchAllQueryBuilder for this very package.
|
||||||
*/
|
*/
|
||||||
class MatchAllQueryBuilder extends QueryBuilder {
|
class MatchAllQueryBuilder extends QueryBuilder {
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* Match query is a query that analyzes the text and constructs a query as the result of the
|
* Match query is a query that analyzes the text and constructs a query as the result of the
|
||||||
* analysis. It can construct different queries based on the type provided. A trimmed down version
|
* analysis. It can construct different queries based on the type provided. A trimmed down version
|
||||||
* of {@link org.elasticsearch.index.query.MatchQueryBuilder} for this very package.
|
* of org.elasticsearch.index.query.MatchQueryBuilder for this very package.
|
||||||
*/
|
*/
|
||||||
class MatchQueryBuilder extends QueryBuilder {
|
class MatchQueryBuilder extends QueryBuilder {
|
||||||
|
|
||||||
|
@@ -16,10 +16,7 @@ package com.google.gerrit.elasticsearch.builders;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/** A trimmed down version of org.elasticsearch.index.query.QueryBuilder for this very package. */
|
||||||
* A trimmed down version of {@link org.elasticsearch.index.query.QueryBuilder} for this very
|
|
||||||
* package.
|
|
||||||
*/
|
|
||||||
public abstract class QueryBuilder {
|
public abstract class QueryBuilder {
|
||||||
|
|
||||||
protected QueryBuilder() {}
|
protected QueryBuilder() {}
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
package com.google.gerrit.elasticsearch.builders;
|
package com.google.gerrit.elasticsearch.builders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A static factory for simple "import static" usage. A trimmed down version of {@link
|
* A static factory for simple "import static" usage. A trimmed down version of
|
||||||
* org.elasticsearch.index.query.QueryBuilders} for this very package.
|
* org.elasticsearch.index.query.QueryBuilders for this very package.
|
||||||
*/
|
*/
|
||||||
public abstract class QueryBuilders {
|
public abstract class QueryBuilders {
|
||||||
|
|
||||||
|
@@ -17,8 +17,8 @@ package com.google.gerrit.elasticsearch.builders;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A trimmed down and further altered version of {@link
|
* A trimmed down and further altered version of org.elasticsearch.action.support.QuerySourceBuilder
|
||||||
* org.elasticsearch.action.support.QuerySourceBuilder} for this very package.
|
* for this very package.
|
||||||
*/
|
*/
|
||||||
class QuerySourceBuilder {
|
class QuerySourceBuilder {
|
||||||
|
|
||||||
|
@@ -17,8 +17,8 @@ package com.google.gerrit.elasticsearch.builders;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Query that matches documents within an range of terms. A trimmed down version of {@link
|
* A Query that matches documents within an range of terms. A trimmed down version of
|
||||||
* org.elasticsearch.index.query.RangeQueryBuilder} for this very package.
|
* org.elasticsearch.index.query.RangeQueryBuilder for this very package.
|
||||||
*/
|
*/
|
||||||
public class RangeQueryBuilder extends QueryBuilder {
|
public class RangeQueryBuilder extends QueryBuilder {
|
||||||
|
|
||||||
|
@@ -17,8 +17,8 @@ package com.google.gerrit.elasticsearch.builders;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Query that does fuzzy matching for a specific value. A trimmed down version of {@link
|
* A Query that does fuzzy matching for a specific value. A trimmed down version of
|
||||||
* org.elasticsearch.index.query.RegexpQueryBuilder} for this very package.
|
* org.elasticsearch.index.query.RegexpQueryBuilder for this very package.
|
||||||
*/
|
*/
|
||||||
class RegexpQueryBuilder extends QueryBuilder {
|
class RegexpQueryBuilder extends QueryBuilder {
|
||||||
|
|
||||||
|
@@ -19,8 +19,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A search source builder allowing to easily build search source. A trimmed down and further
|
* A search source builder allowing to easily build search source. A trimmed down and further
|
||||||
* altered version of {@link org.elasticsearch.search.builder.SearchSourceBuilder} for this very
|
* altered version of org.elasticsearch.search.builder.SearchSourceBuilder for this very package.
|
||||||
* package.
|
|
||||||
*/
|
*/
|
||||||
public class SearchSourceBuilder {
|
public class SearchSourceBuilder {
|
||||||
|
|
||||||
|
@@ -17,8 +17,8 @@ package com.google.gerrit.elasticsearch.builders;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Query that matches documents containing a term. A trimmed down version of {@link
|
* A Query that matches documents containing a term. A trimmed down version of
|
||||||
* org.elasticsearch.index.query.TermQueryBuilder} for this very package.
|
* org.elasticsearch.index.query.TermQueryBuilder for this very package.
|
||||||
*/
|
*/
|
||||||
class TermQueryBuilder extends QueryBuilder {
|
class TermQueryBuilder extends QueryBuilder {
|
||||||
|
|
||||||
|
@@ -27,8 +27,8 @@ import java.io.IOException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A trimmed down and further altered version of {@link
|
* A trimmed down and further altered version of org.elasticsearch.common.xcontent.XContentBuilder
|
||||||
* org.elasticsearch.common.xcontent.XContentBuilder} for this very package.
|
* for this very package.
|
||||||
*/
|
*/
|
||||||
public final class XContentBuilder implements Closeable {
|
public final class XContentBuilder implements Closeable {
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public final class XContentBuilder implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new builder. Make sure to call {@link #close()} when the builder is done with.
|
* Constructs a new builder. Make sure to call {@link #close()} when the builder is done with.
|
||||||
* Inspired from {@link org.elasticsearch.common.xcontent.json.JsonXContent} static block.
|
* Inspired from org.elasticsearch.common.xcontent.json.JsonXContent static block.
|
||||||
*/
|
*/
|
||||||
public XContentBuilder() throws IOException {
|
public XContentBuilder() throws IOException {
|
||||||
JsonFactory jsonFactory = new JsonFactory();
|
JsonFactory jsonFactory = new JsonFactory();
|
||||||
|
@@ -35,10 +35,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
class DbGroupMemberAuditListener implements GroupMemberAuditListener {
|
class DbGroupMemberAuditListener implements GroupMemberAuditListener {
|
||||||
private static final Logger log =
|
private static final Logger log = LoggerFactory.getLogger(DbGroupMemberAuditListener.class);
|
||||||
org.slf4j.LoggerFactory.getLogger(DbGroupMemberAuditListener.class);
|
|
||||||
|
|
||||||
private final SchemaFactory<ReviewDb> schema;
|
private final SchemaFactory<ReviewDb> schema;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
|
@@ -33,10 +33,11 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ListSubgroups implements RestReadView<GroupResource> {
|
public class ListSubgroups implements RestReadView<GroupResource> {
|
||||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ListSubgroups.class);
|
private static final Logger log = LoggerFactory.getLogger(ListSubgroups.class);
|
||||||
|
|
||||||
private final GroupControl.Factory controlFactory;
|
private final GroupControl.Factory controlFactory;
|
||||||
private final GroupIncludeCache groupIncludeCache;
|
private final GroupIncludeCache groupIncludeCache;
|
||||||
|
@@ -7,15 +7,3 @@ java_library(
|
|||||||
data = ["//lib:LICENSE-Apache2.0"],
|
data = ["//lib:LICENSE-Apache2.0"],
|
||||||
exports = ["@jackson_core//jar"],
|
exports = ["@jackson_core//jar"],
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
|
||||||
name = "jackson-dataformat-cbor",
|
|
||||||
data = ["//lib:LICENSE-Apache2.0"],
|
|
||||||
exports = ["@jackson_dataformat_cbor//jar"],
|
|
||||||
)
|
|
||||||
|
|
||||||
java_library(
|
|
||||||
name = "jackson-dataformat-smile",
|
|
||||||
data = ["//lib:LICENSE-Apache2.0"],
|
|
||||||
exports = ["@jackson_dataformat_smile//jar"],
|
|
||||||
)
|
|
||||||
|
Reference in New Issue
Block a user