Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Walter Knize <[email protected]>
  • Loading branch information
nknize committed Mar 11, 2022
1 parent 7de1303 commit 16aff4e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.index.IndexService;
import org.opensearch.index.mapper.MapperParsingException;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.query.RangeQueryBuilder;
import org.opensearch.indices.IndicesService;
import org.opensearch.test.OpenSearchIntegTestCase;
Expand Down Expand Up @@ -144,11 +145,16 @@ public void testMappingParamAndNestedMismatch() throws Exception {
MapperParsingException e = expectThrows(
MapperParsingException.class,
() -> prepareCreate("test").addMapping(
"type1",
MapperService.SINGLE_MAPPING_NAME,
XContentFactory.jsonBuilder().startObject().startObject("type2").endObject().endObject()
).get()
);
assertThat(e.getMessage(), startsWith("Failed to parse mapping [type1]: Root mapping definition has unsupported parameters"));
assertThat(
e.getMessage(),
startsWith(
"Failed to parse mapping [" + MapperService.SINGLE_MAPPING_NAME + "]: Root mapping definition has unsupported parameters"
)
);
}

public void testEmptyMappings() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.index.mapper.MapperParsingException;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.indices.IndexClosedException;
import org.opensearch.indices.ShardLimitValidator;
import org.opensearch.test.OpenSearchIntegTestCase;
Expand Down Expand Up @@ -108,14 +109,7 @@ public void testMappingMetadataParsed() throws Exception {
.prepareCreate("test")
.addMapping(
"type1",
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_routing")
.field("required", true)
.endObject()
.endObject()
.endObject()
XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject()
)
.execute()
.actionGet();
Expand All @@ -130,7 +124,7 @@ public void testMappingMetadataParsed() throws Exception {
.metadata()
.index("test")
.getMappings()
.get("type1");
.get(MapperService.SINGLE_MAPPING_NAME);
assertThat(mappingMd.routing().required(), equalTo(true));

logger.info("--> restarting nodes...");
Expand All @@ -149,7 +143,7 @@ public void testMappingMetadataParsed() throws Exception {
.metadata()
.index("test")
.getMappings()
.get("type1");
.get(MapperService.SINGLE_MAPPING_NAME);
assertThat(mappingMd.routing().required(), equalTo(true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import org.opensearch.index.engine.Engine;
import org.opensearch.index.engine.NoOpEngine;
import org.opensearch.index.flush.FlushStats;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.mapper.SourceToParse;
import org.opensearch.index.seqno.RetentionLeaseSyncer;
import org.opensearch.index.seqno.SequenceNumbers;
Expand Down Expand Up @@ -445,7 +446,7 @@ public void testMaybeRollTranslogGeneration() throws Exception {
.put("index.number_of_shards", 1)
.put("index.translog.generation_threshold_size", generationThreshold + "b")
.build();
createIndex("test", settings, "test");
createIndex("test", settings, MapperService.SINGLE_MAPPING_NAME);
ensureGreen("test");
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
final IndexService test = indicesService.indexService(resolveIndex("test"));
Expand All @@ -459,7 +460,7 @@ public void testMaybeRollTranslogGeneration() throws Exception {
final Engine.IndexResult result = shard.applyIndexOperationOnPrimary(
Versions.MATCH_ANY,
VersionType.INTERNAL,
new SourceToParse("test", "test", "1", new BytesArray("{}"), XContentType.JSON),
new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", new BytesArray("{}"), XContentType.JSON),
SequenceNumbers.UNASSIGNED_SEQ_NO,
0,
IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void testUpdateMappingNoChanges() {
.prepareCreate("test")
.setSettings(Settings.builder().put("index.number_of_shards", 2).put("index.number_of_replicas", 0))
.addMapping(
"type",
MapperService.SINGLE_MAPPING_NAME,
"{\"" + MapperService.SINGLE_MAPPING_NAME + "\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}",
XContentType.JSON
)
Expand All @@ -260,7 +260,7 @@ public void testUpdateMappingNoChanges() {
AcknowledgedResponse putMappingResponse = client().admin()
.indices()
.preparePutMapping("test")
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
.setSource("{\"properties\":{\"body\":{\"type\":\"text\"}}}", XContentType.JSON)
.execute()
.actionGet();

Expand Down

0 comments on commit 16aff4e

Please sign in to comment.