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
This commit is contained in:
Marco Miller 2018-07-13 13:10:59 -04:00
parent 5b3d230a79
commit 6eb410d5ac
6 changed files with 11 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}