From 5fd630bb3cdcad46ea0bff8d25d7367595b32ff8 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Fri, 23 Aug 2024 14:57:57 -0700 Subject: [PATCH 1/4] Add tests for SplitResponseProcessor Signed-off-by: Daniel Widdis --- CHANGELOG.md | 3 +- .../request_processor/filter_query.yaml | 2 +- .../response_processor/split_and_sort.yaml | 81 +++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a91329c..70503f81c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,7 +71,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added API spec for security plugin ([#271](https://github.com/opensearch-project/opensearch-api-specification/pull/271)) - Added `/_plugins/_security/api/certificates/` ([#439](https://github.com/opensearch-project/opensearch-api-specification/pull/439)) - Added `/_plugins/_ml/models/{model_id}/_deploy`, `_undeploy` and `knn_vector` type in `passage_embedding` ([#504](https://github.com/opensearch-project/opensearch-api-specification/pull/504)) -- Added `PersonalizeSearchRanking`, `RetrievalAugmentedGeneration`, `Rerank`, `Collapse`, `TruncateHits` and `SplitResponseProcessor` ([#505](https://github.com/opensearch-project/opensearch-api-specification/pull/505)) +- Added `PersonalizeSearchRanking`, `RetrievalAugmentedGeneration`, `Rerank`, `Collapse`, `TruncateHits`, `SortResponseProcessor` and `SplitResponseProcessor` ([#505](https://github.com/opensearch-project/opensearch-api-specification/pull/505)) - Added `/_plugins/_security/api/certificates/` to API spec ([#439](https://github.com/opensearch-project/opensearch-api-specification/pull/439)) - Added support for annotating and testing the API spec against multiple OpenSearch distributions ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483)) - Added `read_time`, `write_time`, `queue_size` and `io_time_in_millis` to `IoStatDevice` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483)) @@ -79,6 +79,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `cancelled_task_percentage` and `current_cancellation_eligible_tasks_count` to `ShardSearchBackpressureTaskCancellationStats` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483)) - Added detailed test coverage report ([#513](https://github.com/opensearch-project/opensearch-api-specification/pull/513)) - Added 404 responses to `/_alias/{name}` and `/{index}/_alias/{name}` ([#519](https://github.com/opensearch-project/opensearch-api-specification/pull/519)) +- Added tests for `SplitResponseProcessor` ([#526](https://github.com/opensearch-project/opensearch-api-specification/pull/526)) ### Changed diff --git a/tests/default/_core/search/pipeline/request_processor/filter_query.yaml b/tests/default/_core/search/pipeline/request_processor/filter_query.yaml index e2d2cfb79..458eeb749 100644 --- a/tests/default/_core/search/pipeline/request_processor/filter_query.yaml +++ b/tests/default/_core/search/pipeline/request_processor/filter_query.yaml @@ -1,7 +1,7 @@ $schema: ../../../../../../json_schemas/test_story.schema.yaml description: |- - Test the creation of a search pipeline with a response processor. + Test the creation of a search pipeline with a filter_query request processor. version: '>= 2.8' prologues: - path: /_bulk diff --git a/tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml b/tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml new file mode 100644 index 000000000..e35e5f02a --- /dev/null +++ b/tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml @@ -0,0 +1,81 @@ +$schema: ../../../../../../json_schemas/test_story.schema.yaml + +description: |- + Test the creation of a search pipeline with split and sort response processors. +version: '>= 2.17' +prologues: + - path: /numbers/_doc/1 + method: POST + parameters: + refresh: true + request: + payload: + number_string: + - 'zero,one,two,three' + status: [201] +epilogues: + - path: /_search/pipeline/numbers_pipeline + method: DELETE + status: [200, 404] + - path: /numbers + method: DELETE + status: [200, 404] +chapters: + - synopsis: Create search pipeline. + path: /_search/pipeline/{id} + method: PUT + parameters: + id: numbers_pipeline + request: + payload: + response_processors: + - split: + field: number_string + separator: ',' + target_field: number_strings + - sort: + field: number_strings + order: asc + target_field: sorted_number_strings + response: + status: 200 + payload: + acknowledged: true + - synopsis: Query created pipeline. + path: /_search/pipeline/{id} + method: GET + parameters: + id: numbers_pipeline + response: + status: 200 + - synopsis: Search. + warnings: + multiple-paths-detected: false + path: /{index}/_search + method: GET + parameters: + index: numbers + search_pipeline: numbers_pipeline + response: + status: 200 + payload: + hits: + total: + value: 1 + hits: + - _index: numbers + _source: + number_string: + - 'zero,one,two,three' + number_strings: + # eslint-disable yml/sort-sequence-values + - zero + - one + - two + - three + # eslint-enable yml/sort-sequence-values + sorted_number_strings: + - one + - three + - two + - zero \ No newline at end of file From 173fc2979b461066b5d4c8c111cdbf206edaa391 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Fri, 23 Aug 2024 23:21:16 -0700 Subject: [PATCH 2/4] Remove CHANGELOG entry for test addition Signed-off-by: Daniel Widdis --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70503f81c..3d9fd126f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,7 +79,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `cancelled_task_percentage` and `current_cancellation_eligible_tasks_count` to `ShardSearchBackpressureTaskCancellationStats` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483)) - Added detailed test coverage report ([#513](https://github.com/opensearch-project/opensearch-api-specification/pull/513)) - Added 404 responses to `/_alias/{name}` and `/{index}/_alias/{name}` ([#519](https://github.com/opensearch-project/opensearch-api-specification/pull/519)) -- Added tests for `SplitResponseProcessor` ([#526](https://github.com/opensearch-project/opensearch-api-specification/pull/526)) ### Changed From 83e68b9a330f1e8318cce6227b798e0e6f2202ca Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Mon, 26 Aug 2024 10:07:41 -0700 Subject: [PATCH 3/4] Update docker image to include these changes Signed-off-by: Daniel Widdis --- .github/workflows/test-spec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 13a218e29..c3220b9f4 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -34,10 +34,10 @@ jobs: tests: snapshot - version: 2.17.0 hub: opensearchstaging - ref: '@sha256:ed4274522a50228f41b50f1a7ea86e6b52fa6737072fc151b2624d22aff80d56' + ref: '@sha256:1273489ebbedcb470ea13563dae4c6dc6b2ed431e87e686ed931ae0733034b25' - version: 3.0.0 hub: opensearchstaging - ref: '@sha256:cab6f71b284485c44306f8f4849ad520283c2a32ece617109b38183ba29cc401' + ref: '@sha256:06af2ba4037f8423dc1a4ed3cd29108a1912774e7c659e73f0fac09e1bb2b63d' name: test-opensearch-spec (version=${{ matrix.entry.version }}, hub=${{ matrix.entry.hub || 'opensearchproject' }}, tests=${{ matrix.entry.tests || 'default' }}) runs-on: ubuntu-latest From e951787b057937d842cdf60aa93ee346fd81ba20 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Mon, 26 Aug 2024 10:23:47 -0700 Subject: [PATCH 4/4] Input should be a string not a single element array of string Signed-off-by: Daniel Widdis --- .../search/pipeline/response_processor/split_and_sort.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml b/tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml index e35e5f02a..3f5cc74d0 100644 --- a/tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml +++ b/tests/default/_core/search/pipeline/response_processor/split_and_sort.yaml @@ -10,8 +10,7 @@ prologues: refresh: true request: payload: - number_string: - - 'zero,one,two,three' + number_string: 'zero,one,two,three' status: [201] epilogues: - path: /_search/pipeline/numbers_pipeline @@ -65,8 +64,7 @@ chapters: hits: - _index: numbers _source: - number_string: - - 'zero,one,two,three' + number_string: 'zero,one,two,three' number_strings: # eslint-disable yml/sort-sequence-values - zero