From 0bea608dd91c9bbf12da4424f2a16e527fe627bf Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 31 Jul 2024 21:49:46 +0500 Subject: [PATCH] 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