From d989004fd591636717bc190e5fa159e73475df25 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 17 Dec 2024 08:10:14 -0500 Subject: [PATCH] Fixed /_search/scroll/{scroll_id}, missing search tests. (#732) * Fixed /_search/scroll. Signed-off-by: dblock * Added tests for GET and POST /_search. Signed-off-by: dblock * Added a test for GET /_search/pipeline and DELETE /_search/pipeline/{id}. Signed-off-by: dblock * Added missing _search/point_in_time tests. Signed-off-by: dblock --------- Signed-off-by: dblock Signed-off-by: Nathalie Jonathan --- CHANGELOG.md | 1 + spec/namespaces/_core.yaml | 3 - tests/default/_core/point_in_time/all.yaml | 33 ++++++ tests/default/_core/search.yaml | 19 ++++ tests/default/_core/search/pipeline.yaml | 33 ++++++ .../response_processor/rename_field.yaml | 13 +-- tests/default/_core/search/point_in_time.yaml | 37 ++++++ tests/default/_core/search/scroll.yaml | 107 ++++++++++++++++++ tests/default/indices/search.yaml | 38 +++++++ .../default/indices/search/point_in_time.yaml | 30 +++++ 10 files changed, 301 insertions(+), 13 deletions(-) create mode 100644 tests/default/_core/point_in_time/all.yaml create mode 100644 tests/default/_core/search.yaml create mode 100644 tests/default/_core/search/pipeline.yaml create mode 100644 tests/default/_core/search/point_in_time.yaml create mode 100644 tests/default/_core/search/scroll.yaml create mode 100644 tests/default/indices/search.yaml create mode 100644 tests/default/indices/search/point_in_time.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 1507d6df2..10b6dbbce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed snapshot status numeric property types ([#729](https://github.com/opensearch-project/opensearch-api-specification/pull/729)) - Fixed request schema for `PATCH /_plugins/_security/api/nodesdn` ([#731](https://github.com/opensearch-project/opensearch-api-specification/pull/731)) - Fixed response schema for `GET /_plugins/_security/api/nodesdn/{cluster_name}` ([#731](https://github.com/opensearch-project/opensearch-api-specification/pull/731)) +- Fixed request body for `/_search/scroll/{scroll_id}` ([#732](https://github.com/opensearch-project/opensearch-api-specification/pull/732)) ### Changed - Changed `tasks._common:TaskInfo` and `tasks._common:TaskGroup` to be composed of a `tasks._common:TaskInfoBase` ([#683](https://github.com/opensearch-project/opensearch-api-specification/pull/683)) diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index a1c0e68b0..229fc9e55 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -2523,9 +2523,6 @@ components: $ref: '../schemas/_common.yaml#/components/schemas/Duration' scroll_id: $ref: '../schemas/_common.yaml#/components/schemas/ScrollId' - required: - - scroll_id - description: The scroll ID if not passed by URL or query parameter. search: content: application/json: diff --git a/tests/default/_core/point_in_time/all.yaml b/tests/default/_core/point_in_time/all.yaml new file mode 100644 index 000000000..86ff71e03 --- /dev/null +++ b/tests/default/_core/point_in_time/all.yaml @@ -0,0 +1,33 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test point-in-time. +version: '>= 2.4' +epilogues: + - path: /_search/point_in_time/_all + method: DELETE + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies}} + - {title: The Cruise, year: 1998} + - {create: {_index: movies}} + - {title: Drive, year: 1960} + - path: /movies/_search/point_in_time + method: POST + parameters: + keep_alive: 1m +chapters: + - synopsis: Get all point in time. + path: /_search/point_in_time/_all + method: GET + - synopsis: Delete all point in time. + path: /_search/point_in_time/_all + method: DELETE diff --git a/tests/default/_core/search.yaml b/tests/default/_core/search.yaml new file mode 100644 index 000000000..88072e844 --- /dev/null +++ b/tests/default/_core/search.yaml @@ -0,0 +1,19 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test search. +chapters: + - synopsis: Search across all indexes (GET). + path: /_search + method: GET + request: + payload: + query: + match_all: {} + - synopsis: Search across all indexes (POST). + path: /_search + method: POST + request: + payload: + query: + match_all: {} + \ No newline at end of file diff --git a/tests/default/_core/search/pipeline.yaml b/tests/default/_core/search/pipeline.yaml new file mode 100644 index 000000000..eab34717f --- /dev/null +++ b/tests/default/_core/search/pipeline.yaml @@ -0,0 +1,33 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test the creation of a search pipeline. +version: '>= 2.9' +epilogues: + - path: /_search/pipeline/empty-pipeline + method: DELETE + status: [200, 404] +chapters: + - synopsis: Create search pipeline. + path: /_search/pipeline/{id} + method: PUT + parameters: + id: empty-pipeline + request: + payload: {} + response: + status: 200 + payload: + acknowledged: true + - synopsis: Query all pipelines. + path: /_search/pipeline + method: GET + - synopsis: Query created pipeline. + path: /_search/pipeline/{id} + method: GET + parameters: + id: empty-pipeline + - synopsis: Delete created pipeline. + path: /_search/pipeline/{id} + method: DELETE + parameters: + id: empty-pipeline diff --git a/tests/default/_core/search/pipeline/response_processor/rename_field.yaml b/tests/default/_core/search/pipeline/response_processor/rename_field.yaml index 388d1414a..d2b05957b 100644 --- a/tests/default/_core/search/pipeline/response_processor/rename_field.yaml +++ b/tests/default/_core/search/pipeline/response_processor/rename_field.yaml @@ -13,7 +13,7 @@ prologues: name: Drive status: [201] epilogues: - - path: /_search/pipeline/names_pipeline + - path: /_search/pipeline/rename-field method: DELETE status: [200, 404] - path: /movies @@ -24,7 +24,7 @@ chapters: path: /_search/pipeline/{id} method: PUT parameters: - id: names_pipeline + id: rename-field request: payload: response_processors: @@ -35,13 +35,6 @@ chapters: status: 200 payload: acknowledged: true - - synopsis: Query created pipeline. - path: /_search/pipeline/{id} - method: GET - parameters: - id: names_pipeline - response: - status: 200 - synopsis: Search. warnings: multiple-paths-detected: false @@ -49,7 +42,7 @@ chapters: method: GET parameters: index: movies - search_pipeline: names_pipeline + search_pipeline: rename-field response: status: 200 payload: diff --git a/tests/default/_core/search/point_in_time.yaml b/tests/default/_core/search/point_in_time.yaml new file mode 100644 index 000000000..7eba25818 --- /dev/null +++ b/tests/default/_core/search/point_in_time.yaml @@ -0,0 +1,37 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test point-in-time. +version: '>= 2.4' +epilogues: + - path: /_search/point_in_time/_all + method: DELETE + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies}} + - {title: The Cruise, year: 1998} + - {create: {_index: movies}} + - {title: Drive, year: 1960} + - path: /movies/_search/point_in_time + id: pit + method: POST + parameters: + keep_alive: 1m + output: + id: payload.pit_id +chapters: + - synopsis: Delete all pits. + path: /_search/point_in_time + request: + payload: + pit_id: + - ${pit.id} + method: DELETE diff --git a/tests/default/_core/search/scroll.yaml b/tests/default/_core/search/scroll.yaml new file mode 100644 index 000000000..fb4baccd1 --- /dev/null +++ b/tests/default/_core/search/scroll.yaml @@ -0,0 +1,107 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test search scroll. +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies}} + - {title: The Lion King, year: 1994} + - {create: {_index: movies}} + - {title: Drive, year: 2011} + - {create: {_index: movies}} + - {title: Frozen, year: 2013} + - {create: {_index: movies}} + - {title: Moneyball, year: 2011} + - {create: {_index: movies}} + - {title: The Cruise, year: 1998} + - path: /movies/_search + method: GET + id: scroll + parameters: + scroll: 10m + request: + payload: + query: + match_all: {} + size: 1 + output: + scroll_id: payload._scroll_id +epilogues: + - path: /_search/scroll/_all + method: DELETE + - path: /movies + method: DELETE + status: [200, 404] +chapters: + - synopsis: Get the next batch of results (GET). + method: GET + path: /_search/scroll + request: + payload: + scroll: 10m + scroll_id: ${scroll.scroll_id} + response: + status: 200 + payload: + hits: + hits: + - _index: movies + _source: + title: Drive + - synopsis: Get the next batch of results (POST). + method: POST + path: /_search/scroll + request: + payload: + scroll: 10m + scroll_id: ${scroll.scroll_id} + response: + status: 200 + payload: + hits: + hits: + - _index: movies + _source: + title: Frozen + - synopsis: Get the next batch of results (GET). + method: GET + path: /_search/scroll/{scroll_id} + parameters: + scroll_id: ${scroll.scroll_id} + request: + payload: + scroll: 10m + response: + status: 200 + payload: + hits: + hits: + - _index: movies + _source: + title: Moneyball + - synopsis: Get the next batch of results (POST). + method: POST + path: /_search/scroll/{scroll_id} + parameters: + scroll_id: ${scroll.scroll_id} + request: + payload: + scroll: 10m + response: + status: 200 + payload: + hits: + hits: + - _index: movies + _source: + title: The Cruise + - synopsis: Delete the scroll. + method: DELETE + path: /_search/scroll/{scroll_id} + parameters: + scroll_id: ${scroll.scroll_id} diff --git a/tests/default/indices/search.yaml b/tests/default/indices/search.yaml new file mode 100644 index 000000000..b3f78261b --- /dev/null +++ b/tests/default/indices/search.yaml @@ -0,0 +1,38 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test search. +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies, _id: movie1}} + - {director: Quentin Tarantino, title: Pulp Fiction, year: 1994} + - {create: {_index: movies, _id: movie2}} + - {director: Christopher Nolan, title: Inception, year: 2010} +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +chapters: + - synopsis: Search in an index (GET). + path: /{index}/_search + method: GET + parameters: + index: movies + request: + payload: + query: + match_all: {} + - synopsis: Search across all indices (POST). + path: /{index}/_search + method: POST + parameters: + index: movies + request: + payload: + query: + match_all: {} diff --git a/tests/default/indices/search/point_in_time.yaml b/tests/default/indices/search/point_in_time.yaml new file mode 100644 index 000000000..c626db504 --- /dev/null +++ b/tests/default/indices/search/point_in_time.yaml @@ -0,0 +1,30 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test point-in-time. +version: '>= 2.4' +epilogues: + - path: /_search/point_in_time/_all + method: DELETE + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies}} + - {title: The Cruise, year: 1998} + - {create: {_index: movies}} + - {title: Drive, year: 1960} +chapters: + - synopsis: Create a point in time. + path: /{index}/_search/point_in_time + method: POST + parameters: + index: + - movies + keep_alive: 1m