Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganized tests and added tests for _doc. #331

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed

- Fixed GitHub pages ([#215](https://github.com/opensearch-project/opensearch-api-specification/pull/215))
- Fixed missing 201 response in `/{index}/_doc/{id}` ([#331](https://github.com/opensearch-project/opensearch-api-specification/pull/331))

### Security

Expand Down
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ To assure the correctness of the spec, you must add tests for the spec in the [t
- chapters: These are the operations that are being tested.
- epilogues: These are the operations that are executed after the test story is run. They are used to clean up the environment after the test story.

Below is the simplified version of the test story that tests the [index operations](tests/index.yaml):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the operations tested in the index lifecycle story is actually part of the indices namespace. I think we should put it in tests/indices/lifecycle.yaml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to organize tests in namespaces, updated and added to DEVELOPER_GUIDE.

Below is the simplified version of the test story that tests the [index operations](tests/_core/index.yaml):
```yaml
$schema: ../json_schemas/test_story.schema.yaml # The schema of the test story. Include this line so that your editor can validate the test story on the fly.

Expand Down
12 changes: 12 additions & 0 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,8 @@ paths:
requestBody:
$ref: '#/components/requestBodies/index'
responses:
'201':
$ref: '#/components/responses/index@201'
'200':
$ref: '#/components/responses/index@200'
/{index}/_doc/{id}:
Expand Down Expand Up @@ -1291,6 +1293,8 @@ paths:
requestBody:
$ref: '#/components/requestBodies/index'
responses:
'201':
$ref: '#/components/responses/index@201'
'200':
$ref: '#/components/responses/index@200'
put:
Expand All @@ -1317,6 +1321,8 @@ paths:
requestBody:
$ref: '#/components/requestBodies/index'
responses:
'201':
$ref: '#/components/responses/index@201'
'200':
$ref: '#/components/responses/index@200'
delete:
Expand Down Expand Up @@ -2875,6 +2881,12 @@ components:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
index@201:
description: ''
content:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
info@200:
description: ''
content:
Expand Down
2 changes: 1 addition & 1 deletion tests/index.yaml → tests/_core/index.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$schema: ../json_schemas/test_story.schema.yaml
$schema: ../../json_schemas/test_story.schema.yaml

skip: false
description: Test endpoints relevant the lifecycle of an index, from creation to deletion.
Expand Down
60 changes: 60 additions & 0 deletions tests/_core/index/_doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
$schema: ../../../json_schemas/test_story.schema.yaml

skip: false
description: Test inserting and retrieving a doc.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Create a document.
path: /{index}/_doc
method: POST
parameters:
index: movies
request_body:
payload:
title: Beauty and the Beast
year: 1991
response:
status: 201
- synopsis: Create a document.
path: /{index}/_doc/{id}
method: POST
parameters:
index: movies
id: '1'
request_body:
payload:
title: Beauty and the Beast (Id)
year: 1991
response:
status: 201
- synopsis: Update a document.
path: /{index}/_doc/{id}
method: PUT
parameters:
index: movies
id: '1'
request_body:
payload:
title: Beauty and the Beast (Updated)
year: 1991
response:
status: 200
- synopsis: Retrieve a document.
path: /{index}/_doc/{id}
method: GET
parameters:
index: movies
id: '1'
response:
status: 200
- synopsis: Delete a document.
path: /{index}/_doc/{id}
method: DELETE
parameters:
index: movies
id: '1'
response:
status: 200
2 changes: 1 addition & 1 deletion tests/info.yaml → tests/_core/info.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

$schema: ../json_schemas/test_story.schema.yaml
$schema: ../../json_schemas/test_story.schema.yaml

skip: false
description: Test root endpoint.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
$schema: ../json_schemas/test_story.schema.yaml
$schema: ../../../../json_schemas/test_story.schema.yaml

skip: false
description: |
This test story checks that we can create an ingest pipeline with a text
embedding processor
Test the creation of an ingest pipeline with a text embedding processor.
epilogues:
- path: /_ingest/pipeline/books_pipeline
method: DELETE
status: [200, 404]
chapters:
- synopsis: Create ingest pipeline for text embedding
- synopsis: Create ingest pipeline for text embedding.
path: /_ingest/pipeline/{id}
method: PUT
parameters:
id: books_pipeline
request_body:
payload:
description: "Extracts text from field and embeds it"
description: Extracts text from field and embeds it.
processors:
- text_embedding:
model_id: "text-embedding-model"
model_id: text-embedding-model
field_map:
text: "passage_embedding"
text: passage_embedding
response:
status: 200
payload:
acknowledged: true
- synopsis: Query created pipeline
- synopsis: Query created pipeline.
path: /_ingest/pipeline/{id}
method: GET
parameters:
Expand Down
Loading