From 0bea608dd91c9bbf12da4424f2a16e527fe627bf Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 31 Jul 2024 21:49:46 +0500 Subject: [PATCH 1/8] adding specs and tests for SQL Settings API Signed-off-by: Tokesh --- CHANGELOG.md | 1 - spec/_superseded_operations.yaml | 2 +- spec/namespaces/sql.yaml | 34 +++++++++++++++++++++++ spec/schemas/sql._common.yaml | 46 +++++++++++++++++++++++++++++++- tests/sql/query.yaml | 2 ++ tests/sql/settings.yaml | 24 +++++++++++++++++ 6 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 tests/sql/settings.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index a76163f31..3a3137cc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added JsonSchemaValidator, a wrapper for AJV ([#364](https://github.com/opensearch-project/opensearch-api-specification/issues/364)) - Added support for `application/cbor` responses ([#371](https://github.com/opensearch-project/opensearch-api-specification/pull/371)) - Added `/_plugins/_sql`, `close`, `explain` and `stats` ([#379](https://github.com/opensearch-project/opensearch-api-specification/pull/379)) -- Added tests for SQL namespace ([#379](https://github.com/opensearch-project/opensearch-api-specification/pull/379)) - Added support for `application/smile` responses ([#386](https://github.com/opensearch-project/opensearch-api-specification/pull/386)) - Added `doc_status`, `remote_store`, `segment_replication` and `unreferenced_file_cleanups_performed` to `SegmentStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395)) - Added `concurrent_query_*` and `search_idle_reactivate_count_total` fields to `SearchStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395)) diff --git a/spec/_superseded_operations.yaml b/spec/_superseded_operations.yaml index 768cb8a4d..2f6693133 100644 --- a/spec/_superseded_operations.yaml +++ b/spec/_superseded_operations.yaml @@ -586,7 +586,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml operations: - POST /_opendistro/_sql/settings: - superseded_by: /_plugins/_sql/settings + superseded_by: /_plugins/_query/settings operations: - PUT /_opendistro/_sql/stats: diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 0afdde2d8..bf890d02f 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -4,6 +4,21 @@ info: description: OpenSearch SQL API version: 1.0.0 paths: + /_plugins/_query/settings: + put: + operationId: sql.settings.0 + x-operation-group: sql.settings + x-version-added: '1.0' + description: Adds SQL settings to the standard OpenSearch cluster settings. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/settings/ + parameters: + - $ref: '#/components/parameters/sql.settings::query.format' + requestBody: + $ref: '#/components/requestBodies/sql.settings' + responses: + '200': + $ref: '#/components/responses/sql.settings@200' /_plugins/_sql: post: operationId: sql.query.0 @@ -83,6 +98,13 @@ paths: $ref: '#/components/responses/sql.post_stats@200' components: parameters: + sql.settings::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. sql.query::query.format: name: format in: query @@ -159,6 +181,12 @@ components: default: true description: Specifies whether to escape special characters in the results requestBodies: + sql.settings: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettings' + required: true sql.query: content: application/json: @@ -184,6 +212,12 @@ components: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStats' required: true responses: + sql.settings@200: + description: '' + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsResponse' sql.query@200: description: '' content: diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index ea1abf9f0..e10b2f81e 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -85,4 +85,48 @@ components: user: type: object execution_time: - type: object \ No newline at end of file + type: object + SqlSettings: + type: object + properties: + transient: + $ref: '#/components/schemas/Transient' + SqlSettingsResponse: + type: object + properties: + acknowledged: + type: boolean + persistent: + type: object + transient: + $ref: '#/components/schemas/Transient' + Transient: + type: object + properties: + plugins: + type: object + properties: + ppl: + type: object + properties: + enabled: + type: string + query: + type: object + properties: + memory_limit: + type: string + size_limit: + type: string + sql: + type: object + properties: + enabled: + type: string + slowlog: + type: string + cursor: + type: object + properties: + keep_alive: + type: string \ No newline at end of file diff --git a/tests/sql/query.yaml b/tests/sql/query.yaml index 9dba20594..3111d0d64 100644 --- a/tests/sql/query.yaml +++ b/tests/sql/query.yaml @@ -17,6 +17,8 @@ chapters: - synopsis: Get SQL query path: /_plugins/_sql method: POST + parameters: + sanitize: false request_body: payload: query: 'SELECT * FROM books' diff --git a/tests/sql/settings.yaml b/tests/sql/settings.yaml new file mode 100644 index 000000000..952cd9e81 --- /dev/null +++ b/tests/sql/settings.yaml @@ -0,0 +1,24 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test updating SQL settings in OS cluster. + +chapters: + - synopsis: Update SQL settings. + path: /_plugins/_query/settings + method: PUT + request_body: + payload: + transient: + plugins: + sql: + enabled: 'true' + slowlog: '2' + cursor: + keep_alive: "1m" + ppl: + enabled: 'true' + query: + memory_limit: "80%" + size_limit: "200" + response: + status: 200 \ No newline at end of file From 7acf0b64cec41c219610361571949bd587102aa4 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 31 Jul 2024 21:57:46 +0500 Subject: [PATCH 2/8] fix lint and validate ci Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 26 +++++++-------- spec/schemas/sql._common.yaml | 63 ++++++++++++++++++++--------------- tests/sql/settings.yaml | 6 ++-- 3 files changed, 53 insertions(+), 42 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index bf890d02f..3ab67069f 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -6,19 +6,19 @@ info: paths: /_plugins/_query/settings: put: - operationId: sql.settings.0 - x-operation-group: sql.settings - x-version-added: '1.0' - description: Adds SQL settings to the standard OpenSearch cluster settings. - externalDocs: - url: https://opensearch.org/docs/latest/search-plugins/sql/settings/ - parameters: - - $ref: '#/components/parameters/sql.settings::query.format' - requestBody: - $ref: '#/components/requestBodies/sql.settings' - responses: - '200': - $ref: '#/components/responses/sql.settings@200' + operationId: sql.settings.0 + x-operation-group: sql.settings + x-version-added: '1.0' + description: Adds SQL settings to the standard OpenSearch cluster settings. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/settings/ + parameters: + - $ref: '#/components/parameters/sql.settings::query.format' + requestBody: + $ref: '#/components/requestBodies/sql.settings' + responses: + '200': + $ref: '#/components/responses/sql.settings@200' /_plugins/_sql: post: operationId: sql.query.0 diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index e10b2f81e..957120953 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -104,29 +104,40 @@ components: type: object properties: plugins: - type: object - properties: - ppl: - type: object - properties: - enabled: - type: string - query: - type: object - properties: - memory_limit: - type: string - size_limit: - type: string - sql: - type: object - properties: - enabled: - type: string - slowlog: - type: string - cursor: - type: object - properties: - keep_alive: - type: string \ No newline at end of file + $ref: '#/components/schemas/Plugins' + Plugins: + type: object + properties: + ppl: + $ref: '#/components/schemas/Ppl' + query: + $ref: '#/components/schemas/Query' + sql: + $ref: '#/components/schemas/Sql' + Ppl: + type: object + properties: + enabled: + type: string + Query: + type: object + properties: + memory_limit: + type: string + size_limit: + type: string + + Sql: + type: object + properties: + enabled: + type: string + slowlog: + type: string + cursor: + $ref: '#/components/schemas/Cursor' + Cursor: + type: object + properties: + keep_alive: + type: string \ No newline at end of file diff --git a/tests/sql/settings.yaml b/tests/sql/settings.yaml index 952cd9e81..894b51af6 100644 --- a/tests/sql/settings.yaml +++ b/tests/sql/settings.yaml @@ -14,11 +14,11 @@ chapters: enabled: 'true' slowlog: '2' cursor: - keep_alive: "1m" + keep_alive: 1m ppl: enabled: 'true' query: - memory_limit: "80%" - size_limit: "200" + memory_limit: '80%' + size_limit: '200' response: status: 200 \ No newline at end of file From a6e350257aeafe2310035901d49ff95e23db92ce Mon Sep 17 00:00:00 2001 From: Tokesh Date: Thu, 1 Aug 2024 22:52:54 +0500 Subject: [PATCH 3/8] adding version plain version of request body Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 4 +++- spec/schemas/sql._common.yaml | 23 +++++++++++++++++++++-- tests/sql/settings.yaml | 14 ++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 3ab67069f..721ae9d39 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -185,7 +185,9 @@ components: content: application/json: schema: - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettings' + anyOf: + - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsPlain' + - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettings' required: true sql.query: content: diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 957120953..96c60c92d 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -91,6 +91,11 @@ components: properties: transient: $ref: '#/components/schemas/Transient' + SqlSettingsPlain: + type: object + properties: + transient: + $ref: '#/components/schemas/TransientPlain' SqlSettingsResponse: type: object properties: @@ -126,7 +131,6 @@ components: type: string size_limit: type: string - Sql: type: object properties: @@ -140,4 +144,19 @@ components: type: object properties: keep_alive: - type: string \ No newline at end of file + type: string + TransientPlain: + type: object + properties: + plugins.sql.enabled: + type: boolean + plugins.ppl.enabled: + type: boolean + plugins.sql.slowlog: + type: integer + plugins.sql.cursor.keep_alive: + type: string + plugins.query.memory_limit: + type: string + plugins.query.size_limit: + type: integer \ No newline at end of file diff --git a/tests/sql/settings.yaml b/tests/sql/settings.yaml index 894b51af6..15d48f0da 100644 --- a/tests/sql/settings.yaml +++ b/tests/sql/settings.yaml @@ -20,5 +20,19 @@ chapters: query: memory_limit: '80%' size_limit: '200' + response: + status: 200 + - synopsis: Update SQL settings with plain request body. + path: /_plugins/_query/settings + method: PUT + request_body: + payload: + transient: + "plugins.sql.enabled" : true + "plugins.ppl.enabled" : true + "plugins.sql.slowlog" : 2 + "plugins.sql.cursor.keep_alive" : "1m" + "plugins.query.memory_limit" : "80%" + "plugins.query.size_limit": 200 response: status: 200 \ No newline at end of file From f4c2be74e64199ea551221253f009a32e6d0c674 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Thu, 1 Aug 2024 22:55:39 +0500 Subject: [PATCH 4/8] hotfix lint Signed-off-by: Tokesh --- tests/sql/settings.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/sql/settings.yaml b/tests/sql/settings.yaml index 15d48f0da..aba36caf8 100644 --- a/tests/sql/settings.yaml +++ b/tests/sql/settings.yaml @@ -28,11 +28,11 @@ chapters: request_body: payload: transient: - "plugins.sql.enabled" : true - "plugins.ppl.enabled" : true - "plugins.sql.slowlog" : 2 - "plugins.sql.cursor.keep_alive" : "1m" - "plugins.query.memory_limit" : "80%" - "plugins.query.size_limit": 200 + plugins.sql.enabled: true + plugins.ppl.enabled: true + plugins.sql.slowlog: 2 + plugins.sql.cursor.keep_alive: 1m + plugins.query.memory_limit: '80%' + plugins.query.size_limit: 200 response: status: 200 \ No newline at end of file From 72d367df7b4820371474051a9829bd98bf77dba1 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Thu, 1 Aug 2024 23:26:31 +0500 Subject: [PATCH 5/8] deleting unnecessary descriptions in sql namespace specs Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 721ae9d39..aeba15e55 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -104,14 +104,12 @@ components: description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.query::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.query::query.sanitize: name: sanitize in: query @@ -119,14 +117,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.explain::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.explain::query.sanitize: name: sanitize in: query @@ -134,14 +130,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.close::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.close::query.sanitize: name: sanitize in: query @@ -149,14 +143,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.get_stats::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.get_stats::query.sanitize: name: sanitize in: query @@ -164,14 +156,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.post_stats::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.post_stats::query.sanitize: name: sanitize in: query @@ -179,7 +169,6 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results requestBodies: sql.settings: content: @@ -215,13 +204,11 @@ components: required: true responses: sql.settings@200: - description: '' content: application/json: schema: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsResponse' sql.query@200: - description: '' content: application/json: schema: From 57b6a538c0835bc593d2676a87707e77c9049cb6 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Thu, 1 Aug 2024 23:45:33 +0500 Subject: [PATCH 6/8] adding anyOf to few parameters in SQL schemas Signed-off-by: Tokesh --- spec/schemas/sql._common.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 96c60c92d..3d1a9600d 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -123,21 +123,29 @@ components: type: object properties: enabled: - type: string + anyOf: + - type: boolean + - type: string Query: type: object properties: memory_limit: type: string size_limit: - type: string + anyOf: + - type: string + - type: integer Sql: type: object properties: enabled: - type: string + anyOf: + - type: boolean + - type: string slowlog: - type: string + anyOf: + - type: integer + - type: string cursor: $ref: '#/components/schemas/Cursor' Cursor: From 281d5553b341e457d8d2e50a3fe4d4348b847eed Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Fri, 2 Aug 2024 22:03:15 +0500 Subject: [PATCH 7/8] adding changelog changes Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a3137cc5..cea8512e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `plugins` to NodeInfoSettings ([#442](https://github.com/opensearch-project/opensearch-api-specification/pull/442)) - Added test coverage ([#443](https://github.com/opensearch-project/opensearch-api-specification/pull/443)) - Added `--opensearch-version` to `merger` that excludes schema elements per semver ([#428](https://github.com/opensearch-project/opensearch-api-specification/pull/428)) +- Added `/_plugins/_query/settings` ([#456](https://github.com/opensearch-project/opensearch-api-specification/pull/456)) ### Changed From 41b888e830d91ff75c69797234ae518f06397d97 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Fri, 2 Aug 2024 23:10:47 +0500 Subject: [PATCH 8/8] fixing types in tests Signed-off-by: Tokesh --- tests/sql/settings.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/sql/settings.yaml b/tests/sql/settings.yaml index aba36caf8..68e5f91c7 100644 --- a/tests/sql/settings.yaml +++ b/tests/sql/settings.yaml @@ -11,15 +11,15 @@ chapters: transient: plugins: sql: - enabled: 'true' + enabled: true slowlog: '2' cursor: keep_alive: 1m ppl: - enabled: 'true' + enabled: true query: memory_limit: '80%' - size_limit: '200' + size_limit: 200 response: status: 200 - synopsis: Update SQL settings with plain request body.