ElasticReindexIT: implement this class from stable
Add an implementation to this whole test class, based on the 2.15 one. Adapt some of its surroundings accordingly, also based on stable. Include the fix coming from Ia9097054 though, about first initializing the Elasticsearch gerrit indices -through reindexing before each test. Also base this implementation on the alignment with ElasticIndexIT, done through Ia9097054 as well, about not stopping any containers here too. Add the previously missing 'docker' tag to pgm acceptance_tests labels for elastic. Do not remove the flaky tag though, as ElasticReindexIT now fails for V6, likely out of Issue 9252; similar accounts/groups cause. Bug: Issue 8799 Change-Id: Ia15d92053b5364595dc5e9994f7aa4c5fb018233
This commit is contained in:
parent
1ade4162e0
commit
7f9b8a5f44
@ -35,6 +35,7 @@ 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;
|
||||
@ -46,6 +47,9 @@ import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public abstract class AbstractReindexTests extends StandaloneSiteTest {
|
||||
/** @param injector injector */
|
||||
public abstract void configureIndex(Injector injector) throws Exception;
|
||||
|
||||
private static final String CHANGES = ChangeSchemaDefinitions.NAME;
|
||||
|
||||
private Project.NameKey project;
|
||||
@ -225,6 +229,7 @@ public abstract class AbstractReindexTests extends StandaloneSiteTest {
|
||||
private void setUpChange() throws Exception {
|
||||
project = new Project.NameKey("reindex-project-test");
|
||||
try (ServerContext ctx = startServer()) {
|
||||
configureIndex(ctx.getInjector());
|
||||
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
|
||||
gApi.projects().create(project.get());
|
||||
|
||||
|
@ -21,6 +21,7 @@ acceptance_tests(
|
||||
srcs = ["ElasticReindexIT.java"],
|
||||
group = "elastic",
|
||||
labels = [
|
||||
"docker",
|
||||
"elastic",
|
||||
"exclusive",
|
||||
"flaky",
|
||||
@ -30,7 +31,9 @@ acceptance_tests(
|
||||
vm_args = ["-Xmx512m"],
|
||||
deps = [
|
||||
":util",
|
||||
"//java/com/google/gerrit/elasticsearch",
|
||||
"//java/com/google/gerrit/server/schema",
|
||||
"//javatests/com/google/gerrit/elasticsearch:elasticsearch_test_utils",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
// 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.
|
||||
@ -14,7 +14,56 @@
|
||||
|
||||
package com.google.gerrit.acceptance.pgm;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import com.google.gerrit.elasticsearch.ElasticContainer;
|
||||
import com.google.gerrit.elasticsearch.ElasticTestUtils;
|
||||
import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo;
|
||||
import com.google.gerrit.elasticsearch.ElasticVersion;
|
||||
import com.google.gerrit.testing.ConfigSuite;
|
||||
import com.google.inject.Injector;
|
||||
import java.util.UUID;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.Before;
|
||||
|
||||
@Ignore
|
||||
public class ElasticReindexIT extends AbstractReindexTests {}
|
||||
public class ElasticReindexIT extends AbstractReindexTests {
|
||||
|
||||
private static Config getConfig(ElasticVersion version) {
|
||||
ElasticNodeInfo elasticNodeInfo;
|
||||
ElasticContainer<?> container = ElasticContainer.createAndStart(version);
|
||||
elasticNodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
String indicesPrefix = UUID.randomUUID().toString();
|
||||
Config cfg = new Config();
|
||||
ElasticTestUtils.configure(cfg, elasticNodeInfo.port, indicesPrefix, version);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@ConfigSuite.Default
|
||||
public static Config elasticsearchV2() {
|
||||
return getConfig(ElasticVersion.V2_4);
|
||||
}
|
||||
|
||||
@ConfigSuite.Config
|
||||
public static Config elasticsearchV5() {
|
||||
return getConfig(ElasticVersion.V5_6);
|
||||
}
|
||||
|
||||
@ConfigSuite.Config
|
||||
public static Config elasticsearchV6_2() {
|
||||
return getConfig(ElasticVersion.V6_2);
|
||||
}
|
||||
|
||||
@ConfigSuite.Config
|
||||
public static Config elasticsearchV6_3() {
|
||||
return getConfig(ElasticVersion.V6_3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureIndex(Injector injector) throws Exception {
|
||||
ElasticTestUtils.createAllIndexes(injector);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void reindexFirstSinceElastic() throws Exception {
|
||||
assertServerStartupFails();
|
||||
runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,9 @@
|
||||
|
||||
package com.google.gerrit.acceptance.pgm;
|
||||
|
||||
public class ReindexIT extends AbstractReindexTests {}
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class ReindexIT extends AbstractReindexTests {
|
||||
@Override
|
||||
public void configureIndex(Injector injector) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user