diff --git a/CHANGELOG.md b/CHANGELOG.md index d32021d4..d2441b2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `cluster_manager` to `ClusterNodeCount` ([#534](https://github.com/opensearch-project/opensearch-api-specification/pull/534)) - Added support for `query` with `terms` in `_search` ([#546](https://github.com/opensearch-project/opensearch-api-specification/pull/546)) - Added `h`, `bytes`, `time` parameters to cat API tests ([#551](https://github.com/opensearch-project/opensearch-api-specification/pull/551)) +- Added `terminated_early` to `count@200` ([#547](https://github.com/opensearch-project/opensearch-api-specification/pull/547)) - Added request and response schemas for `/_cluster/routing/awareness/{attribute}/weights` ([#524](https://github.com/opensearch-project/opensearch-api-specification/pull/524)) - Added request and response schemas for `/_cluster/decommission/awareness` ([#524](https://github.com/opensearch-project/opensearch-api-specification/pull/524)) diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index f26fb4de..e4eae5c8 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -2673,6 +2673,8 @@ components: schema: type: object properties: + terminated_early: + type: boolean count: type: number _shards: diff --git a/tests/default/_core/count.yaml b/tests/default/_core/count.yaml new file mode 100644 index 00000000..8a802f64 --- /dev/null +++ b/tests/default/_core/count.yaml @@ -0,0 +1,14 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _count endpoint. +chapters: + - synopsis: Count the number of documents in the cluster (GET). + path: /_count + method: GET + response: + status: 200 + - synopsis: Count the number of documents in the cluster (POST). + path: /_count + method: POST + response: + status: 200 diff --git a/tests/default/indices/dangling.yaml b/tests/default/_core/dangling.yaml similarity index 100% rename from tests/default/indices/dangling.yaml rename to tests/default/_core/dangling.yaml diff --git a/tests/default/cluster/state.yaml b/tests/default/cluster/state.yaml new file mode 100644 index 00000000..56d5de91 --- /dev/null +++ b/tests/default/cluster/state.yaml @@ -0,0 +1,31 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test cluster state. +chapters: + - synopsis: Returns an internal representation of the cluster state. + path: /_cluster/state + method: GET + response: + status: 200 + - synopsis: Returns the cluster state version. + path: /_cluster/state/{metric} + method: GET + parameters: + metric: + - version + response: + status: 200 + payload: + cluster_name: docker-cluster + - synopsis: Returns the cluster state version for a given index. + path: /_cluster/state/{metric}/{index} + method: GET + parameters: + metric: + - metadata + index: + - _all + response: + status: 200 + payload: + metadata: {} diff --git a/tests/default/indices/count.yaml b/tests/default/indices/count.yaml new file mode 100644 index 00000000..a5730fdc --- /dev/null +++ b/tests/default/indices/count.yaml @@ -0,0 +1,56 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _count endpoint. +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request: + payload: {} + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book_1392214}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} +epilogues: + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Count the number of documents in an index. + path: /{index}/_count + method: GET + parameters: + index: books + response: + status: 200 + payload: + count: 2 + - synopsis: Count the number of documents in an index that match a query. + path: /{index}/_count + method: POST + parameters: + index: books + allow_no_indices: true + expand_wildcards: closed + ignore_unavailable: true + min_score: 0 + routing: zone + preference: none + terminate_after: 1 + request: + payload: + query: + term: + year: 1960 + response: + status: 200 + payload: + count: 1 diff --git a/tests/default/indices/data_stream/stats.yaml b/tests/default/indices/data_stream/stats.yaml index b8cbcd0b..d033fefd 100644 --- a/tests/default/indices/data_stream/stats.yaml +++ b/tests/default/indices/data_stream/stats.yaml @@ -1,6 +1,6 @@ $schema: ../../../../json_schemas/test_story.schema.yaml -description: Test data streams. +description: Test data stream stats. prologues: - path: /_index_template/logs-template-nginx method: PUT @@ -29,7 +29,10 @@ epilogues: method: DELETE status: [200, 404] chapters: - - synopsis: Get data stream stats. + - synopsis: Get all data stream stats. + path: /_data_stream/_stats + method: GET + - synopsis: Get data stream stats for an index. path: /_data_stream/{name}/_stats method: GET parameters: diff --git a/tests/default/indices/delete_by_query.yaml b/tests/default/indices/delete_by_query.yaml new file mode 100644 index 00000000..b6c9c0a9 --- /dev/null +++ b/tests/default/indices/delete_by_query.yaml @@ -0,0 +1,55 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test deleting documents that match a query. +epilogues: + - path: /books + method: DELETE + status: [200, 404] +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book_1392214}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 60} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 91} +chapters: + - synopsis: Delete documents in the index (full query term, script). + path: /{index}/_delete_by_query + method: POST + parameters: + index: books + request: + payload: + query: + term: + title: + _name: title + value: beauty + case_insensitive: true + boost: 1 + response: + status: 200 + payload: + total: 1 + deleted: 1 + - synopsis: Delete remaining documents in the index. + path: /{index}/_delete_by_query + method: POST + parameters: + index: books + refresh: true + conflicts: proceed + request: + payload: + query: + match_all: {} + response: + status: 200 + payload: + total: 2 + deleted: 1 \ No newline at end of file diff --git a/tests/default/indices/update_by_query.yaml b/tests/default/indices/update_by_query.yaml index 0ce1295d..bb3194ff 100644 --- a/tests/default/indices/update_by_query.yaml +++ b/tests/default/indices/update_by_query.yaml @@ -1,6 +1,6 @@ $schema: ../../../json_schemas/test_story.schema.yaml -description: Test reindex. +description: Test updating documents that match a query. epilogues: - path: /books method: DELETE