Run reindex test against Elasticsearch in addition to Lucene
Bug: Issue 8771 Change-Id: I657672f3bd899423ad460281ae2d9d71158c1aed
This commit is contained in:
@@ -60,15 +60,15 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ElasticAccountIndex extends AbstractElasticIndex<Account.Id, AccountState>
|
||||
implements AccountIndex {
|
||||
static class AccountMapping {
|
||||
public static class AccountMapping {
|
||||
MappingProperties accounts;
|
||||
|
||||
AccountMapping(Schema<AccountState> schema) {
|
||||
public AccountMapping(Schema<AccountState> schema) {
|
||||
this.accounts = ElasticMapping.createMapping(schema);
|
||||
}
|
||||
}
|
||||
|
||||
static final String ACCOUNTS = "accounts";
|
||||
public static final String ACCOUNTS = "accounts";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ElasticAccountIndex.class);
|
||||
|
||||
|
@@ -78,24 +78,24 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/** Secondary index implementation using Elasticsearch. */
|
||||
class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
||||
public class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
||||
implements ChangeIndex {
|
||||
private static final Logger log = LoggerFactory.getLogger(ElasticChangeIndex.class);
|
||||
|
||||
static class ChangeMapping {
|
||||
MappingProperties openChanges;
|
||||
MappingProperties closedChanges;
|
||||
public static class ChangeMapping {
|
||||
public MappingProperties openChanges;
|
||||
public MappingProperties closedChanges;
|
||||
|
||||
ChangeMapping(Schema<ChangeData> schema) {
|
||||
public ChangeMapping(Schema<ChangeData> schema) {
|
||||
MappingProperties mapping = ElasticMapping.createMapping(schema);
|
||||
this.openChanges = mapping;
|
||||
this.closedChanges = mapping;
|
||||
}
|
||||
}
|
||||
|
||||
static final String CHANGES = "changes";
|
||||
static final String OPEN_CHANGES = "open_" + CHANGES;
|
||||
static final String CLOSED_CHANGES = "closed_" + CHANGES;
|
||||
public static final String CHANGES = "changes";
|
||||
public static final String OPEN_CHANGES = "open_" + CHANGES;
|
||||
public static final String CLOSED_CHANGES = "closed_" + CHANGES;
|
||||
|
||||
private final ChangeMapping mapping;
|
||||
private final Provider<ReviewDb> db;
|
||||
|
@@ -57,15 +57,15 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ElasticGroupIndex extends AbstractElasticIndex<AccountGroup.UUID, AccountGroup>
|
||||
implements GroupIndex {
|
||||
static class GroupMapping {
|
||||
public static class GroupMapping {
|
||||
MappingProperties groups;
|
||||
|
||||
GroupMapping(Schema<AccountGroup> schema) {
|
||||
public GroupMapping(Schema<AccountGroup> schema) {
|
||||
this.groups = ElasticMapping.createMapping(schema);
|
||||
}
|
||||
}
|
||||
|
||||
static final String GROUPS = "groups";
|
||||
public static final String GROUPS = "groups";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ElasticGroupIndex.class);
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.elasticsearch;
|
||||
package com.google.gerrit.elasticsearch.testing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.elasticsearch.ElasticAccountIndex.ACCOUNTS;
|
||||
@@ -23,8 +23,10 @@ import static com.google.gerrit.elasticsearch.ElasticGroupIndex.GROUPS;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gerrit.elasticsearch.ElasticAccountIndex;
|
||||
import com.google.gerrit.elasticsearch.ElasticAccountIndex.AccountMapping;
|
||||
import com.google.gerrit.elasticsearch.ElasticChangeIndex.ChangeMapping;
|
||||
import com.google.gerrit.elasticsearch.ElasticGroupIndex;
|
||||
import com.google.gerrit.elasticsearch.ElasticGroupIndex.GroupMapping;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
@@ -48,16 +50,16 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeBuilder;
|
||||
|
||||
final class ElasticTestUtils {
|
||||
public final class ElasticTestUtils {
|
||||
static final Gson gson =
|
||||
new GsonBuilder()
|
||||
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
|
||||
.create();
|
||||
|
||||
static class ElasticNodeInfo {
|
||||
final Node node;
|
||||
final String port;
|
||||
final File elasticDir;
|
||||
public static class ElasticNodeInfo {
|
||||
public final Node node;
|
||||
public final String port;
|
||||
public final File elasticDir;
|
||||
|
||||
private ElasticNodeInfo(Node node, File rootDir, String port) {
|
||||
this.node = node;
|
||||
@@ -66,7 +68,7 @@ final class ElasticTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static void configure(Config config, String port, String prefix) {
|
||||
public static void configure(Config config, String port, String prefix) {
|
||||
config.setEnum("index", null, "type", IndexType.ELASTICSEARCH);
|
||||
config.setString("elasticsearch", "test", "protocol", "http");
|
||||
config.setString("elasticsearch", "test", "hostname", "localhost");
|
||||
@@ -74,7 +76,8 @@ final class ElasticTestUtils {
|
||||
config.setString("elasticsearch", null, "prefix", prefix);
|
||||
}
|
||||
|
||||
static ElasticNodeInfo startElasticsearchNode() throws InterruptedException, ExecutionException {
|
||||
public static ElasticNodeInfo startElasticsearchNode()
|
||||
throws InterruptedException, ExecutionException {
|
||||
File elasticDir = Files.createTempDir();
|
||||
Path elasticDirPath = elasticDir.toPath();
|
||||
Settings settings =
|
||||
@@ -106,19 +109,19 @@ final class ElasticTestUtils {
|
||||
return new ElasticNodeInfo(node, elasticDir, getHttpPort(node));
|
||||
}
|
||||
|
||||
static void deleteAllIndexes(ElasticNodeInfo nodeInfo) {
|
||||
public static void deleteAllIndexes(ElasticNodeInfo nodeInfo) {
|
||||
nodeInfo.node.client().admin().indices().prepareDelete("_all").execute();
|
||||
}
|
||||
|
||||
static class NodeInfo {
|
||||
public static class NodeInfo {
|
||||
String httpAddress;
|
||||
}
|
||||
|
||||
static class Info {
|
||||
public static class Info {
|
||||
Map<String, NodeInfo> nodes;
|
||||
}
|
||||
|
||||
static void createAllIndexes(ElasticNodeInfo nodeInfo, String prefix) {
|
||||
public static void createAllIndexes(ElasticNodeInfo nodeInfo, String prefix) {
|
||||
Schema<ChangeData> changeSchema = ChangeSchemaDefinitions.INSTANCE.getLatest();
|
||||
ChangeMapping openChangesMapping = new ChangeMapping(changeSchema);
|
||||
ChangeMapping closedChangesMapping = new ChangeMapping(changeSchema);
|
@@ -14,7 +14,8 @@
|
||||
|
||||
package com.google.gerrit.elasticsearch;
|
||||
|
||||
import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo;
|
||||
import com.google.gerrit.elasticsearch.testing.ElasticTestUtils;
|
||||
import com.google.gerrit.elasticsearch.testing.ElasticTestUtils.ElasticNodeInfo;
|
||||
import com.google.gerrit.server.query.account.AbstractQueryAccountsTest;
|
||||
import com.google.gerrit.testutil.InMemoryModule;
|
||||
import com.google.inject.Guice;
|
||||
|
@@ -14,7 +14,8 @@
|
||||
|
||||
package com.google.gerrit.elasticsearch;
|
||||
|
||||
import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo;
|
||||
import com.google.gerrit.elasticsearch.testing.ElasticTestUtils;
|
||||
import com.google.gerrit.elasticsearch.testing.ElasticTestUtils.ElasticNodeInfo;
|
||||
import com.google.gerrit.server.query.change.AbstractQueryChangesTest;
|
||||
import com.google.gerrit.testutil.InMemoryModule;
|
||||
import com.google.gerrit.testutil.InMemoryRepositoryManager.Repo;
|
||||
|
@@ -14,7 +14,8 @@
|
||||
|
||||
package com.google.gerrit.elasticsearch;
|
||||
|
||||
import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo;
|
||||
import com.google.gerrit.elasticsearch.testing.ElasticTestUtils;
|
||||
import com.google.gerrit.elasticsearch.testing.ElasticTestUtils.ElasticNodeInfo;
|
||||
import com.google.gerrit.server.query.group.AbstractQueryGroupsTest;
|
||||
import com.google.gerrit.testutil.InMemoryModule;
|
||||
import com.google.inject.Guice;
|
||||
|
Reference in New Issue
Block a user