Skip to content

Commit

Permalink
adding specs and tests for SQL Settings API
Browse files Browse the repository at this point in the history
Signed-off-by: Tokesh <[email protected]>
  • Loading branch information
Tokesh committed Jul 31, 2024
1 parent 7cae0b8 commit 0bea608
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 3 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion spec/_superseded_operations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 34 additions & 0 deletions spec/namespaces/sql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ info:
description: OpenSearch SQL API
version: 1.0.0
paths:
/_plugins/_query/settings:
put:
operationId: sql.settings.0

Check failure on line 9 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8 spaces
x-operation-group: sql.settings

Check failure on line 10 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8 spaces
x-version-added: '1.0'

Check failure on line 11 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8 spaces
description: Adds SQL settings to the standard OpenSearch cluster settings.

Check failure on line 12 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8 spaces
externalDocs:

Check failure on line 13 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8 spaces
url: https://opensearch.org/docs/latest/search-plugins/sql/settings/

Check failure on line 14 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 10 spaces
parameters:

Check failure on line 15 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8 spaces
- $ref: '#/components/parameters/sql.settings::query.format'

Check failure on line 16 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 10 spaces
requestBody:

Check failure on line 17 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8 spaces
$ref: '#/components/requestBodies/sql.settings'

Check failure on line 18 in spec/namespaces/sql.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 10 spaces
responses:
'200':
$ref: '#/components/responses/sql.settings@200'
/_plugins/_sql:
post:
operationId: sql.query.0
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
46 changes: 45 additions & 1 deletion spec/schemas/sql._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,48 @@ components:
user:
type: object
execution_time:
type: object
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
2 changes: 2 additions & 0 deletions tests/sql/query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ chapters:
- synopsis: Get SQL query
path: /_plugins/_sql
method: POST
parameters:
sanitize: false
request_body:
payload:
query: 'SELECT * FROM books'
Expand Down
24 changes: 24 additions & 0 deletions tests/sql/settings.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0bea608

Please sign in to comment.