From eb948fb1535127f185b432994155d2d4fa999c18 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 17 Dec 2024 11:54:54 -0500 Subject: [PATCH 1/3] Added tests for /_validate/query. (#739) * Added tests for /_validate/query. Signed-off-by: dblock * Added retry for https://github.com/opensearch-project/opensearch-api-specification/issues/738. Signed-off-by: dblock --------- Signed-off-by: dblock --- tests/default/_core/validate/query.yaml | 17 +++++++++++++++++ tests/default/indices/validate/query.yaml | 23 +++++------------------ tests/plugins/security/api/nodesdn.yaml | 2 ++ 3 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 tests/default/_core/validate/query.yaml diff --git a/tests/default/_core/validate/query.yaml b/tests/default/_core/validate/query.yaml new file mode 100644 index 000000000..1c5849c01 --- /dev/null +++ b/tests/default/_core/validate/query.yaml @@ -0,0 +1,17 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test validating queries. +chapters: + - synopsis: Validate a query. + path: /_validate/query + method: + - GET + - POST + request: + payload: + query: + match_all: {} + response: + status: 200 + payload: + valid: true diff --git a/tests/default/indices/validate/query.yaml b/tests/default/indices/validate/query.yaml index 264579058..55ced1fb8 100644 --- a/tests/default/indices/validate/query.yaml +++ b/tests/default/indices/validate/query.yaml @@ -1,6 +1,6 @@ $schema: ../../../../json_schemas/test_story.schema.yaml -description: Test validating queries for a specific index using both GET and POST methods. +description: Test validating queries for a specific index. epilogues: - path: /movies method: DELETE @@ -18,9 +18,11 @@ prologues: - {create: {_index: movies, _id: movie2}} - {director: Nicolas Winding Refn, title: Drive, year: 1960} chapters: - - synopsis: Validate a match query (GET). + - synopsis: Validate a match query. path: /{index}/_validate/query - method: GET + method: + - GET + - POST parameters: index: movies request: @@ -32,18 +34,3 @@ chapters: status: 200 payload: valid: true - - - synopsis: Validate a match query (POST). - path: /{index}/_validate/query - method: POST - parameters: - index: movies - request: - payload: - query: - match: - title: Drive - response: - status: 200 - payload: - valid: true \ No newline at end of file diff --git a/tests/plugins/security/api/nodesdn.yaml b/tests/plugins/security/api/nodesdn.yaml index 176a748c9..6a4611ef3 100644 --- a/tests/plugins/security/api/nodesdn.yaml +++ b/tests/plugins/security/api/nodesdn.yaml @@ -15,6 +15,8 @@ chapters: payload: nodes_dn: - CN=cluster.example.com + retry: + count: 3 response: status: 201 payload: From b9e9c01fcdc505753073b5a9733309fa621c5d79 Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Tue, 17 Dec 2024 23:03:23 +0500 Subject: [PATCH 2/3] Term vectors API tests (#734) * added tests for term vectors and removed id from required of termvectors@200 Signed-off-by: Tokesh * added type for term vectors, fixing lint Signed-off-by: Tokesh * hotfix path Signed-off-by: Tokesh * adding multi term vectors Signed-off-by: Tokesh * renaming folder and lint fix Signed-off-by: Tokesh * adding type to mterm vector specs Signed-off-by: Tokesh * hotfix of string Signed-off-by: Tokesh * added type to wrong place of specs Signed-off-by: Tokesh * adding core mtermvectors Signed-off-by: Tokesh * using multiple method, fix grammar in changelog Signed-off-by: Tokesh --------- Signed-off-by: Tokesh Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- CHANGELOG.md | 2 + spec/namespaces/_core.yaml | 3 +- spec/schemas/_core.mtermvectors.yaml | 2 + tests/default/_core/mtermvectors.yaml | 44 ++++++++++++++++++++ tests/default/indices/mtermvectors.yaml | 45 +++++++++++++++++++++ tests/default/indices/termvectors.yaml | 53 +++++++++++++++++++++++++ 6 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 tests/default/_core/mtermvectors.yaml create mode 100644 tests/default/indices/mtermvectors.yaml create mode 100644 tests/default/indices/termvectors.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b6dbbce..32d445c24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added response schema for `GET /_plugins/_knn/warmup/{index}` ([#717](https://github.com/opensearch-project/opensearch-api-specification/pull/717)) - Added support for multiple test verbs ([#724](https://github.com/opensearch-project/opensearch-api-specification/pull/724)) - Added support for using a certificate and key in tests ([#731](https://github.com/opensearch-project/opensearch-api-specification/pull/731)) +- Added `_type` to `termvector` and `mtermvector` ([#734](https://github.com/opensearch-project/opensearch-api-specification/pull/734)) ### Removed - Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652)) @@ -45,6 +46,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Removed unsupported `cause` and `create` from `/_index_template/_simulate_index/{name}` ([#691](https://github.com/opensearch-project/opensearch-api-specification/pull/691)) - Removed `mappings` from `required` in `indices.simulate_template#Template` ([#691](https://github.com/opensearch-project/opensearch-api-specification/pull/691)) - Removed `HealthStatusCapatilized` and merged it with `HealthStatus` ([#725](https://github.com/opensearch-project/opensearch-api-specification/pull/725)) +- Removed `id` from `required` in `indices.termvectors@200` ([#734](https://github.com/opensearch-project/opensearch-api-specification/pull/734)) ### Fixed - Spec passes OpenAPI 3.1.0 validations ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index 229fc9e55..bcbbaf8da 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -3338,8 +3338,9 @@ components: format: int64 _version: $ref: '../schemas/_common.yaml#/components/schemas/VersionNumber' + _type: + $ref: '../schemas/_common.yaml#/components/schemas/Type' required: - - _id - _index - _version - found diff --git a/spec/schemas/_core.mtermvectors.yaml b/spec/schemas/_core.mtermvectors.yaml index deae8eda6..503dccafb 100644 --- a/spec/schemas/_core.mtermvectors.yaml +++ b/spec/schemas/_core.mtermvectors.yaml @@ -62,6 +62,8 @@ components: $ref: '_core.termvectors.yaml#/components/schemas/TermVector' error: $ref: '_common.yaml#/components/schemas/ErrorCause' + _type: + $ref: '_common.yaml#/components/schemas/Type' required: - _id - _index diff --git a/tests/default/_core/mtermvectors.yaml b/tests/default/_core/mtermvectors.yaml new file mode 100644 index 000000000..497abd3ff --- /dev/null +++ b/tests/default/_core/mtermvectors.yaml @@ -0,0 +1,44 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _mtermvectors APIs. +prologues: + - path: /books + method: PUT + request: + payload: + mappings: + properties: + author: + type: text + title: + term_vector: yes + type: text + year: + type: integer + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book1}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book2}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} +epilogues: + - path: /books + method: DELETE + status: [200, 404] + +chapters: + - synopsis: Retrieve term vectors for specific documents. + path: /_mtermvectors + method: + - GET + - POST + request: + payload: + docs: + - _id: book1 + _index: books \ No newline at end of file diff --git a/tests/default/indices/mtermvectors.yaml b/tests/default/indices/mtermvectors.yaml new file mode 100644 index 000000000..e9a7978ed --- /dev/null +++ b/tests/default/indices/mtermvectors.yaml @@ -0,0 +1,45 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _mtermvectors APIs. +prologues: + - path: /books + method: PUT + request: + payload: + mappings: + properties: + author: + type: text + title: + term_vector: yes + type: text + year: + type: integer + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book1}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book2}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} +epilogues: + - path: /books + method: DELETE + status: [200, 404] + +chapters: + - synopsis: Retrieve term vectors for specific documents in an index. + path: /{index}/_mtermvectors + parameters: + index: books + method: + - GET + - POST + request: + payload: + docs: + - _id: book1 \ No newline at end of file diff --git a/tests/default/indices/termvectors.yaml b/tests/default/indices/termvectors.yaml new file mode 100644 index 000000000..da53e1038 --- /dev/null +++ b/tests/default/indices/termvectors.yaml @@ -0,0 +1,53 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _termvectors APIs. +prologues: + - path: /books + method: PUT + request: + payload: + mappings: + properties: + author: + type: text + title: + term_vector: yes + type: text + year: + type: integer + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book1}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book2}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} +epilogues: + - path: /books + method: DELETE + status: [200, 404] + +chapters: + - synopsis: Get term vectors for a specific index. + path: /{index}/_termvectors + parameters: + index: books + method: + - GET + - POST + request: + payload: + doc: + title: To kill + - synopsis: Get term vectors for a document by its ID. + path: /{index}/_termvectors/{id} + parameters: + index: books + id: book1 + method: + - GET + - POST \ No newline at end of file From 4226d83a23bd85bf59d9a17e3899e370d47cec3e Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Tue, 17 Dec 2024 23:04:08 +0500 Subject: [PATCH 3/3] Msearch template API tests (#735) * added msearch template tests Signed-off-by: Tokesh * lint fix Signed-off-by: Tokesh * added core msearch template tests Signed-off-by: Tokesh * added msearch get tests Signed-off-by: Tokesh * renaming folders, using multiple methods, deleting default code Signed-off-by: Tokesh --------- Signed-off-by: Tokesh Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- CHANGELOG.md | 1 + spec/schemas/_core.msearch_template.yaml | 4 +- .../{msearch.yaml => msearch/index.yaml} | 38 +++---------------- tests/default/_core/msearch/template.yaml | 35 +++++++++++++++++ .../{msearch.yaml => msearch/index.yaml} | 10 ++--- tests/default/indices/msearch/template.yaml | 37 ++++++++++++++++++ 6 files changed, 86 insertions(+), 39 deletions(-) rename tests/default/_core/{msearch.yaml => msearch/index.yaml} (61%) create mode 100644 tests/default/_core/msearch/template.yaml rename tests/default/indices/{msearch.yaml => msearch/index.yaml} (87%) create mode 100644 tests/default/indices/msearch/template.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 32d445c24..94549cf2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) +- Fixed type in `_msearch/template` ([#735](https://github.com/opensearch-project/opensearch-api-specification/pull/735)) ### 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/schemas/_core.msearch_template.yaml b/spec/schemas/_core.msearch_template.yaml index f9e164e84..c87bbc3da 100644 --- a/spec/schemas/_core.msearch_template.yaml +++ b/spec/schemas/_core.msearch_template.yaml @@ -25,7 +25,9 @@ components: The value is the variable value. type: object additionalProperties: - type: object + oneOf: + - type: string + - type: object profile: description: When `true`, provides a profile for the query execution. type: boolean diff --git a/tests/default/_core/msearch.yaml b/tests/default/_core/msearch/index.yaml similarity index 61% rename from tests/default/_core/msearch.yaml rename to tests/default/_core/msearch/index.yaml index 6cff72802..7cb893404 100644 --- a/tests/default/_core/msearch.yaml +++ b/tests/default/_core/msearch/index.yaml @@ -1,4 +1,4 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../../../json_schemas/test_story.schema.yaml description: Test document multi-search. epilogues: @@ -25,7 +25,9 @@ prologues: chapters: - synopsis: Run multiple search requests in single request (GET). path: /_msearch - method: GET + method: + - GET + - POST request: content_type: application/x-ndjson payload: @@ -52,34 +54,4 @@ chapters: - _index: movies _id: movie1 - _index: movies - _id: movie2 - - synopsis: Run multiple search requests in single request (POST). - path: /_msearch - method: POST - request: - content_type: application/x-ndjson - payload: - - {index: movies} - - {query: {match_all: {}}} - - {index: books} - - {query: {match_all: {}}} - response: - status: 200 - payload: - responses: - - hits: - total: - value: 2 - relation: eq - hits: - - _index: movies - _id: movie1 - - _index: movies - _id: movie2 - - hits: - total: - value: 1 - relation: eq - hits: - - _index: books - _id: book1 + _id: movie2 \ No newline at end of file diff --git a/tests/default/_core/msearch/template.yaml b/tests/default/_core/msearch/template.yaml new file mode 100644 index 000000000..f1246f644 --- /dev/null +++ b/tests/default/_core/msearch/template.yaml @@ -0,0 +1,35 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test _msearch/template APIs. +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book1}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book2}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} + - {create: {_index: books, _id: book3}} + - {author: George Orwell, title: '1984', year: 1949} +epilogues: + - path: /books + method: DELETE + status: [200, 404] + +chapters: + - synopsis: Perform a multi-search template query using a GET request. + path: /_msearch/template + method: + - GET + - POST + request: + content_type: application/x-ndjson + payload: + - {index: books} + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Mockingbird}} + - {index: books} + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Beast}} \ No newline at end of file diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch/index.yaml similarity index 87% rename from tests/default/indices/msearch.yaml rename to tests/default/indices/msearch/index.yaml index ba5cd97eb..53fbb7122 100644 --- a/tests/default/indices/msearch.yaml +++ b/tests/default/indices/msearch/index.yaml @@ -1,4 +1,4 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../../../json_schemas/test_story.schema.yaml description: Test endpoints relevant to the lifecycle of an index, including multi-get and multi-search operations. prologues: @@ -22,7 +22,9 @@ epilogues: chapters: - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call. path: /{index}/_msearch - method: POST + method: + - GET + - POST parameters: index: books request: @@ -31,6 +33,4 @@ chapters: - {index: books} - {query: {match: {title: To Kill a Mockingbird}}} - {index: books} - - {query: {match: {title: The Cruise}}} - response: - status: 200 \ No newline at end of file + - {query: {match: {title: The Cruise}}} \ No newline at end of file diff --git a/tests/default/indices/msearch/template.yaml b/tests/default/indices/msearch/template.yaml new file mode 100644 index 000000000..0586dc449 --- /dev/null +++ b/tests/default/indices/msearch/template.yaml @@ -0,0 +1,37 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test _msearch/template APIs. +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book1}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book2}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} + - {create: {_index: books, _id: book3}} + - {author: George Orwell, title: '1984', year: 1949} +epilogues: + - path: /books + method: DELETE + status: [200, 404] + +chapters: + - synopsis: Perform a multi-search template query using a GET request. + path: /{index}/_msearch/template + parameters: + index: books + method: + - GET + - POST + request: + content_type: application/x-ndjson + payload: + - {index: books} + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Mockingbird}} + - {index: books} + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Beast}} \ No newline at end of file