Skip to content

Commit

Permalink
Added skip section in integ test to fix mixed cluster failures
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Maurya <[email protected]>
  • Loading branch information
rishabhmaurya committed Nov 20, 2023
1 parent 40e205e commit 989033e
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
setup:
- skip:
version: " - 7.1.99"
reason: "added in 7.2.0"
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"

- do:
indices.create:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
"validate_query with query_string parameters":
- skip:
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"
- do:
indices.create:
index: test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
"Default index":
- skip:
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"
- do:
indices.create:
index: goodbad
Expand Down Expand Up @@ -71,84 +74,3 @@

- match: {aggregations.class.buckets.0.sig_terms.buckets.0.key: "bad"}
- match: {aggregations.class.buckets.1.sig_terms.buckets.0.key: "good"}

---
"IP test":
- do:
indices.create:
index: ip_index
body:
mappings:
properties:
ip:
type: ip

- do:
index:
index: ip_index
id: 1
body: { ip: "::1" }
- do:
index:
index: ip_index
id: 2
body: { }

- do:
indices.refresh: {}

- do:
search:
rest_total_hits_as_int: true
body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1 } } } }

- match: { hits.total: 1 }

- length: { aggregations.ip_terms.buckets: 1 }

- match: { aggregations.ip_terms.buckets.0.key: "::1" }

- is_false: aggregations.ip_terms.buckets.0.key_as_string

- match: { aggregations.ip_terms.buckets.0.doc_count: 1 }

- do:
search:
rest_total_hits_as_int: true
body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1, "include" : [ "::1" ] } } } }

- match: { hits.total: 1 }

- length: { aggregations.ip_terms.buckets: 1 }

- match: { aggregations.ip_terms.buckets.0.key: "::1" }

- do:
search:
rest_total_hits_as_int: true
body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1, "exclude" : [ "::1" ] } } } }

- match: { hits.total: 1 }

- length: { aggregations.ip_terms.buckets: 0 }

- do:
catch: /Aggregation \[ip_terms\] cannot support regular expression style include\/exclude settings as they can only be applied to string fields\. Use an array of values for include\/exclude clauses/
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "exclude" : "127.*" } } } }

---
'Misspelled fields get "did you mean"':
- skip:
version: " - 7.6.99"
reason: Implemented in 8.0 (to be backported to 7.7)
- do:
catch: /\[significant_terms\] unknown field \[jlp\] did you mean \[jlh\]\?/
search:
body:
aggs:
foo:
significant_terms:
field: foo
jlp: {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
"Default index":

- skip:
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"
- do:
indices.create:
index: goodbad
Expand Down Expand Up @@ -75,7 +77,9 @@

---
"Dedup noise":

- skip:
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"
- do:
indices.create:
index: goodbad
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
setup:
- skip:
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"
- do:
indices.create:
index: test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
"search with indexed phrases":
- skip:
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"
- do:
indices.create:
index: test
Expand All @@ -8,7 +11,6 @@
properties:
text:
type: match_only_text
index_phrases: true

- do:
index:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
setup:
- skip:
version: " - 7.1.99"
reason: "added in 7.2.0"
version: " - 2.11.99"
reason: "match_only_text field was introduced in 2.12.0"

- do:
indices.create:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.lucene.search.TermQuery;
import org.opensearch.Version;
import org.opensearch.common.lucene.search.MultiPhrasePrefixQuery;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.index.analysis.IndexAnalyzers;
import org.opensearch.index.analysis.NamedAnalyzer;
import org.opensearch.index.query.QueryShardContext;
Expand Down Expand Up @@ -308,30 +307,4 @@ private List<List<Term>> getTermsFromTokenStream(TokenStream stream) throws IOEx
return termArray;
}
}

@Override
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
// this is a pain, but we have to do this to maintain BWC
builder.field("type", contentType());
Builder mapperBuilder = (MatchOnlyTextFieldMapper.Builder) getMergeBuilder();
mapperBuilder.boost.toXContent(builder, includeDefaults);
mapperBuilder.index.toXContent(builder, includeDefaults);
mapperBuilder.store.toXContent(builder, includeDefaults);
this.multiFields.toXContent(builder, params);
this.copyTo.toXContent(builder, params);
mapperBuilder.meta.toXContent(builder, includeDefaults);
mapperBuilder.indexOptions.toXContent(builder, includeDefaults);
mapperBuilder.termVectors.toXContent(builder, includeDefaults);
mapperBuilder.norms.toXContent(builder, includeDefaults);
mapperBuilder.analyzers.indexAnalyzer.toXContent(builder, includeDefaults);
mapperBuilder.analyzers.searchAnalyzer.toXContent(builder, includeDefaults);
mapperBuilder.analyzers.searchQuoteAnalyzer.toXContent(builder, includeDefaults);
mapperBuilder.similarity.toXContent(builder, includeDefaults);
mapperBuilder.eagerGlobalOrdinals.toXContent(builder, includeDefaults);
mapperBuilder.positionIncrementGap.toXContent(builder, includeDefaults);
mapperBuilder.fieldData.toXContent(builder, includeDefaults);
mapperBuilder.freqFilter.toXContent(builder, includeDefaults);
mapperBuilder.indexPrefixes.toXContent(builder, includeDefaults);
mapperBuilder.indexPhrases.toXContent(builder, includeDefaults);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class SourceFieldMatchQuery extends Query {
* Constructs a SourceFieldMatchQuery.
*
* @param delegateQuery The parent query to use to find matches.
* @param filter The query used to filter further by running against field value computed using _source field.
* @param filter The query used to filter further by running against field value fetched using _source field.
* @param fieldType The mapped field type.
* @param context The QueryShardContext to get lookup and valueFetcher
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public void testPositionIncrementGap() throws IOException {}
@Override
public void testDefaultPositionIncrementGap() throws IOException {}

@Override
public void testMinimalToMaximal() throws IOException {}

@Override
public void testIndexPrefixMapping() throws IOException {
MapperParsingException e = expectThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void testAllPossibleScenarios() throws IOException {
QueryShardContext queryShardContext = createQueryShardContext(mapperService);
when(queryShardContext.sourcePath("desert")).thenReturn(Set.of("desert"));
when(queryShardContext.index()).thenReturn(new Index("test_index", "uuid"));
when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper());

String[] deserts = new String[] { "apple pie pie", "banana split pie", "chocolate cake" };
List<ParsedDocument> docs = new ArrayList<>();
Expand Down Expand Up @@ -113,7 +112,6 @@ public void testSourceDisabled() throws IOException {
QueryShardContext queryShardContext = createQueryShardContext(mapperService);
when(queryShardContext.sourcePath("desert")).thenReturn(Set.of("desert"));
when(queryShardContext.index()).thenReturn(new Index("test_index", "uuid"));
when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper());
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> new SourceFieldMatchQuery(
Expand Down Expand Up @@ -141,7 +139,6 @@ public void testMissingField() throws IOException {
QueryShardContext queryShardContext = createQueryShardContext(mapperService);
when(queryShardContext.sourcePath("desert")).thenReturn(Set.of("desert"));
when(queryShardContext.index()).thenReturn(new Index("test_index", "uuid"));
when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper());

String[] deserts = new String[] { "apple pie pie", "banana split pie", "chocolate cake" };
List<ParsedDocument> docs = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ protected QueryShardContext createQueryShardContext(MapperService mapperService)
throw new UnsupportedOperationException("search lookup not available");
}));
when(queryShardContext.getFieldType(any())).thenAnswer(inv -> mapperService.fieldType(inv.getArguments()[0].toString()));
when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper());
return queryShardContext;
}
}

0 comments on commit 989033e

Please sign in to comment.