From 3d2c35097d63e8ef7a933e686d0b310061f1b8df Mon Sep 17 00:00:00 2001 From: javanna Date: Mon, 21 Nov 2016 13:00:24 +0100 Subject: [PATCH] Add indices options tests to search api REST tests This is a followup to #21689 where we removed a misplaced try catch for IndexMissingException and IndexClosedException which was related to #9047 (at least for the index closed case). The code block within the change was moved as part of #20890, which made the catch redundant. It was somehow used before (e.g. in 5.0) but it doesn't seem that this catch had any effect. Added tests to verify that. In fact a specific catch added to the search api only would defeat the purpose of having common indices options that work throughout all our APIs. Relates to #21689 --- .../test/search/80_date_math_index_names.yaml | 7 --- .../test/search/80_indices_options.yaml | 63 +++++++++++++++++++ 2 files changed, 63 insertions(+), 7 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/search/80_date_math_index_names.yaml create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/search/80_indices_options.yaml diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/80_date_math_index_names.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/80_date_math_index_names.yaml deleted file mode 100644 index 2f2cf6ab98286..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/80_date_math_index_names.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -"Missing index with catch": - - - do: - catch: /logstash-\d{4}\.\d{2}\.\d{2}/ - search: - index: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/80_indices_options.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/80_indices_options.yaml new file mode 100644 index 0000000000000..d3cb5dae84602 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/80_indices_options.yaml @@ -0,0 +1,63 @@ +--- +"Missing index date math with catch": + + - do: + catch: /logstash-\d{4}\.\d{2}\.\d{2}/ + search: + index: + +--- +"Missing index": + + - do: + catch: missing + search: + index: missing_index + + - do: + search: + index: missing_index + ignore_unavailable: true + + - match: {hits.total: 0} + +--- +"Closed index": + + - do: + indices.create: + index: index_closed + + - do: + indices.close: + index: index_closed + + - do: + catch: /index_closed_exception/ + search: + index: index_closed + + - do: + search: + index: index_closed + ignore_unavailable: true + + - match: {hits.total: 0} + + - do: + search: + index: index* + + - match: {hits.total: 0} + + - do: + catch: missing + search: + index: index* + allow_no_indices: false + + - do: + catch: /index_closed_exception/ + search: + index: index* + expand_wildcards: ["open","closed"]