Skip to content

Commit 65293df

Browse files
authored
Fix watcher search template test after #65332 (#65380)
In #65332, the serialization of the WatcherSearchTemplateRequest class changed to use IndicesOptions built in XContent facilities. This had the side effect of fixing the handling of `all` for `expand_wildcards` to include hidden indices. However, the tests in WatcherUtilsTests were missed. This change updates those tests. Backport of #65379
1 parent 34f4afd commit 65293df

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import static org.elasticsearch.xpack.core.watcher.support.WatcherDateTimeUtils.formatDate;
3838
import static org.elasticsearch.xpack.core.watcher.support.WatcherUtils.flattenModel;
3939
import static org.elasticsearch.xpack.watcher.input.search.ExecutableSearchInput.DEFAULT_SEARCH_TYPE;
40+
import static org.elasticsearch.xpack.watcher.support.search.WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS;
4041
import static org.elasticsearch.xpack.watcher.test.WatcherTestUtils.getRandomSupportedSearchType;
4142
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
4243
import static org.hamcrest.Matchers.equalTo;
@@ -92,7 +93,9 @@ public void testSerializeSearchRequest() throws Exception {
9293
String[] expectedIndices = generateRandomStringArray(5, 5, true);
9394
String[] expectedTypes = generateRandomStringArray(2, 5, true, false);
9495
IndicesOptions expectedIndicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(),
95-
randomBoolean(), WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS);
96+
randomBoolean(), randomBoolean(), DEFAULT_INDICES_OPTIONS.allowAliasesToMultipleIndices(),
97+
DEFAULT_INDICES_OPTIONS.forbidClosedIndices(), DEFAULT_INDICES_OPTIONS.ignoreAliases(),
98+
DEFAULT_INDICES_OPTIONS.ignoreThrottled());
9699
SearchType expectedSearchType = getRandomSupportedSearchType();
97100

98101
BytesReference expectedSource = null;
@@ -150,7 +153,6 @@ public void testSerializeSearchRequest() throws Exception {
150153
}
151154
}
152155

153-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/65397")
154156
public void testDeserializeSearchRequest() throws Exception {
155157

156158
XContentBuilder builder = jsonBuilder().startObject();
@@ -175,18 +177,14 @@ public void testDeserializeSearchRequest() throws Exception {
175177
}
176178
}
177179

178-
IndicesOptions indicesOptions = WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS;
180+
IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS;
179181
if (randomBoolean()) {
180182
indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(),
181-
randomBoolean(), WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS);
182-
builder.startObject("indices_options")
183-
.field("allow_no_indices", indicesOptions.allowNoIndices())
184-
.field("expand_wildcards", indicesOptions.expandWildcardsClosed() && indicesOptions.expandWildcardsOpen() ? "all" :
185-
indicesOptions.expandWildcardsClosed() ? "closed" :
186-
indicesOptions.expandWildcardsOpen() ? "open" :
187-
"none")
188-
.field("ignore_unavailable", indicesOptions.ignoreUnavailable())
189-
.endObject();
183+
randomBoolean(), randomBoolean(), indicesOptions.allowAliasesToMultipleIndices(),
184+
indicesOptions.forbidClosedIndices(), indicesOptions.ignoreAliases(), indicesOptions.ignoreThrottled());
185+
builder.startObject("indices_options");
186+
indicesOptions.toXContent(builder, ToXContent.EMPTY_PARAMS);
187+
builder.endObject();
190188
}
191189

192190
SearchType searchType = SearchType.DEFAULT;
@@ -248,5 +246,4 @@ public void testDeserializeSearchRequest() throws Exception {
248246
assertWarnings(WatcherSearchTemplateRequest.TYPES_DEPRECATION_MESSAGE);
249247
}
250248
}
251-
252249
}

0 commit comments

Comments
 (0)