Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
Signed-off-by: alen_abeshov <[email protected]>
  • Loading branch information
aabeshov committed Aug 9, 2024
1 parent c94c8f6 commit be75db3
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 68 deletions.
2 changes: 1 addition & 1 deletion spec/namespaces/observability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ components:
content:
application/json:
schema:
$ref: '../schemas/observability._common.yaml#/components/schemas/ObservabilityObject'
$ref: '../schemas/observability._common.yaml#/components/schemas/ObservabilityObjectList'
observability.get_object@404:
description: Not Found
content:
Expand Down
6 changes: 2 additions & 4 deletions spec/namespaces/query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ components:
application/json:
schema:
type: string
example: Created DataSource with name my_prometheus
query.datasources_update@200:
description: Updated
content:
application/json:
schema:
type: string
example: Updated DataSource with name my_prometheus
query.datasources_update@404:
description: Not Found
content:
Expand All @@ -117,8 +115,8 @@ components:
content:
application/json:
schema:
type: string
example: ''
type: object
properties: { }
query.datasource_delete@404:
description: Not Found
content:
Expand Down
5 changes: 0 additions & 5 deletions spec/schemas/observability._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ components:
savedQuery:
$ref: '#/components/schemas/SavedQuery'
required:
- createdTimeMs
- lastUpdatedTimeMs
- objectId
- operationalPanel
- savedQuery
- savedVisualization
- tenant

OperationalPanel:
Expand Down
53 changes: 39 additions & 14 deletions spec/schemas/query._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,38 @@ paths: {}
components:
schemas:
DataSourceList:
type: object
properties:
dataSources:
type: array
items:
$ref: '#/components/schemas/DataSource'
required:
- dataSources
type: array
items:
$ref: '#/components/schemas/DataSource'

DataSource:
type: object
properties:
name:
type: string
type:
description:
type: string
connector:
type: string
allowedRoles:
type: array
items:
type: string
properties:
type: object
additionalProperties: true
resultIndex:
type: string
status:
type: string
configuration:
$ref: '#/components/schemas/DataSourceConfiguration'
required:
- configuration
- connector
- name
- type
- properties
- resultIndex
- status

DataSourceConfiguration:
type: object
Expand Down Expand Up @@ -96,11 +106,26 @@ components:
properties:
name:
type: string
type:
description:
type: string
connector:
type: string
allowedRoles:
type: array
items:
type: string
properties:
type: object
additionalProperties: true
resultIndex:
type: string
status:
type: string
configuration:
$ref: '#/components/schemas/DataSourceConfiguration'
required:
- configuration
- connector
- name
- type
- properties
- resultIndex
- status
101 changes: 78 additions & 23 deletions tests/observability/datasources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,100 @@ $schema: ../../json_schemas/test_story.schema.yaml
description: Test various operations of the OpenSearch Query Datasources API.

prologues:
- path: /_plugins/_query/_datasources
- path: /_plugins/_query/_datasources/{datasource_name}
method: DELETE
parameters:
datasource_name: test_datasource
status: [204, 404]

chapters:
- synopsis: Create a new query datasource.
path: /_plugins/_query/_datasources
method: POST
request:
payload:
name: test_datasource
type: prometheus
configuration:
endpoint: "http://localhost:9090"
credentials:
username: "admin"
password: "admin"
epilogues:
- path: /_plugins/_query/_datasources/test_datasource
method: DELETE
status: [204, 404]
chapters:
- synopsis: Retrieve specific datasource.
path: /_plugins/_query/_datasources/test_datasource
description: ''
connector: PROMETHEUS
allowedRoles: []
properties:
prometheus.uri: 'http://localhost:9090'
resultIndex: query_execution_result_test_datasource
status: ACTIVE
response:
status: 201
payload: Created DataSource with name test_datasource

- synopsis: Retrieve the list of all query datasources.
path: /_plugins/_query/_datasources
method: GET
response:
status: 200
payload: []

- synopsis: Update specific datasource.
- synopsis: Retrieve a specific query datasource by name.
path: /_plugins/_query/_datasources/{datasource_name}
method: GET
parameters:
datasource_name: test_datasource
response:
status: 200
payload:
name: test_datasource
description: ''
connector: PROMETHEUS
allowedRoles: []
properties:
prometheus.uri: 'http://localhost:9090'
resultIndex: query_execution_result_test_datasource
status: ACTIVE

- synopsis: Update an existing query datasource.
path: /_plugins/_query/_datasources
method: PUT
request:
payload:
name: test_datasource
type: prometheus
configuration:
endpoint: "http://localhost:9091"
credentials:
username: "admin"
password: "admin"
description: Updated description
connector: PROMETHEUS
allowedRoles: []
properties:
prometheus.uri: 'http://localhost:9091'
resultIndex: query_execution_result_test_datasource
status: ACTIVE
response:
status: 200
payload: Updated DataSource with name test_datasource

- synopsis: Retrieve list of datasources.
path: /_plugins/_query/_datasources
- synopsis: Retrieve the updated query datasource by name.
path: /_plugins/_query/_datasources/{datasource_name}
method: GET
parameters:
datasource_name: test_datasource
response:
status: 200
payload:
name: test_datasource
description: Updated description
connector: PROMETHEUS
allowedRoles: []
properties:
prometheus.uri: 'http://localhost:9091'
resultIndex: query_execution_result_test_datasource
status: ACTIVE

- synopsis: Delete the query datasource by name.
path: /_plugins/_query/_datasources/{datasource_name}
method: DELETE
parameters:
datasource_name: test_datasource
response:
status: 204


epilogues:
- path: /_plugins/_query/_datasources/{datasource_name}
method: DELETE
parameters:
datasource_name: test_datasource
status: [204, 404]
Loading

0 comments on commit be75db3

Please sign in to comment.