From 6eb410d5ac4e4c3270965c56b73081c1fe42edf5 Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Fri, 13 Jul 2018 13:10:59 -0400 Subject: [PATCH] Elasticsearch tests: remove password duplication Only define the password once; default one for the stock 'elastic' user. The potential merge-up of this commit to master should consider the other change I290c8af2. If the latter gets merged, then that merge-up should also include amending master-only ElasticV5QueryProjectsTest. Change-Id: I99b4e328be1f1b761edb0abe8e55e4115ce3365a --- .../com/google/gerrit/acceptance/pgm/ElasticReindexIT.java | 3 +-- .../java/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java | 3 +-- .../google/gerrit/elasticsearch/testing/ElasticTestUtils.java | 4 +++- .../gerrit/elasticsearch/ElasticV5QueryAccountsTest.java | 3 ++- .../gerrit/elasticsearch/ElasticV5QueryChangesTest.java | 3 ++- .../google/gerrit/elasticsearch/ElasticV5QueryGroupsTest.java | 3 ++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java index 283b03f62e..b560c5f8cf 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java @@ -33,8 +33,7 @@ public class ElasticReindexIT extends AbstractReindexTests { elasticNodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort()); String indicesPrefix = UUID.randomUUID().toString(); Config cfg = new Config(); - String password = version == ElasticVersion.V5_6 ? "changeme" : null; - ElasticTestUtils.configure(cfg, elasticNodeInfo.port, indicesPrefix, password); + ElasticTestUtils.configure(cfg, elasticNodeInfo.port, indicesPrefix, version); return cfg; } diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java index e2355ba17f..dc9104f6da 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java @@ -32,8 +32,7 @@ public class ElasticIndexIT extends AbstractIndexTests { elasticNodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort()); String indicesPrefix = UUID.randomUUID().toString(); Config cfg = new Config(); - String password = version == ElasticVersion.V5_6 ? "changeme" : null; - ElasticTestUtils.configure(cfg, elasticNodeInfo.port, indicesPrefix, password); + ElasticTestUtils.configure(cfg, elasticNodeInfo.port, indicesPrefix, version); return cfg; } diff --git a/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/testing/ElasticTestUtils.java b/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/testing/ElasticTestUtils.java index 8832fcd865..d2e0bc60e8 100644 --- a/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/testing/ElasticTestUtils.java +++ b/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/testing/ElasticTestUtils.java @@ -14,6 +14,7 @@ package com.google.gerrit.elasticsearch.testing; +import com.google.gerrit.elasticsearch.ElasticVersion; import com.google.gerrit.server.index.IndexDefinition; import com.google.gerrit.server.index.IndexModule.IndexType; import com.google.inject.Injector; @@ -32,11 +33,12 @@ public final class ElasticTestUtils { } } - public static void configure(Config config, int port, String prefix, String password) { + public static void configure(Config config, int port, String prefix, ElasticVersion version) { config.setEnum("index", null, "type", IndexType.ELASTICSEARCH); config.setString("elasticsearch", null, "server", "http://localhost:" + port); config.setString("elasticsearch", null, "prefix", prefix); config.setInt("index", null, "maxLimit", 10000); + String password = version == ElasticVersion.V5_6 ? "changeme" : null; if (password != null) { config.setString("elasticsearch", null, "password", password); } diff --git a/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryAccountsTest.java b/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryAccountsTest.java index 496680ea66..60657be72e 100644 --- a/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryAccountsTest.java +++ b/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryAccountsTest.java @@ -62,7 +62,8 @@ public class ElasticV5QueryAccountsTest extends AbstractQueryAccountsTest { Config elasticsearchConfig = new Config(config); InMemoryModule.setDefaults(elasticsearchConfig); String indicesPrefix = testName(); - ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix, "changeme"); + ElasticTestUtils.configure( + elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6); return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); } } diff --git a/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryChangesTest.java b/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryChangesTest.java index b8411b5940..076fad94dd 100644 --- a/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryChangesTest.java +++ b/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryChangesTest.java @@ -62,7 +62,8 @@ public class ElasticV5QueryChangesTest extends AbstractQueryChangesTest { Config elasticsearchConfig = new Config(config); InMemoryModule.setDefaults(elasticsearchConfig); String indicesPrefix = testName(); - ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix, "changeme"); + ElasticTestUtils.configure( + elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6); return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); } } diff --git a/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryGroupsTest.java b/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryGroupsTest.java index df25c67986..d16a52a483 100644 --- a/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryGroupsTest.java +++ b/gerrit-elasticsearch/src/test/java/com/google/gerrit/elasticsearch/ElasticV5QueryGroupsTest.java @@ -62,7 +62,8 @@ public class ElasticV5QueryGroupsTest extends AbstractQueryGroupsTest { Config elasticsearchConfig = new Config(config); InMemoryModule.setDefaults(elasticsearchConfig); String indicesPrefix = testName(); - ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix, "changeme"); + ElasticTestUtils.configure( + elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6); return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); } }