Merge branch 'stable-2.16'

* stable-2.16:
  Update git submodules
  Do not create postgresql index on an inexisting table
  ElasticContainer: Remove unneeded environment setting
  Remove redundant "testName" methods from Elasticsearch tests
  ElasticVersionTest: Add supportedVersion asserts for V7_0
  Add support for Elasticsearch 7
  Allow to set Elasticsearch number of shards and replicas
  Discontinue support for Elasticsearch 2.4.x
  ElasticSetting.Builder: Make methods return 'this'
  Add link to security documentation for Elasticsearch 6.5
  ElasticVersionTest: Add missing tests for 6.5.x

Change-Id: Idf65e3086d3e5ac691e88bd9cc6b598ef395db6a
This commit is contained in:
David Pursehouse 2018-12-05 10:23:35 +09:00
commit c791662eb2
24 changed files with 143 additions and 156 deletions

View File

@ -2979,7 +2979,7 @@ WARNING: Support for Elasticsearch is still experimental and is not recommended
for production use. For compatibility information, please refer to the
link:https://www.gerritcodereview.com/elasticsearch.html[project homepage].
When using Elasticsearch versions 2.4 and 5.6, the open and closed changes are
When using Elasticsearch version 5.6, the open and closed changes are
indexed in a single index, separated into types `open_changes` and `closed_changes`
respectively. When using version 6.2 or later, the open and closed changes are
merged into the default `_doc` type. The latter is also used for the accounts and
@ -3016,6 +3016,22 @@ The value is in the usual time-unit format like `1 m`, `5 m`.
+
Defaults to `30000 ms`.
[[elasticsearch.numberOfShards]]elasticsearch.numberOfShards::
+
Sets the number of shards to use per index. Refer to the
link:https://www.elastic.co/guide/en/elasticsearch/reference/current/_basic_concepts.html#getting-started-shards-and-replicas[
Elasticsearch documentation] for details.
+
Defaults to 5.
[[elasticsearch.numberOfReplicas]]elasticsearch.numberOfReplicas::
+
Sets the number of replicas to use per index. Refer to the
link:https://www.elastic.co/guide/en/elasticsearch/reference/current/_basic_concepts.html#getting-started-shards-and-replicas[
Elasticsearch documentation] for details.
+
Defaults to 1.
==== Elasticsearch Security
When security is enabled in Elasticsearch, the username and password must be provided.
@ -3023,11 +3039,11 @@ Note that the same username and password are used for all servers.
For further information about Elasticsearch security, please refer to the documentation:
* link:https://www.elastic.co/guide/en/elasticsearch/plugins/2.4/security.html[Elasticsearch 2.4]
* link:https://www.elastic.co/guide/en/x-pack/5.6/security-getting-started.html[Elasticsearch 5.6]
* link:https://www.elastic.co/guide/en/x-pack/6.2/security-getting-started.html[Elasticsearch 6.2]
* link:https://www.elastic.co/guide/en/elastic-stack-overview/6.3/security-getting-started.html[Elasticsearch 6.3]
* link:https://www.elastic.co/guide/en/elastic-stack-overview/6.4/security-getting-started.html[Elasticsearch 6.4]
* link:https://www.elastic.co/guide/en/elastic-stack-overview/6.5/security-getting-started.html[Elasticsearch 6.5]
[[elasticsearch.username]]elasticsearch.username::
+

View File

@ -107,6 +107,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
return content;
}
private final ElasticConfiguration config;
private final Schema<V> schema;
private final SitePaths sitePaths;
private final String indexNameRaw;
@ -118,17 +119,18 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
protected final ElasticQueryBuilder queryBuilder;
AbstractElasticIndex(
ElasticConfiguration cfg,
ElasticConfiguration config,
SitePaths sitePaths,
Schema<V> schema,
ElasticRestClientProvider client,
String indexName,
String indexType) {
this.config = config;
this.sitePaths = sitePaths;
this.schema = schema;
this.gson = new GsonBuilder().setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
this.queryBuilder = new ElasticQueryBuilder();
this.indexName = cfg.getIndexName(indexName, schema.getVersion());
this.indexName = config.getIndexName(indexName, schema.getVersion());
this.indexNameRaw = indexName;
this.client = client;
this.type = client.adapter().getType(indexType);
@ -199,7 +201,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
protected abstract String getMappings();
private String getSettings() {
return gson.toJson(ImmutableMap.of(SETTINGS, ElasticSetting.createSetting()));
return gson.toJson(ImmutableMap.of(SETTINGS, ElasticSetting.createSetting(config)));
}
protected abstract String getId(V v);
@ -293,8 +295,11 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
}
protected String getURI(String type, String request) throws UnsupportedEncodingException {
String encodedType = URLEncoder.encode(type, UTF_8.toString());
String encodedIndexName = URLEncoder.encode(indexName, UTF_8.toString());
if (SEARCH.equals(request) && client.adapter().omitTypeFromSearch()) {
return encodedIndexName + "/" + request;
}
String encodedType = URLEncoder.encode(type, UTF_8.toString());
return encodedIndexName + "/" + encodedType + "/" + request;
}

View File

@ -40,9 +40,13 @@ class ElasticConfiguration {
static final String KEY_MAX_RETRY_TIMEOUT = "maxRetryTimeout";
static final String KEY_PREFIX = "prefix";
static final String KEY_SERVER = "server";
static final String KEY_NUMBER_OF_SHARDS = "numberOfShards";
static final String KEY_NUMBER_OF_REPLICAS = "numberOfReplicas";
static final String DEFAULT_PORT = "9200";
static final String DEFAULT_USERNAME = "elastic";
static final int DEFAULT_MAX_RETRY_TIMEOUT_MS = 30000;
static final int DEFAULT_NUMBER_OF_SHARDS = 5;
static final int DEFAULT_NUMBER_OF_REPLICAS = 1;
static final TimeUnit MAX_RETRY_TIMEOUT_UNIT = TimeUnit.MILLISECONDS;
private final Config cfg;
@ -51,6 +55,8 @@ class ElasticConfiguration {
final String username;
final String password;
final int maxRetryTimeout;
final int numberOfShards;
final int numberOfReplicas;
final String prefix;
@Inject
@ -71,6 +77,10 @@ class ElasticConfiguration {
DEFAULT_MAX_RETRY_TIMEOUT_MS,
MAX_RETRY_TIMEOUT_UNIT);
this.prefix = Strings.nullToEmpty(cfg.getString(SECTION_ELASTICSEARCH, null, KEY_PREFIX));
this.numberOfShards =
cfg.getInt(SECTION_ELASTICSEARCH, null, KEY_NUMBER_OF_SHARDS, DEFAULT_NUMBER_OF_SHARDS);
this.numberOfReplicas =
cfg.getInt(SECTION_ELASTICSEARCH, null, KEY_NUMBER_OF_REPLICAS, DEFAULT_NUMBER_OF_REPLICAS);
this.hosts = new ArrayList<>();
for (String server : cfg.getStringList(SECTION_ELASTICSEARCH, null, KEY_SERVER)) {
try {

View File

@ -21,6 +21,7 @@ public class ElasticQueryAdapter {
private final boolean ignoreUnmapped;
private final boolean usePostV5Type;
private final boolean omitTypeFromSearch;
private final String searchFilteringName;
private final String indicesExistParam;
@ -31,33 +32,16 @@ public class ElasticQueryAdapter {
private final String versionDiscoveryUrl;
ElasticQueryAdapter(ElasticVersion version) {
this.ignoreUnmapped = version == ElasticVersion.V2_4;
this.usePostV5Type = version.isV6();
this.versionDiscoveryUrl = version.isV6() ? "/%s*" : "/%s*/_aliases";
switch (version) {
case V5_6:
case V6_2:
case V6_3:
case V6_4:
case V6_5:
this.searchFilteringName = "_source";
this.indicesExistParam = "?allow_no_indices=false";
this.exactFieldType = "keyword";
this.stringFieldType = "text";
this.indexProperty = "true";
this.rawFieldsKey = "_source";
break;
case V2_4:
default:
this.searchFilteringName = "fields";
this.indicesExistParam = "";
this.exactFieldType = "string";
this.stringFieldType = "string";
this.indexProperty = "not_analyzed";
this.rawFieldsKey = "fields";
break;
}
this.ignoreUnmapped = false;
this.usePostV5Type = version.isV6OrLater();
this.omitTypeFromSearch = version.isV7OrLater();
this.versionDiscoveryUrl = version.isV6OrLater() ? "/%s*" : "/%s*/_aliases";
this.searchFilteringName = "_source";
this.indicesExistParam = "?allow_no_indices=false";
this.exactFieldType = "keyword";
this.stringFieldType = "text";
this.indexProperty = "true";
this.rawFieldsKey = "_source";
}
void setIgnoreUnmapped(JsonObject properties) {
@ -100,8 +84,12 @@ public class ElasticQueryAdapter {
return usePostV5Type;
}
String getType(String preV6Type) {
return usePostV5Type() ? POST_V5_TYPE : preV6Type;
boolean omitTypeFromSearch() {
return omitTypeFromSearch;
}
String getType(String type) {
return usePostV5Type() ? POST_V5_TYPE : type;
}
String getVersionDiscoveryUrl(String name) {

View File

@ -22,33 +22,33 @@ class ElasticSetting {
private static final ImmutableMap<String, String> CUSTOM_CHAR_MAPPING =
ImmutableMap.of("\\u002E", "\\u0020", "\\u005F", "\\u0020");
static SettingProperties createSetting() {
ElasticSetting.Builder settings = new ElasticSetting.Builder();
settings.addCharFilter();
settings.addAnalyzer();
return settings.build();
static SettingProperties createSetting(ElasticConfiguration config) {
return new ElasticSetting.Builder().addCharFilter().addAnalyzer().build(config);
}
static class Builder {
private final ImmutableMap.Builder<String, FieldProperties> fields =
new ImmutableMap.Builder<>();
SettingProperties build() {
SettingProperties build(ElasticConfiguration config) {
SettingProperties properties = new SettingProperties();
properties.analysis = fields.build();
properties.numberOfShards = config.numberOfShards;
properties.numberOfReplicas = config.numberOfReplicas;
return properties;
}
void addCharFilter() {
Builder addCharFilter() {
FieldProperties charMapping = new FieldProperties("mapping");
charMapping.mappings = getCustomCharMappings(CUSTOM_CHAR_MAPPING);
FieldProperties charFilter = new FieldProperties();
charFilter.customMapping = charMapping;
fields.put("char_filter", charFilter);
return this;
}
void addAnalyzer() {
Builder addAnalyzer() {
FieldProperties customAnalyzer = new FieldProperties("custom");
customAnalyzer.tokenizer = "standard";
customAnalyzer.charFilter = new String[] {"custom_mapping"};
@ -57,6 +57,7 @@ class ElasticSetting {
FieldProperties analyzer = new FieldProperties();
analyzer.customWithCharFilter = customAnalyzer;
fields.put("analyzer", analyzer);
return this;
}
private static String[] getCustomCharMappings(ImmutableMap<String, String> map) {
@ -72,6 +73,8 @@ class ElasticSetting {
static class SettingProperties {
Map<String, FieldProperties> analysis;
Integer numberOfShards;
Integer numberOfReplicas;
}
static class FieldProperties {

View File

@ -18,12 +18,12 @@ import com.google.common.base.Joiner;
import java.util.regex.Pattern;
public enum ElasticVersion {
V2_4("2.4.*"),
V5_6("5.6.*"),
V6_2("6.2.*"),
V6_3("6.3.*"),
V6_4("6.4.*"),
V6_5("6.5.*");
V6_5("6.5.*"),
V7_0("7.0.*");
private final String version;
private final Pattern pattern;
@ -56,8 +56,16 @@ public enum ElasticVersion {
return Joiner.on(", ").join(ElasticVersion.values());
}
public boolean isV6() {
return version.startsWith("6.");
public boolean isV6OrLater() {
return isAtLeastVersion(6);
}
public boolean isV7OrLater() {
return isAtLeastVersion(7);
}
private boolean isAtLeastVersion(int v) {
return Integer.valueOf(version.split("\\.")[0]) >= v;
}
@Override

View File

@ -26,11 +26,6 @@ import org.junit.Before;
public class ElasticReindexIT extends AbstractReindexTests {
@ConfigSuite.Default
public static Config elasticsearchV2() {
return getConfig(ElasticVersion.V2_4);
}
@ConfigSuite.Config
public static Config elasticsearchV5() {
return getConfig(ElasticVersion.V5_6);
}
@ -40,6 +35,11 @@ public class ElasticReindexIT extends AbstractReindexTests {
return getConfig(ElasticVersion.V6_5);
}
@ConfigSuite.Config
public static Config elasticsearchV7() {
return getConfig(ElasticVersion.V7_0);
}
@Override
public void configureIndex(Injector injector) throws Exception {
createAllIndexes(injector);

View File

@ -25,11 +25,6 @@ import org.eclipse.jgit.lib.Config;
public class ElasticIndexIT extends AbstractIndexTests {
@ConfigSuite.Default
public static Config elasticsearchV2() {
return getConfig(ElasticVersion.V2_4);
}
@ConfigSuite.Config
public static Config elasticsearchV5() {
return getConfig(ElasticVersion.V5_6);
}
@ -39,6 +34,11 @@ public class ElasticIndexIT extends AbstractIndexTests {
return getConfig(ElasticVersion.V6_5);
}
@ConfigSuite.Config
public static Config elasticsearchV7() {
return getConfig(ElasticVersion.V7_0);
}
@Override
public void configureIndex(Injector injector) throws Exception {
createAllIndexes(injector);

View File

@ -40,26 +40,18 @@ TYPES = [
SUFFIX = "sTest.java"
ELASTICSEARCH_TESTS = {i: "ElasticQuery" + i.capitalize() + SUFFIX for i in TYPES}
ELASTICSEARCH_TESTS_V5 = {i: "ElasticV5Query" + i.capitalize() + SUFFIX for i in TYPES}
ELASTICSEARCH_TESTS_V6 = {i: "ElasticV6Query" + i.capitalize() + SUFFIX for i in TYPES}
ELASTICSEARCH_TESTS_V7 = {i: "ElasticV7Query" + i.capitalize() + SUFFIX for i in TYPES}
ELASTICSEARCH_TAGS = [
"docker",
"elastic",
"exclusive",
]
[junit_tests(
name = "elasticsearch_query_%ss_test" % name,
size = "large",
srcs = [src],
tags = ELASTICSEARCH_TAGS,
deps = ELASTICSEARCH_DEPS + [QUERY_TESTS_DEP % name],
) for name, src in ELASTICSEARCH_TESTS.items()]
[junit_tests(
name = "elasticsearch_query_%ss_test_V5" % name,
size = "large",
@ -76,6 +68,14 @@ ELASTICSEARCH_TAGS = [
deps = ELASTICSEARCH_DEPS + [QUERY_TESTS_DEP % name],
) for name, src in ELASTICSEARCH_TESTS_V6.items()]
[junit_tests(
name = "elasticsearch_query_%ss_test_V7" % name,
size = "large",
srcs = [src],
tags = ELASTICSEARCH_TAGS + ["flaky"],
deps = ELASTICSEARCH_DEPS + [QUERY_TESTS_DEP % name],
) for name, src in ELASTICSEARCH_TESTS_V7.items()]
junit_tests(
name = "elasticsearch_tests",
size = "small",

View File

@ -36,14 +36,8 @@ public class ElasticContainer<SELF extends ElasticContainer<SELF>> extends Gener
}
}
public static ElasticContainer<?> createAndStart() {
return createAndStart(ElasticVersion.V2_4);
}
private static String getImageName(ElasticVersion version) {
switch (version) {
case V2_4:
return "elasticsearch:2.4.6-alpine";
case V5_6:
return "docker.elastic.co/elasticsearch/elasticsearch:5.6.13";
case V6_2:
@ -54,6 +48,8 @@ public class ElasticContainer<SELF extends ElasticContainer<SELF>> extends Gener
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.3";
case V6_5:
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1";
case V7_0:
return "docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-alpha1";
}
throw new IllegalStateException("No tests for version: " + version.name());
}
@ -65,9 +61,6 @@ public class ElasticContainer<SELF extends ElasticContainer<SELF>> extends Gener
@Override
protected void configure() {
addExposedPort(ELASTICSEARCH_DEFAULT_PORT);
// https://github.com/docker-library/elasticsearch/issues/58
addEnv("-Ees.network.host", "0.0.0.0");
}
@Override

View File

@ -52,10 +52,6 @@ public class ElasticV5QueryAccountsTest extends AbstractQueryAccountsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV5QueryAccountsTest extends AbstractQueryAccountsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));

View File

@ -52,10 +52,6 @@ public class ElasticV5QueryChangesTest extends AbstractQueryChangesTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV5QueryChangesTest extends AbstractQueryChangesTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));

View File

@ -52,10 +52,6 @@ public class ElasticV5QueryGroupsTest extends AbstractQueryGroupsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV5QueryGroupsTest extends AbstractQueryGroupsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));

View File

@ -52,10 +52,6 @@ public class ElasticV5QueryProjectsTest extends AbstractQueryProjectsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV5QueryProjectsTest extends AbstractQueryProjectsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));

View File

@ -52,10 +52,6 @@ public class ElasticV6QueryAccountsTest extends AbstractQueryAccountsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV6QueryAccountsTest extends AbstractQueryAccountsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -52,10 +52,6 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -52,10 +52,6 @@ public class ElasticV6QueryGroupsTest extends AbstractQueryGroupsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV6QueryGroupsTest extends AbstractQueryGroupsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -52,10 +52,6 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 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.
@ -25,7 +25,7 @@ import org.eclipse.jgit.lib.Config;
import org.junit.AfterClass;
import org.junit.BeforeClass;
public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest {
public class ElasticV7QueryAccountsTest extends AbstractQueryAccountsTest {
@ConfigSuite.Default
public static Config defaultConfig() {
return IndexConfig.createForElasticsearch();
@ -41,7 +41,7 @@ public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest {
return;
}
container = ElasticContainer.createAndStart();
container = ElasticContainer.createAndStart(ElasticVersion.V7_0);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}
@ -52,10 +52,6 @@ public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -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.
@ -25,7 +25,7 @@ import org.eclipse.jgit.lib.Config;
import org.junit.AfterClass;
import org.junit.BeforeClass;
public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
public class ElasticV7QueryChangesTest extends AbstractQueryChangesTest {
@ConfigSuite.Default
public static Config defaultConfig() {
return IndexConfig.createForElasticsearch();
@ -41,7 +41,7 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
return;
}
container = ElasticContainer.createAndStart();
container = ElasticContainer.createAndStart(ElasticVersion.V7_0);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}
@ -52,10 +52,6 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2017 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.
@ -25,7 +25,7 @@ import org.eclipse.jgit.lib.Config;
import org.junit.AfterClass;
import org.junit.BeforeClass;
public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest {
public class ElasticV7QueryGroupsTest extends AbstractQueryGroupsTest {
@ConfigSuite.Default
public static Config defaultConfig() {
return IndexConfig.createForElasticsearch();
@ -41,7 +41,7 @@ public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest {
return;
}
container = ElasticContainer.createAndStart();
container = ElasticContainer.createAndStart(ElasticVersion.V7_0);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}
@ -52,10 +52,6 @@ public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2017 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.
@ -25,7 +25,7 @@ import org.eclipse.jgit.lib.Config;
import org.junit.AfterClass;
import org.junit.BeforeClass;
public class ElasticQueryProjectsTest extends AbstractQueryProjectsTest {
public class ElasticV7QueryProjectsTest extends AbstractQueryProjectsTest {
@ConfigSuite.Default
public static Config defaultConfig() {
return IndexConfig.createForElasticsearch();
@ -41,7 +41,7 @@ public class ElasticQueryProjectsTest extends AbstractQueryProjectsTest {
return;
}
container = ElasticContainer.createAndStart();
container = ElasticContainer.createAndStart(ElasticVersion.V7_0);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}
@ -52,10 +52,6 @@ public class ElasticQueryProjectsTest extends AbstractQueryProjectsTest {
}
}
private String testName() {
return testName.getMethodName().toLowerCase() + "_";
}
@Override
protected void initAfterLifecycleStart() throws Exception {
super.initAfterLifecycleStart();
@ -66,7 +62,7 @@ public class ElasticQueryProjectsTest extends AbstractQueryProjectsTest {
protected Injector createInjector() {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName();
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

View File

@ -22,9 +22,6 @@ import org.junit.Test;
public class ElasticVersionTest extends GerritBaseTests {
@Test
public void supportedVersion() throws Exception {
assertThat(ElasticVersion.forVersion("2.4.0")).isEqualTo(ElasticVersion.V2_4);
assertThat(ElasticVersion.forVersion("2.4.6")).isEqualTo(ElasticVersion.V2_4);
assertThat(ElasticVersion.forVersion("5.6.0")).isEqualTo(ElasticVersion.V5_6);
assertThat(ElasticVersion.forVersion("5.6.11")).isEqualTo(ElasticVersion.V5_6);
@ -36,6 +33,12 @@ public class ElasticVersionTest extends GerritBaseTests {
assertThat(ElasticVersion.forVersion("6.4.0")).isEqualTo(ElasticVersion.V6_4);
assertThat(ElasticVersion.forVersion("6.4.1")).isEqualTo(ElasticVersion.V6_4);
assertThat(ElasticVersion.forVersion("6.5.0")).isEqualTo(ElasticVersion.V6_5);
assertThat(ElasticVersion.forVersion("6.5.1")).isEqualTo(ElasticVersion.V6_5);
assertThat(ElasticVersion.forVersion("7.0.0")).isEqualTo(ElasticVersion.V7_0);
assertThat(ElasticVersion.forVersion("7.0.1")).isEqualTo(ElasticVersion.V7_0);
}
@Test
@ -48,9 +51,19 @@ public class ElasticVersionTest extends GerritBaseTests {
@Test
public void version6() throws Exception {
assertThat(ElasticVersion.V6_2.isV6()).isTrue();
assertThat(ElasticVersion.V6_3.isV6()).isTrue();
assertThat(ElasticVersion.V6_4.isV6()).isTrue();
assertThat(ElasticVersion.V5_6.isV6()).isFalse();
assertThat(ElasticVersion.V5_6.isV6OrLater()).isFalse();
assertThat(ElasticVersion.V6_2.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V6_3.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V6_4.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V7_0.isV6OrLater()).isTrue();
}
@Test
public void version7() throws Exception {
assertThat(ElasticVersion.V5_6.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V6_2.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V6_3.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V6_4.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V7_0.isV7OrLater()).isTrue();
}
}

View File

@ -8,7 +8,6 @@ ALTER TABLE change_messages CLUSTER ON change_messages_pkey;
ALTER TABLE patch_comments CLUSTER ON patch_comments_pkey;
ALTER TABLE patch_set_approvals CLUSTER ON patch_set_approvals_pkey;
ALTER TABLE account_group_members CLUSTER ON account_group_members_pkey;
CLUSTER;