Skip to content

Commit

Permalink
More tests. (#693)
Browse files Browse the repository at this point in the history
* Added test for POST /_mget.

Signed-off-by: dblock <[email protected]>

* Added tests for GET /_mapping/field/{fields}.

Signed-off-by: dblock <[email protected]>

* Added tests for /_list.

Signed-off-by: dblock <[email protected]>

* Added tests for /_plugins/_flow_framework/workflow/_search and state/_search.

Signed-off-by: dblock <[email protected]>

* Simplify field test.

Signed-off-by: dblock <[email protected]>

---------

Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock authored Nov 26, 2024
1 parent 9323eec commit c888a16
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 94 deletions.
12 changes: 12 additions & 0 deletions tests/default/_core/list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test _list operations.
# TODO: Re-enable in 3.0, see https://github.com/opensearch-project/opensearch-api-specification/pull/613
version: '>= 2.18 < 3.0'
chapters:
- synopsis: Returns available list APIs.
path: /_list
method: GET
response:
status: 200
content_type: text/plain
28 changes: 28 additions & 0 deletions tests/default/_core/mapping/field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test field mappings.
prologues:
- path: /{index}
method: PUT
parameters:
index: movies
request:
payload:
mappings:
properties:
director:
type: text
year:
type: integer
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Get field mappings across multiple indexes.
path: /_mapping/field/{fields}
method: GET
parameters:
fields: year
response:
status: 200
20 changes: 19 additions & 1 deletion tests/default/_core/mget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ prologues:
- {create: {_index: movies, _id: movie2}}
- {director: Nicolas Winding Refn, title: Drive, year: 1960}
chapters:
- synopsis: Retrieve documents from multiple indexes.
- synopsis: Retrieve documents from multiple indexes (GET).
path: /_mget
method: GET
request:
Expand All @@ -45,3 +45,21 @@ chapters:
_id: movie1
- _index: books
_id: book1
- synopsis: Retrieve documents from multiple indexes (POST).
path: /_mget
method: POST
request:
payload:
docs:
- _index: books
_id: book1
- _index: movies
_id: movie1
response:
status: 200
payload:
docs:
- _index: books
_id: book1
- _index: movies
_id: movie1
10 changes: 5 additions & 5 deletions tests/default/flow_framework/deprovision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Test flow_framework provision endpoints.
version: '>= 2.12'
prologues:
- path: /_plugins/_flow_framework/workflow
id: create_flow_framework
id: workflow
method: POST
parameters:
use_case: semantic_search_with_cohere_embedding_query_enricher
Expand All @@ -12,24 +12,24 @@ prologues:
payload:
create_connector.credential.key: test_api_key
output:
test_workflow_id: payload.workflow_id
workflow_id: payload.workflow_id
epilogues:
- path: /_plugins/_flow_framework/workflow/{workflow_id}/_deprovision
method: POST
status: [200, 404]
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
- path: /_plugins/_flow_framework/workflow/{workflow_id}
method: DELETE
status: [200, 404]
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
chapters:
- synopsis: Deprovision workflow.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_deprovision
method: POST
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
response:
status: 200
- synopsis: Deprovision workflow using an invalid ID.
Expand Down
10 changes: 5 additions & 5 deletions tests/default/flow_framework/provision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ description: Test flow_framework provision endpoints.
version: '>= 2.12'
prologues:
- path: /_plugins/_flow_framework/workflow
id: create_flow_framework
id: workflow
method: POST
parameters:
use_case: semantic_search_with_cohere_embedding_query_enricher
request:
payload:
create_connector.credential.key: test_api_key
output:
test_workflow_id: payload.workflow_id
workflow_id: payload.workflow_id
epilogues:
- path: /_plugins/_flow_framework/workflow/{workflow_id}/_deprovision
method: POST
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
- path: /_plugins/_flow_framework/workflow/{workflow_id}
method: DELETE
status: [200, 404]
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
chapters:
- synopsis: Provision workflow.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_provision
method: POST
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
request:
payload:
openai_key: '1234556'
Expand Down
6 changes: 3 additions & 3 deletions tests/default/flow_framework/search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ description: Test flow_framework provision endpoints.
version: '>= 2.12'
prologues:
- path: /_plugins/_flow_framework/workflow
id: create_flow_framework
id: workflow
method: POST
parameters:
use_case: semantic_search_with_cohere_embedding_query_enricher
request:
payload:
create_connector.credential.key: test_api_key
output:
test_workflow_id: payload.workflow_id
workflow_id: payload.workflow_id
epilogues:
- path: /_plugins/_flow_framework/workflow/{workflow_id}
method: DELETE
status: [200, 404]
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
chapters:
- synopsis: Search workflow match the name.
path: /_plugins/_flow_framework/workflow/_search
Expand Down
6 changes: 3 additions & 3 deletions tests/default/flow_framework/search_state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ description: Test flow_framework provision endpoints.
version: '>= 2.12'
prologues:
- path: /_plugins/_flow_framework/workflow
id: create_flow_framework
id: workflow
method: POST
parameters:
use_case: semantic_search_with_cohere_embedding_query_enricher
request:
payload:
create_connector.credential.key: test_api_key
output:
test_workflow_id: payload.workflow_id
workflow_id: payload.workflow_id
epilogues:
- path: /_plugins/_flow_framework/workflow/{workflow_id}
method: DELETE
status: [200, 404]
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
chapters:
- synopsis: Search workflow state.
path: /_plugins/_flow_framework/workflow/state/_search
Expand Down
8 changes: 4 additions & 4 deletions tests/default/flow_framework/status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ description: Test flow_framework provision endpoints.
version: '>= 2.12'
prologues:
- path: /_plugins/_flow_framework/workflow
id: create_flow_framework
id: workflow
method: POST
parameters:
use_case: semantic_search_with_cohere_embedding_query_enricher
request:
payload:
create_connector.credential.key: test_api_key
output:
test_workflow_id: payload.workflow_id
workflow_id: payload.workflow_id
epilogues:
- path: /_plugins/_flow_framework/workflow/{workflow_id}
method: DELETE
status: [200, 404]
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
chapters:
- synopsis: Get workflow status.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_status
method: GET
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
response:
status: 200
payload:
Expand Down
8 changes: 4 additions & 4 deletions tests/default/flow_framework/steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ description: Test flow_framework provision endpoints.
version: '>= 2.12'
prologues:
- path: /_plugins/_flow_framework/workflow
id: create_flow_framework
id: workflow
method: POST
parameters:
use_case: semantic_search_with_cohere_embedding_query_enricher
request:
payload:
create_connector.credential.key: test_api_key
output:
test_workflow_id: payload.workflow_id
workflow_id: payload.workflow_id
epilogues:
- path: /_plugins/_flow_framework/workflow/{workflow_id}
method: DELETE
status: [200, 404]
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
workflow_id: ${workflow.workflow_id}
chapters:
- synopsis: Get workflow steps.
path: /_plugins/_flow_framework/workflow/_steps
method: GET
response:
status: 200
- synopsis: Get workflow steps with invalid query parameter.
- synopsis: Get workflow steps with an invalid query parameter.
path: /_plugins/_flow_framework/workflow/_steps
method: GET
parameters:
Expand Down
Loading

0 comments on commit c888a16

Please sign in to comment.