From 45e4cd9537f289a98579eef36a2dc3e561cc48fa Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 25 Aug 2020 18:33:39 -0700 Subject: move tests around --- tests/common/mod.rs | 6 --- tests/files/GET_collapse_expand.txt | 24 ---------- tests/files/GET_collapse_nested.txt | 16 ------- tests/files/GET_highlight.txt | 16 ------- tests/files/GET_highlight_complex.txt | 16 ------- tests/files/GET_highlight_fields.txt | 18 ------- tests/files/GET_highlight_query.txt | 55 ---------------------- tests/files/GET_range.txt | 12 ----- tests/files/GET_search.txt | 10 ---- tests/files/GET_search_agg_filter.txt | 28 ----------- tests/files/GET_search_agg_filter_simple.txt | 11 ----- tests/files/GET_search_agg_histogram.txt | 13 ----- tests/files/GET_search_agg_max.txt | 11 ----- tests/files/GET_search_agg_nested.txt | 16 ------- tests/files/GET_search_bool.txt | 15 ------ tests/files/GET_search_boosting.txt | 18 ------- tests/files/GET_search_docvalues.txt | 16 ------- tests/files/GET_search_exists.txt | 8 ---- .../files/GET_search_fatcat_preservation_year.txt | 2 - tests/files/GET_search_fatcat_scholar_basic.txt | 2 - tests/files/GET_search_ids.txt | 8 ---- tests/files/GET_search_match_all.txt | 6 --- tests/files/GET_search_match_none.txt | 6 --- tests/files/GET_search_multi_match.txt | 9 ---- tests/files/GET_search_multi_match_tie.txt | 11 ----- tests/files/GET_search_prefix.txt | 10 ---- tests/files/GET_search_querystring.txt | 14 ------ tests/files/GET_search_simplequerystring.txt | 10 ---- tests/files/GET_search_sort.txt | 13 ----- tests/files/GET_search_term.txt | 11 ----- tests/files/GET_search_term_short.txt | 8 ---- tests/files/GET_search_wildcard.txt | 12 ----- tests/files/GET_uri_search.txt | 1 - tests/files/POST_search_inner.txt.disabled | 17 ------- tests/files/POST_search_rescore.txt | 26 ---------- tests/files/POST_search_sort_mode.txt | 9 ---- tests/files/POST_search_start_scroll.txt | 9 ---- tests/files/scroll_fail/DELETE_scroll_all.txt | 4 ++ tests/files/search/GET_collapse_expand.txt | 24 ++++++++++ tests/files/search/GET_collapse_nested.txt | 16 +++++++ tests/files/search/GET_highlight.txt | 16 +++++++ tests/files/search/GET_highlight_complex.txt | 16 +++++++ tests/files/search/GET_highlight_fields.txt | 18 +++++++ tests/files/search/GET_highlight_query.txt | 55 ++++++++++++++++++++++ tests/files/search/GET_range.txt | 12 +++++ tests/files/search/GET_search.txt | 10 ++++ tests/files/search/GET_search_agg_filter.txt | 28 +++++++++++ .../files/search/GET_search_agg_filter_simple.txt | 11 +++++ tests/files/search/GET_search_agg_histogram.txt | 13 +++++ tests/files/search/GET_search_agg_max.txt | 11 +++++ tests/files/search/GET_search_agg_nested.txt | 16 +++++++ tests/files/search/GET_search_bool.txt | 15 ++++++ tests/files/search/GET_search_boosting.txt | 18 +++++++ tests/files/search/GET_search_docvalues.txt | 16 +++++++ tests/files/search/GET_search_exists.txt | 8 ++++ .../search/GET_search_fatcat_preservation_year.txt | 2 + .../search/GET_search_fatcat_scholar_basic.txt | 2 + tests/files/search/GET_search_ids.txt | 8 ++++ tests/files/search/GET_search_match_all.txt | 6 +++ tests/files/search/GET_search_match_none.txt | 6 +++ tests/files/search/GET_search_multi_match.txt | 9 ++++ tests/files/search/GET_search_multi_match_tie.txt | 11 +++++ tests/files/search/GET_search_prefix.txt | 10 ++++ tests/files/search/GET_search_querystring.txt | 14 ++++++ .../files/search/GET_search_simplequerystring.txt | 10 ++++ tests/files/search/GET_search_sort.txt | 13 +++++ tests/files/search/GET_search_term.txt | 11 +++++ tests/files/search/GET_search_term_short.txt | 8 ++++ tests/files/search/GET_search_wildcard.txt | 12 +++++ tests/files/search/GET_uri_search.txt | 1 + tests/files/search/POST_search_rescore.txt | 26 ++++++++++ tests/files/search/POST_search_sort_mode.txt | 9 ++++ tests/files/search/POST_search_start_scroll.txt | 9 ++++ tests/files/search_fail/POST_search_inner.txt | 17 +++++++ tests/parse_es_requests.rs | 48 ++++++++++++++----- 75 files changed, 527 insertions(+), 505 deletions(-) delete mode 100644 tests/files/GET_collapse_expand.txt delete mode 100644 tests/files/GET_collapse_nested.txt delete mode 100644 tests/files/GET_highlight.txt delete mode 100644 tests/files/GET_highlight_complex.txt delete mode 100644 tests/files/GET_highlight_fields.txt delete mode 100644 tests/files/GET_highlight_query.txt delete mode 100644 tests/files/GET_range.txt delete mode 100644 tests/files/GET_search.txt delete mode 100644 tests/files/GET_search_agg_filter.txt delete mode 100644 tests/files/GET_search_agg_filter_simple.txt delete mode 100644 tests/files/GET_search_agg_histogram.txt delete mode 100644 tests/files/GET_search_agg_max.txt delete mode 100644 tests/files/GET_search_agg_nested.txt delete mode 100644 tests/files/GET_search_bool.txt delete mode 100644 tests/files/GET_search_boosting.txt delete mode 100644 tests/files/GET_search_docvalues.txt delete mode 100644 tests/files/GET_search_exists.txt delete mode 100644 tests/files/GET_search_fatcat_preservation_year.txt delete mode 100644 tests/files/GET_search_fatcat_scholar_basic.txt delete mode 100644 tests/files/GET_search_ids.txt delete mode 100644 tests/files/GET_search_match_all.txt delete mode 100644 tests/files/GET_search_match_none.txt delete mode 100644 tests/files/GET_search_multi_match.txt delete mode 100644 tests/files/GET_search_multi_match_tie.txt delete mode 100644 tests/files/GET_search_prefix.txt delete mode 100644 tests/files/GET_search_querystring.txt delete mode 100644 tests/files/GET_search_simplequerystring.txt delete mode 100644 tests/files/GET_search_sort.txt delete mode 100644 tests/files/GET_search_term.txt delete mode 100644 tests/files/GET_search_term_short.txt delete mode 100644 tests/files/GET_search_wildcard.txt delete mode 100644 tests/files/GET_uri_search.txt delete mode 100644 tests/files/POST_search_inner.txt.disabled delete mode 100644 tests/files/POST_search_rescore.txt delete mode 100644 tests/files/POST_search_sort_mode.txt delete mode 100644 tests/files/POST_search_start_scroll.txt create mode 100644 tests/files/scroll_fail/DELETE_scroll_all.txt create mode 100644 tests/files/search/GET_collapse_expand.txt create mode 100644 tests/files/search/GET_collapse_nested.txt create mode 100644 tests/files/search/GET_highlight.txt create mode 100644 tests/files/search/GET_highlight_complex.txt create mode 100644 tests/files/search/GET_highlight_fields.txt create mode 100644 tests/files/search/GET_highlight_query.txt create mode 100644 tests/files/search/GET_range.txt create mode 100644 tests/files/search/GET_search.txt create mode 100644 tests/files/search/GET_search_agg_filter.txt create mode 100644 tests/files/search/GET_search_agg_filter_simple.txt create mode 100644 tests/files/search/GET_search_agg_histogram.txt create mode 100644 tests/files/search/GET_search_agg_max.txt create mode 100644 tests/files/search/GET_search_agg_nested.txt create mode 100644 tests/files/search/GET_search_bool.txt create mode 100644 tests/files/search/GET_search_boosting.txt create mode 100644 tests/files/search/GET_search_docvalues.txt create mode 100644 tests/files/search/GET_search_exists.txt create mode 100644 tests/files/search/GET_search_fatcat_preservation_year.txt create mode 100644 tests/files/search/GET_search_fatcat_scholar_basic.txt create mode 100644 tests/files/search/GET_search_ids.txt create mode 100644 tests/files/search/GET_search_match_all.txt create mode 100644 tests/files/search/GET_search_match_none.txt create mode 100644 tests/files/search/GET_search_multi_match.txt create mode 100644 tests/files/search/GET_search_multi_match_tie.txt create mode 100644 tests/files/search/GET_search_prefix.txt create mode 100644 tests/files/search/GET_search_querystring.txt create mode 100644 tests/files/search/GET_search_simplequerystring.txt create mode 100644 tests/files/search/GET_search_sort.txt create mode 100644 tests/files/search/GET_search_term.txt create mode 100644 tests/files/search/GET_search_term_short.txt create mode 100644 tests/files/search/GET_search_wildcard.txt create mode 100644 tests/files/search/GET_uri_search.txt create mode 100644 tests/files/search/POST_search_rescore.txt create mode 100644 tests/files/search/POST_search_sort_mode.txt create mode 100644 tests/files/search/POST_search_start_scroll.txt create mode 100644 tests/files/search_fail/POST_search_inner.txt diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 890dead..811b4b9 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -9,12 +9,6 @@ pub struct ExampleParts { pub body: Option, } -pub fn load_parts_by_name(name: &str) -> ExampleParts { - let path = format!("tests/files/{}.txt", name); - let path = Path::new(&path); - load_parts(&path) -} - pub fn load_parts(path: &Path) -> ExampleParts { let file = std::fs::File::open(path).unwrap(); diff --git a/tests/files/GET_collapse_expand.txt b/tests/files/GET_collapse_expand.txt deleted file mode 100644 index dc6b1a8..0000000 --- a/tests/files/GET_collapse_expand.txt +++ /dev/null @@ -1,24 +0,0 @@ -GET /my-index-000001/_search -{ - "query": { - "match": { - "message": "GET /search" - } - }, - "collapse": { - "field": "user.id", - "inner_hits": [ - { - "name": "largest_responses", - "size": 3, - "sort": [ "http.response.bytes" ] - }, - { - "name": "most_recent", - "size": 3, - "sort": [ { "@timestamp": "asc" } ] - } - ] - }, - "sort": [ "http.response.bytes" ] -} diff --git a/tests/files/GET_collapse_nested.txt b/tests/files/GET_collapse_nested.txt deleted file mode 100644 index a31c8e4..0000000 --- a/tests/files/GET_collapse_nested.txt +++ /dev/null @@ -1,16 +0,0 @@ -GET /my-index-000001/_search -{ - "query": { - "match": { - "message": "GET /search" - } - }, - "collapse": { - "field": "geo.country_name", - "inner_hits": { - "name": "by_location", - "collapse": { "field": "user.id" }, - "size": 3 - } - } -} diff --git a/tests/files/GET_highlight.txt b/tests/files/GET_highlight.txt deleted file mode 100644 index 8dc23ea..0000000 --- a/tests/files/GET_highlight.txt +++ /dev/null @@ -1,16 +0,0 @@ -GET /my-index-000001/_search -{ - "query": { - "match_phrase": { "message": "number 1" } - }, - "highlight": { - "fields": { - "message": { - "type": "plain", - "fragment_size": 15, - "number_of_fragments": 3, - "fragmenter": "simple" - } - } - } -} diff --git a/tests/files/GET_highlight_complex.txt b/tests/files/GET_highlight_complex.txt deleted file mode 100644 index 288aa9f..0000000 --- a/tests/files/GET_highlight_complex.txt +++ /dev/null @@ -1,16 +0,0 @@ -GET /some-index/_search -{ - "query" : { - "match": { "user.id": "kimchy" } - }, - "highlight" : { - "number_of_fragments" : 3, - "fragment_size" : 150, - "fields" : { - "body" : { "pre_tags" : [""], "post_tags" : [""] }, - "blog.title" : { "number_of_fragments" : 0 }, - "blog.author" : { "number_of_fragments" : 0 }, - "blog.comment" : { "number_of_fragments" : 5, "order" : "score" } - } - } -} diff --git a/tests/files/GET_highlight_fields.txt b/tests/files/GET_highlight_fields.txt deleted file mode 100644 index 85b55cb..0000000 --- a/tests/files/GET_highlight_fields.txt +++ /dev/null @@ -1,18 +0,0 @@ -GET /some-index/_search -{ - "query": { - "query_string": { - "query": "running scissors", - "fields": ["comment", "comment.plain^10"] - } - }, - "highlight": { - "order": "score", - "fields": { - "comment": { - "matched_fields": ["comment", "comment.plain"], - "type" : "fvh" - } - } - } -} diff --git a/tests/files/GET_highlight_query.txt b/tests/files/GET_highlight_query.txt deleted file mode 100644 index 7c7f0ea..0000000 --- a/tests/files/GET_highlight_query.txt +++ /dev/null @@ -1,55 +0,0 @@ -GET /some-index/_search -{ - "query": { - "match": { - "comment": { - "query": "foo bar" - } - } - }, - "rescore": { - "window_size": 50, - "query": { - "rescore_query": { - "match_phrase": { - "comment": { - "query": "foo bar", - "slop": 1 - } - } - }, - "rescore_query_weight": 10 - } - }, - "_source": false, - "highlight": { - "order": "score", - "fields": { - "comment": { - "fragment_size": 150, - "number_of_fragments": 3, - "highlight_query": { - "bool": { - "must": { - "match": { - "comment": { - "query": "foo bar" - } - } - }, - "should": { - "match_phrase": { - "comment": { - "query": "foo bar", - "slop": 1, - "boost": 10.0 - } - } - }, - "minimum_should_match": 0 - } - } - } - } - } -} diff --git a/tests/files/GET_range.txt b/tests/files/GET_range.txt deleted file mode 100644 index a5321c3..0000000 --- a/tests/files/GET_range.txt +++ /dev/null @@ -1,12 +0,0 @@ -GET /some-index/_search -{ - "query": { - "range": { - "age": { - "gte": 10, - "lte": 20, - "boost": 2.0 - } - } - } -} diff --git a/tests/files/GET_search.txt b/tests/files/GET_search.txt deleted file mode 100644 index 7ff7ca6..0000000 --- a/tests/files/GET_search.txt +++ /dev/null @@ -1,10 +0,0 @@ -GET /some-index/_search -{ - "query": { - "match": { - "message": { - "query": "this is a test" - } - } - } -} diff --git a/tests/files/GET_search_agg_filter.txt b/tests/files/GET_search_agg_filter.txt deleted file mode 100644 index 538380a..0000000 --- a/tests/files/GET_search_agg_filter.txt +++ /dev/null @@ -1,28 +0,0 @@ -GET /shirts/_search -{ - "query": { - "bool": { - "filter": { - "term": { "brand": "gucci" } - } - } - }, - "aggs": { - "colors": { - "terms": { "field": "color" } - }, - "color_red": { - "filter": { - "term": { "color": "red" } - }, - "aggs": { - "models": { - "terms": { "field": "model" } - } - } - } - }, - "post_filter": { - "term": { "color": "red" } - } -} diff --git a/tests/files/GET_search_agg_filter_simple.txt b/tests/files/GET_search_agg_filter_simple.txt deleted file mode 100644 index 71a9777..0000000 --- a/tests/files/GET_search_agg_filter_simple.txt +++ /dev/null @@ -1,11 +0,0 @@ -POST /sales/_search?size=0 -{ - "aggs": { - "t_shirts": { - "filter": { "term": { "type": "t-shirt" } }, - "aggs": { - "avg_price": { "avg": { "field": "price" } } - } - } - } -} diff --git a/tests/files/GET_search_agg_histogram.txt b/tests/files/GET_search_agg_histogram.txt deleted file mode 100644 index 4689ad1..0000000 --- a/tests/files/GET_search_agg_histogram.txt +++ /dev/null @@ -1,13 +0,0 @@ -POST /sales/_search?size=0 -{ - "aggs": { - "quantity": { - "histogram": { - "field": "quantity", - "interval": 10, - "keyed": true, - "missing": 0 - } - } - } -} diff --git a/tests/files/GET_search_agg_max.txt b/tests/files/GET_search_agg_max.txt deleted file mode 100644 index 1377afc..0000000 --- a/tests/files/GET_search_agg_max.txt +++ /dev/null @@ -1,11 +0,0 @@ -POST /sales/_search -{ - "aggs" : { - "grade_max" : { - "max" : { - "field" : "grade", - "missing": 10 - } - } - } -} diff --git a/tests/files/GET_search_agg_nested.txt b/tests/files/GET_search_agg_nested.txt deleted file mode 100644 index 8e5d1c1..0000000 --- a/tests/files/GET_search_agg_nested.txt +++ /dev/null @@ -1,16 +0,0 @@ -GET /products/_search -{ - "query": { - "match": { "name": "led tv" } - }, - "aggs": { - "resellers": { - "nested": { - "path": "resellers" - }, - "aggs": { - "min_price": { "min": { "field": "resellers.price" } } - } - } - } -} diff --git a/tests/files/GET_search_bool.txt b/tests/files/GET_search_bool.txt deleted file mode 100644 index 3f402f9..0000000 --- a/tests/files/GET_search_bool.txt +++ /dev/null @@ -1,15 +0,0 @@ -GET /some-index/_search -{ - "query": { - "bool": { - "must": { - "match_all": {} - }, - "filter": { - "term": { - "status": "active" - } - } - } - } -} diff --git a/tests/files/GET_search_boosting.txt b/tests/files/GET_search_boosting.txt deleted file mode 100644 index 9045a54..0000000 --- a/tests/files/GET_search_boosting.txt +++ /dev/null @@ -1,18 +0,0 @@ -GET /some-index/_search -{ - "query": { - "boosting": { - "positive": { - "term": { - "text": "apple" - } - }, - "negative": { - "term": { - "text": "pie tart fruit crumble tree" - } - }, - "negative_boost": 0.5 - } - } -} diff --git a/tests/files/GET_search_docvalues.txt b/tests/files/GET_search_docvalues.txt deleted file mode 100644 index 2fd57b1..0000000 --- a/tests/files/GET_search_docvalues.txt +++ /dev/null @@ -1,16 +0,0 @@ -GET /some-index/_search -{ - "query": { - "match_all": {} - }, - "docvalue_fields": [ - "my_ip*", - { - "field": "my_keyword_field" - }, - { - "field": "*_date_field", - "format": "epoch_millis" - } - ] -} diff --git a/tests/files/GET_search_exists.txt b/tests/files/GET_search_exists.txt deleted file mode 100644 index fe7d722..0000000 --- a/tests/files/GET_search_exists.txt +++ /dev/null @@ -1,8 +0,0 @@ -GET /some-index/_search -{ - "query": { - "exists": { - "field": "user" - } - } -} diff --git a/tests/files/GET_search_fatcat_preservation_year.txt b/tests/files/GET_search_fatcat_preservation_year.txt deleted file mode 100644 index 539677b..0000000 --- a/tests/files/GET_search_fatcat_preservation_year.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET /fatcat_release/_search -{"query": {"bool": {"filter": [{"term": {"container_id": "yh4zdhfsobdolesogv6czydwqi"}}, {"range": {"release_year": {"gte": 1771, "lte": 2020}}}]}}, "aggs": {"year_preservation": {"composite": {"size": 1500, "sources": [{"year": {"histogram": {"field": "release_year", "interval": 1}}}, {"preservation": {"terms": {"field": "preservation"}}}]}}}, "from": 0, "size": 0} diff --git a/tests/files/GET_search_fatcat_scholar_basic.txt b/tests/files/GET_search_fatcat_scholar_basic.txt deleted file mode 100644 index c60e62f..0000000 --- a/tests/files/GET_search_fatcat_scholar_basic.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET /scholar_fulltext/_search -{"query": {"bool": {"filter": [{"terms": {"type": ["article-journal", "paper-conference", "chapter"]}}, {"terms": {"access_type": ["wayback", "ia_file", "ia_sim"]}}], "must": [{"boosting": {"positive": {"bool": {"must": [{"query_string": {"query": "coffee", "default_operator": "AND", "analyze_wildcard": true, "allow_leading_wildcard": false, "lenient": true, "quote_field_suffix": ".exact", "fields": ["title^5", "biblio_all^3", "abstracts.body^2", "fulltext.body", "everything"]}}], "should": [{"terms": {"access_type": ["ia_sim", "ia_file", "wayback"]}}]}}, "negative": {"bool": {"should": [{"bool": {"must_not": [{"exists": {"field": "title"}}]}}, {"bool": {"must_not": [{"exists": {"field": "year"}}]}}, {"bool": {"must_not": [{"exists": {"field": "type"}}]}}, {"bool": {"must_not": [{"exists": {"field": "stage"}}]}}, {"bool": {"must_not": [{"exists": {"field": "biblio.container_ident"}}]}}]}}, "negative_boost": 0.5}}]}}, "collapse": {"field": "collapse_key", "inner_hits": {"name": "more_pages", "size": 0}}, "from": 0, "size": 15, "highlight": {"fields": {"abstracts.body": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.body": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.acknowledgment": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.annex": {"number_of_fragments": 2, "fragment_size": 300}}}} diff --git a/tests/files/GET_search_ids.txt b/tests/files/GET_search_ids.txt deleted file mode 100644 index f22c8b1..0000000 --- a/tests/files/GET_search_ids.txt +++ /dev/null @@ -1,8 +0,0 @@ -GET /some-index/_search -{ - "query": { - "ids" : { - "values" : ["1", "4", "100"] - } - } -} diff --git a/tests/files/GET_search_match_all.txt b/tests/files/GET_search_match_all.txt deleted file mode 100644 index 1d9622c..0000000 --- a/tests/files/GET_search_match_all.txt +++ /dev/null @@ -1,6 +0,0 @@ -GET /some-index/_search -{ - "query": { - "match_all": { "boost" : 1.2 } - } -} diff --git a/tests/files/GET_search_match_none.txt b/tests/files/GET_search_match_none.txt deleted file mode 100644 index 12f50fc..0000000 --- a/tests/files/GET_search_match_none.txt +++ /dev/null @@ -1,6 +0,0 @@ -GET /some-index/_search -{ - "query": { - "match_none": {} - } -} diff --git a/tests/files/GET_search_multi_match.txt b/tests/files/GET_search_multi_match.txt deleted file mode 100644 index cf07050..0000000 --- a/tests/files/GET_search_multi_match.txt +++ /dev/null @@ -1,9 +0,0 @@ -GET /some-index/_search -{ - "query": { - "multi_match" : { - "query" : "this is a test", - "fields" : [ "subject^3", "message" ] - } - } -} diff --git a/tests/files/GET_search_multi_match_tie.txt b/tests/files/GET_search_multi_match_tie.txt deleted file mode 100644 index 54f71db..0000000 --- a/tests/files/GET_search_multi_match_tie.txt +++ /dev/null @@ -1,11 +0,0 @@ -GET /some-index/_search -{ - "query": { - "multi_match" : { - "query": "brown fox", - "type": "best_fields", - "fields": [ "subject", "message" ], - "tie_breaker": 0.3 - } - } -} diff --git a/tests/files/GET_search_prefix.txt b/tests/files/GET_search_prefix.txt deleted file mode 100644 index 3e35556..0000000 --- a/tests/files/GET_search_prefix.txt +++ /dev/null @@ -1,10 +0,0 @@ -GET /some-index/_search -{ - "query": { - "prefix": { - "user.id": { - "value": "ki" - } - } - } -} diff --git a/tests/files/GET_search_querystring.txt b/tests/files/GET_search_querystring.txt deleted file mode 100644 index 1c6e31e..0000000 --- a/tests/files/GET_search_querystring.txt +++ /dev/null @@ -1,14 +0,0 @@ -GET /some-index/_search -{ - "query": { - "query_string": { - "fields": [ - "title", - "content" - ], - "query": "this OR that OR thus", - "type": "cross_fields", - "minimum_should_match": 2 - } - } -} diff --git a/tests/files/GET_search_simplequerystring.txt b/tests/files/GET_search_simplequerystring.txt deleted file mode 100644 index 2ae5507..0000000 --- a/tests/files/GET_search_simplequerystring.txt +++ /dev/null @@ -1,10 +0,0 @@ -GET /some-index/_search -{ - "query": { - "simple_query_string" : { - "query": "\"fried eggs\" +(eggplant | potato) -frittata", - "fields": ["title^5", "body"], - "default_operator": "and" - } - } -} diff --git a/tests/files/GET_search_sort.txt b/tests/files/GET_search_sort.txt deleted file mode 100644 index 9a0567c..0000000 --- a/tests/files/GET_search_sort.txt +++ /dev/null @@ -1,13 +0,0 @@ -GET /my-index-000001/_search -{ - "sort" : [ - { "post_date" : {"order" : "asc"}}, - "user", - { "name" : "desc" }, - { "age" : "desc" }, - "_score" - ], - "query" : { - "term" : { "user" : "kimchy" } - } -} diff --git a/tests/files/GET_search_term.txt b/tests/files/GET_search_term.txt deleted file mode 100644 index 149587f..0000000 --- a/tests/files/GET_search_term.txt +++ /dev/null @@ -1,11 +0,0 @@ -GET /some-value/_search -{ - "query": { - "term": { - "user.id": { - "value": "kimchy", - "boost": 1.0 - } - } - } -} diff --git a/tests/files/GET_search_term_short.txt b/tests/files/GET_search_term_short.txt deleted file mode 100644 index 937a7b5..0000000 --- a/tests/files/GET_search_term_short.txt +++ /dev/null @@ -1,8 +0,0 @@ -GET /my-index-000001/_search?pretty=true -{ - "query": { - "match": { - "full_text": "Quick Brown Foxes!" - } - } -} diff --git a/tests/files/GET_search_wildcard.txt b/tests/files/GET_search_wildcard.txt deleted file mode 100644 index 6eb199d..0000000 --- a/tests/files/GET_search_wildcard.txt +++ /dev/null @@ -1,12 +0,0 @@ -GET /some-index/_search -{ - "query": { - "wildcard": { - "user.id": { - "value": "ki*y", - "boost": 1.0, - "rewrite": "constant_score" - } - } - } -} diff --git a/tests/files/GET_uri_search.txt b/tests/files/GET_uri_search.txt deleted file mode 100644 index e5e0567..0000000 --- a/tests/files/GET_uri_search.txt +++ /dev/null @@ -1 +0,0 @@ -GET /my-index-000001/_search?q=user.id:kimchy diff --git a/tests/files/POST_search_inner.txt.disabled b/tests/files/POST_search_inner.txt.disabled deleted file mode 100644 index 56c5acc..0000000 --- a/tests/files/POST_search_inner.txt.disabled +++ /dev/null @@ -1,17 +0,0 @@ -POST /test/_search -{ - "query": { - "nested": { - "path": "comments", - "query": { - "match": { "comments.text": "words" } - }, - "inner_hits": { - "_source": false, - "docvalue_fields": [ - "comments.text.keyword" - ] - } - } - } -} diff --git a/tests/files/POST_search_rescore.txt b/tests/files/POST_search_rescore.txt deleted file mode 100644 index 071cf5f..0000000 --- a/tests/files/POST_search_rescore.txt +++ /dev/null @@ -1,26 +0,0 @@ -POST /some-index/_search -{ - "query" : { - "match" : { - "message" : { - "operator" : "or", - "query" : "the quick brown" - } - } - }, - "rescore" : { - "window_size" : 50, - "query" : { - "rescore_query" : { - "match_phrase" : { - "message" : { - "query" : "the quick brown", - "slop" : 2 - } - } - }, - "query_weight" : 0.7, - "rescore_query_weight" : 1.2 - } - } -} diff --git a/tests/files/POST_search_sort_mode.txt b/tests/files/POST_search_sort_mode.txt deleted file mode 100644 index 54155ca..0000000 --- a/tests/files/POST_search_sort_mode.txt +++ /dev/null @@ -1,9 +0,0 @@ -POST /some-index/_search -{ - "query" : { - "term" : { "product" : "chocolate" } - }, - "sort" : [ - {"price" : {"order" : "asc", "mode" : "avg"}} - ] -} diff --git a/tests/files/POST_search_start_scroll.txt b/tests/files/POST_search_start_scroll.txt deleted file mode 100644 index 8c8fd00..0000000 --- a/tests/files/POST_search_start_scroll.txt +++ /dev/null @@ -1,9 +0,0 @@ -POST /my-index-000001/_search?scroll=1m -{ - "size": 100, - "query": { - "match": { - "message": "foo" - } - } -} diff --git a/tests/files/scroll_fail/DELETE_scroll_all.txt b/tests/files/scroll_fail/DELETE_scroll_all.txt new file mode 100644 index 0000000..5501c17 --- /dev/null +++ b/tests/files/scroll_fail/DELETE_scroll_all.txt @@ -0,0 +1,4 @@ +DELETE /_search/scroll +{ + "scroll_id" : "_all" +} diff --git a/tests/files/search/GET_collapse_expand.txt b/tests/files/search/GET_collapse_expand.txt new file mode 100644 index 0000000..dc6b1a8 --- /dev/null +++ b/tests/files/search/GET_collapse_expand.txt @@ -0,0 +1,24 @@ +GET /my-index-000001/_search +{ + "query": { + "match": { + "message": "GET /search" + } + }, + "collapse": { + "field": "user.id", + "inner_hits": [ + { + "name": "largest_responses", + "size": 3, + "sort": [ "http.response.bytes" ] + }, + { + "name": "most_recent", + "size": 3, + "sort": [ { "@timestamp": "asc" } ] + } + ] + }, + "sort": [ "http.response.bytes" ] +} diff --git a/tests/files/search/GET_collapse_nested.txt b/tests/files/search/GET_collapse_nested.txt new file mode 100644 index 0000000..a31c8e4 --- /dev/null +++ b/tests/files/search/GET_collapse_nested.txt @@ -0,0 +1,16 @@ +GET /my-index-000001/_search +{ + "query": { + "match": { + "message": "GET /search" + } + }, + "collapse": { + "field": "geo.country_name", + "inner_hits": { + "name": "by_location", + "collapse": { "field": "user.id" }, + "size": 3 + } + } +} diff --git a/tests/files/search/GET_highlight.txt b/tests/files/search/GET_highlight.txt new file mode 100644 index 0000000..8dc23ea --- /dev/null +++ b/tests/files/search/GET_highlight.txt @@ -0,0 +1,16 @@ +GET /my-index-000001/_search +{ + "query": { + "match_phrase": { "message": "number 1" } + }, + "highlight": { + "fields": { + "message": { + "type": "plain", + "fragment_size": 15, + "number_of_fragments": 3, + "fragmenter": "simple" + } + } + } +} diff --git a/tests/files/search/GET_highlight_complex.txt b/tests/files/search/GET_highlight_complex.txt new file mode 100644 index 0000000..288aa9f --- /dev/null +++ b/tests/files/search/GET_highlight_complex.txt @@ -0,0 +1,16 @@ +GET /some-index/_search +{ + "query" : { + "match": { "user.id": "kimchy" } + }, + "highlight" : { + "number_of_fragments" : 3, + "fragment_size" : 150, + "fields" : { + "body" : { "pre_tags" : [""], "post_tags" : [""] }, + "blog.title" : { "number_of_fragments" : 0 }, + "blog.author" : { "number_of_fragments" : 0 }, + "blog.comment" : { "number_of_fragments" : 5, "order" : "score" } + } + } +} diff --git a/tests/files/search/GET_highlight_fields.txt b/tests/files/search/GET_highlight_fields.txt new file mode 100644 index 0000000..85b55cb --- /dev/null +++ b/tests/files/search/GET_highlight_fields.txt @@ -0,0 +1,18 @@ +GET /some-index/_search +{ + "query": { + "query_string": { + "query": "running scissors", + "fields": ["comment", "comment.plain^10"] + } + }, + "highlight": { + "order": "score", + "fields": { + "comment": { + "matched_fields": ["comment", "comment.plain"], + "type" : "fvh" + } + } + } +} diff --git a/tests/files/search/GET_highlight_query.txt b/tests/files/search/GET_highlight_query.txt new file mode 100644 index 0000000..7c7f0ea --- /dev/null +++ b/tests/files/search/GET_highlight_query.txt @@ -0,0 +1,55 @@ +GET /some-index/_search +{ + "query": { + "match": { + "comment": { + "query": "foo bar" + } + } + }, + "rescore": { + "window_size": 50, + "query": { + "rescore_query": { + "match_phrase": { + "comment": { + "query": "foo bar", + "slop": 1 + } + } + }, + "rescore_query_weight": 10 + } + }, + "_source": false, + "highlight": { + "order": "score", + "fields": { + "comment": { + "fragment_size": 150, + "number_of_fragments": 3, + "highlight_query": { + "bool": { + "must": { + "match": { + "comment": { + "query": "foo bar" + } + } + }, + "should": { + "match_phrase": { + "comment": { + "query": "foo bar", + "slop": 1, + "boost": 10.0 + } + } + }, + "minimum_should_match": 0 + } + } + } + } + } +} diff --git a/tests/files/search/GET_range.txt b/tests/files/search/GET_range.txt new file mode 100644 index 0000000..a5321c3 --- /dev/null +++ b/tests/files/search/GET_range.txt @@ -0,0 +1,12 @@ +GET /some-index/_search +{ + "query": { + "range": { + "age": { + "gte": 10, + "lte": 20, + "boost": 2.0 + } + } + } +} diff --git a/tests/files/search/GET_search.txt b/tests/files/search/GET_search.txt new file mode 100644 index 0000000..7ff7ca6 --- /dev/null +++ b/tests/files/search/GET_search.txt @@ -0,0 +1,10 @@ +GET /some-index/_search +{ + "query": { + "match": { + "message": { + "query": "this is a test" + } + } + } +} diff --git a/tests/files/search/GET_search_agg_filter.txt b/tests/files/search/GET_search_agg_filter.txt new file mode 100644 index 0000000..538380a --- /dev/null +++ b/tests/files/search/GET_search_agg_filter.txt @@ -0,0 +1,28 @@ +GET /shirts/_search +{ + "query": { + "bool": { + "filter": { + "term": { "brand": "gucci" } + } + } + }, + "aggs": { + "colors": { + "terms": { "field": "color" } + }, + "color_red": { + "filter": { + "term": { "color": "red" } + }, + "aggs": { + "models": { + "terms": { "field": "model" } + } + } + } + }, + "post_filter": { + "term": { "color": "red" } + } +} diff --git a/tests/files/search/GET_search_agg_filter_simple.txt b/tests/files/search/GET_search_agg_filter_simple.txt new file mode 100644 index 0000000..71a9777 --- /dev/null +++ b/tests/files/search/GET_search_agg_filter_simple.txt @@ -0,0 +1,11 @@ +POST /sales/_search?size=0 +{ + "aggs": { + "t_shirts": { + "filter": { "term": { "type": "t-shirt" } }, + "aggs": { + "avg_price": { "avg": { "field": "price" } } + } + } + } +} diff --git a/tests/files/search/GET_search_agg_histogram.txt b/tests/files/search/GET_search_agg_histogram.txt new file mode 100644 index 0000000..4689ad1 --- /dev/null +++ b/tests/files/search/GET_search_agg_histogram.txt @@ -0,0 +1,13 @@ +POST /sales/_search?size=0 +{ + "aggs": { + "quantity": { + "histogram": { + "field": "quantity", + "interval": 10, + "keyed": true, + "missing": 0 + } + } + } +} diff --git a/tests/files/search/GET_search_agg_max.txt b/tests/files/search/GET_search_agg_max.txt new file mode 100644 index 0000000..1377afc --- /dev/null +++ b/tests/files/search/GET_search_agg_max.txt @@ -0,0 +1,11 @@ +POST /sales/_search +{ + "aggs" : { + "grade_max" : { + "max" : { + "field" : "grade", + "missing": 10 + } + } + } +} diff --git a/tests/files/search/GET_search_agg_nested.txt b/tests/files/search/GET_search_agg_nested.txt new file mode 100644 index 0000000..8e5d1c1 --- /dev/null +++ b/tests/files/search/GET_search_agg_nested.txt @@ -0,0 +1,16 @@ +GET /products/_search +{ + "query": { + "match": { "name": "led tv" } + }, + "aggs": { + "resellers": { + "nested": { + "path": "resellers" + }, + "aggs": { + "min_price": { "min": { "field": "resellers.price" } } + } + } + } +} diff --git a/tests/files/search/GET_search_bool.txt b/tests/files/search/GET_search_bool.txt new file mode 100644 index 0000000..3f402f9 --- /dev/null +++ b/tests/files/search/GET_search_bool.txt @@ -0,0 +1,15 @@ +GET /some-index/_search +{ + "query": { + "bool": { + "must": { + "match_all": {} + }, + "filter": { + "term": { + "status": "active" + } + } + } + } +} diff --git a/tests/files/search/GET_search_boosting.txt b/tests/files/search/GET_search_boosting.txt new file mode 100644 index 0000000..9045a54 --- /dev/null +++ b/tests/files/search/GET_search_boosting.txt @@ -0,0 +1,18 @@ +GET /some-index/_search +{ + "query": { + "boosting": { + "positive": { + "term": { + "text": "apple" + } + }, + "negative": { + "term": { + "text": "pie tart fruit crumble tree" + } + }, + "negative_boost": 0.5 + } + } +} diff --git a/tests/files/search/GET_search_docvalues.txt b/tests/files/search/GET_search_docvalues.txt new file mode 100644 index 0000000..2fd57b1 --- /dev/null +++ b/tests/files/search/GET_search_docvalues.txt @@ -0,0 +1,16 @@ +GET /some-index/_search +{ + "query": { + "match_all": {} + }, + "docvalue_fields": [ + "my_ip*", + { + "field": "my_keyword_field" + }, + { + "field": "*_date_field", + "format": "epoch_millis" + } + ] +} diff --git a/tests/files/search/GET_search_exists.txt b/tests/files/search/GET_search_exists.txt new file mode 100644 index 0000000..fe7d722 --- /dev/null +++ b/tests/files/search/GET_search_exists.txt @@ -0,0 +1,8 @@ +GET /some-index/_search +{ + "query": { + "exists": { + "field": "user" + } + } +} diff --git a/tests/files/search/GET_search_fatcat_preservation_year.txt b/tests/files/search/GET_search_fatcat_preservation_year.txt new file mode 100644 index 0000000..539677b --- /dev/null +++ b/tests/files/search/GET_search_fatcat_preservation_year.txt @@ -0,0 +1,2 @@ +GET /fatcat_release/_search +{"query": {"bool": {"filter": [{"term": {"container_id": "yh4zdhfsobdolesogv6czydwqi"}}, {"range": {"release_year": {"gte": 1771, "lte": 2020}}}]}}, "aggs": {"year_preservation": {"composite": {"size": 1500, "sources": [{"year": {"histogram": {"field": "release_year", "interval": 1}}}, {"preservation": {"terms": {"field": "preservation"}}}]}}}, "from": 0, "size": 0} diff --git a/tests/files/search/GET_search_fatcat_scholar_basic.txt b/tests/files/search/GET_search_fatcat_scholar_basic.txt new file mode 100644 index 0000000..c60e62f --- /dev/null +++ b/tests/files/search/GET_search_fatcat_scholar_basic.txt @@ -0,0 +1,2 @@ +GET /scholar_fulltext/_search +{"query": {"bool": {"filter": [{"terms": {"type": ["article-journal", "paper-conference", "chapter"]}}, {"terms": {"access_type": ["wayback", "ia_file", "ia_sim"]}}], "must": [{"boosting": {"positive": {"bool": {"must": [{"query_string": {"query": "coffee", "default_operator": "AND", "analyze_wildcard": true, "allow_leading_wildcard": false, "lenient": true, "quote_field_suffix": ".exact", "fields": ["title^5", "biblio_all^3", "abstracts.body^2", "fulltext.body", "everything"]}}], "should": [{"terms": {"access_type": ["ia_sim", "ia_file", "wayback"]}}]}}, "negative": {"bool": {"should": [{"bool": {"must_not": [{"exists": {"field": "title"}}]}}, {"bool": {"must_not": [{"exists": {"field": "year"}}]}}, {"bool": {"must_not": [{"exists": {"field": "type"}}]}}, {"bool": {"must_not": [{"exists": {"field": "stage"}}]}}, {"bool": {"must_not": [{"exists": {"field": "biblio.container_ident"}}]}}]}}, "negative_boost": 0.5}}]}}, "collapse": {"field": "collapse_key", "inner_hits": {"name": "more_pages", "size": 0}}, "from": 0, "size": 15, "highlight": {"fields": {"abstracts.body": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.body": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.acknowledgment": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.annex": {"number_of_fragments": 2, "fragment_size": 300}}}} diff --git a/tests/files/search/GET_search_ids.txt b/tests/files/search/GET_search_ids.txt new file mode 100644 index 0000000..f22c8b1 --- /dev/null +++ b/tests/files/search/GET_search_ids.txt @@ -0,0 +1,8 @@ +GET /some-index/_search +{ + "query": { + "ids" : { + "values" : ["1", "4", "100"] + } + } +} diff --git a/tests/files/search/GET_search_match_all.txt b/tests/files/search/GET_search_match_all.txt new file mode 100644 index 0000000..1d9622c --- /dev/null +++ b/tests/files/search/GET_search_match_all.txt @@ -0,0 +1,6 @@ +GET /some-index/_search +{ + "query": { + "match_all": { "boost" : 1.2 } + } +} diff --git a/tests/files/search/GET_search_match_none.txt b/tests/files/search/GET_search_match_none.txt new file mode 100644 index 0000000..12f50fc --- /dev/null +++ b/tests/files/search/GET_search_match_none.txt @@ -0,0 +1,6 @@ +GET /some-index/_search +{ + "query": { + "match_none": {} + } +} diff --git a/tests/files/search/GET_search_multi_match.txt b/tests/files/search/GET_search_multi_match.txt new file mode 100644 index 0000000..cf07050 --- /dev/null +++ b/tests/files/search/GET_search_multi_match.txt @@ -0,0 +1,9 @@ +GET /some-index/_search +{ + "query": { + "multi_match" : { + "query" : "this is a test", + "fields" : [ "subject^3", "message" ] + } + } +} diff --git a/tests/files/search/GET_search_multi_match_tie.txt b/tests/files/search/GET_search_multi_match_tie.txt new file mode 100644 index 0000000..54f71db --- /dev/null +++ b/tests/files/search/GET_search_multi_match_tie.txt @@ -0,0 +1,11 @@ +GET /some-index/_search +{ + "query": { + "multi_match" : { + "query": "brown fox", + "type": "best_fields", + "fields": [ "subject", "message" ], + "tie_breaker": 0.3 + } + } +} diff --git a/tests/files/search/GET_search_prefix.txt b/tests/files/search/GET_search_prefix.txt new file mode 100644 index 0000000..3e35556 --- /dev/null +++ b/tests/files/search/GET_search_prefix.txt @@ -0,0 +1,10 @@ +GET /some-index/_search +{ + "query": { + "prefix": { + "user.id": { + "value": "ki" + } + } + } +} diff --git a/tests/files/search/GET_search_querystring.txt b/tests/files/search/GET_search_querystring.txt new file mode 100644 index 0000000..1c6e31e --- /dev/null +++ b/tests/files/search/GET_search_querystring.txt @@ -0,0 +1,14 @@ +GET /some-index/_search +{ + "query": { + "query_string": { + "fields": [ + "title", + "content" + ], + "query": "this OR that OR thus", + "type": "cross_fields", + "minimum_should_match": 2 + } + } +} diff --git a/tests/files/search/GET_search_simplequerystring.txt b/tests/files/search/GET_search_simplequerystring.txt new file mode 100644 index 0000000..2ae5507 --- /dev/null +++ b/tests/files/search/GET_search_simplequerystring.txt @@ -0,0 +1,10 @@ +GET /some-index/_search +{ + "query": { + "simple_query_string" : { + "query": "\"fried eggs\" +(eggplant | potato) -frittata", + "fields": ["title^5", "body"], + "default_operator": "and" + } + } +} diff --git a/tests/files/search/GET_search_sort.txt b/tests/files/search/GET_search_sort.txt new file mode 100644 index 0000000..9a0567c --- /dev/null +++ b/tests/files/search/GET_search_sort.txt @@ -0,0 +1,13 @@ +GET /my-index-000001/_search +{ + "sort" : [ + { "post_date" : {"order" : "asc"}}, + "user", + { "name" : "desc" }, + { "age" : "desc" }, + "_score" + ], + "query" : { + "term" : { "user" : "kimchy" } + } +} diff --git a/tests/files/search/GET_search_term.txt b/tests/files/search/GET_search_term.txt new file mode 100644 index 0000000..149587f --- /dev/null +++ b/tests/files/search/GET_search_term.txt @@ -0,0 +1,11 @@ +GET /some-value/_search +{ + "query": { + "term": { + "user.id": { + "value": "kimchy", + "boost": 1.0 + } + } + } +} diff --git a/tests/files/search/GET_search_term_short.txt b/tests/files/search/GET_search_term_short.txt new file mode 100644 index 0000000..937a7b5 --- /dev/null +++ b/tests/files/search/GET_search_term_short.txt @@ -0,0 +1,8 @@ +GET /my-index-000001/_search?pretty=true +{ + "query": { + "match": { + "full_text": "Quick Brown Foxes!" + } + } +} diff --git a/tests/files/search/GET_search_wildcard.txt b/tests/files/search/GET_search_wildcard.txt new file mode 100644 index 0000000..6eb199d --- /dev/null +++ b/tests/files/search/GET_search_wildcard.txt @@ -0,0 +1,12 @@ +GET /some-index/_search +{ + "query": { + "wildcard": { + "user.id": { + "value": "ki*y", + "boost": 1.0, + "rewrite": "constant_score" + } + } + } +} diff --git a/tests/files/search/GET_uri_search.txt b/tests/files/search/GET_uri_search.txt new file mode 100644 index 0000000..e5e0567 --- /dev/null +++ b/tests/files/search/GET_uri_search.txt @@ -0,0 +1 @@ +GET /my-index-000001/_search?q=user.id:kimchy diff --git a/tests/files/search/POST_search_rescore.txt b/tests/files/search/POST_search_rescore.txt new file mode 100644 index 0000000..071cf5f --- /dev/null +++ b/tests/files/search/POST_search_rescore.txt @@ -0,0 +1,26 @@ +POST /some-index/_search +{ + "query" : { + "match" : { + "message" : { + "operator" : "or", + "query" : "the quick brown" + } + } + }, + "rescore" : { + "window_size" : 50, + "query" : { + "rescore_query" : { + "match_phrase" : { + "message" : { + "query" : "the quick brown", + "slop" : 2 + } + } + }, + "query_weight" : 0.7, + "rescore_query_weight" : 1.2 + } + } +} diff --git a/tests/files/search/POST_search_sort_mode.txt b/tests/files/search/POST_search_sort_mode.txt new file mode 100644 index 0000000..54155ca --- /dev/null +++ b/tests/files/search/POST_search_sort_mode.txt @@ -0,0 +1,9 @@ +POST /some-index/_search +{ + "query" : { + "term" : { "product" : "chocolate" } + }, + "sort" : [ + {"price" : {"order" : "asc", "mode" : "avg"}} + ] +} diff --git a/tests/files/search/POST_search_start_scroll.txt b/tests/files/search/POST_search_start_scroll.txt new file mode 100644 index 0000000..8c8fd00 --- /dev/null +++ b/tests/files/search/POST_search_start_scroll.txt @@ -0,0 +1,9 @@ +POST /my-index-000001/_search?scroll=1m +{ + "size": 100, + "query": { + "match": { + "message": "foo" + } + } +} diff --git a/tests/files/search_fail/POST_search_inner.txt b/tests/files/search_fail/POST_search_inner.txt new file mode 100644 index 0000000..56c5acc --- /dev/null +++ b/tests/files/search_fail/POST_search_inner.txt @@ -0,0 +1,17 @@ +POST /test/_search +{ + "query": { + "nested": { + "path": "comments", + "query": { + "match": { "comments.text": "words" } + }, + "inner_hits": { + "_source": false, + "docvalue_fields": [ + "comments.text.keyword" + ] + } + } + } +} diff --git a/tests/parse_es_requests.rs b/tests/parse_es_requests.rs index 8e84148..a55e461 100644 --- a/tests/parse_es_requests.rs +++ b/tests/parse_es_requests.rs @@ -8,24 +8,15 @@ mod common; #[test] fn basic_load() { - let parts = common::load_parts_by_name("GET_search"); + let parts = common::load_parts(std::path::Path::new("tests/files/search/GET_search.txt")); assert_eq!(parts.method, "GET"); assert_eq!(parts.path_and_query, "/some-index/_search"); } -#[test] -fn basic_parse() { - let parts = common::load_parts_by_name("GET_search"); - assert_eq!(parts.method, "GET"); - assert_eq!(parts.path_and_query, "/some-index/_search"); - - let _parsed: SearchBody = serde_json::from_str(&parts.body.unwrap()).unwrap(); -} - #[test] fn parse_search_bodies() { - let file_paths = fs::read_dir("tests/files").unwrap(); + let file_paths = fs::read_dir("tests/files/search").unwrap(); for path in file_paths { let path = path.unwrap().path(); @@ -65,7 +56,7 @@ fn parse_scroll_bodies() { #[test] fn filter_search_requests() { - let file_paths = fs::read_dir("tests/files").unwrap(); + let file_paths = fs::read_dir("tests/files/search").unwrap(); let mut config = ProxyConfig::default(); config.allow_all_indices = Some(true); let mut rt = tokio::runtime::Runtime::new().unwrap(); @@ -99,3 +90,36 @@ fn filter_scroll_requests() { rt.block_on(filter_request(req, &config)).unwrap(); } } + +#[test] +fn filter_failures() { + + let file_paths = fs::read_dir("tests/files/search_fail").unwrap(); + let mut config = ProxyConfig::default(); + config.allow_all_indices = Some(true); + let mut rt = tokio::runtime::Runtime::new().unwrap(); + + for path in file_paths { + let path = path.unwrap().path(); + if path.extension() != Some(OsStr::new("txt")) { + continue + } + println!(" filtering: {}", path.display()); + let req = common::load_request(&path); + let result = rt.block_on(filter_request(req, &config)); + assert!(result.is_err()); + } + + let file_paths = fs::read_dir("tests/files/scroll_fail").unwrap(); + + for path in file_paths { + let path = path.unwrap().path(); + if path.extension() != Some(OsStr::new("txt")) { + continue + } + println!(" filtering: {}", path.display()); + let req = common::load_request(&path); + let result = rt.block_on(filter_request(req, &config)); + assert!(result.is_err()); + } +} -- cgit v1.2.3