From 54578cce6c4fb44d790febbe5c61f8e9ca87416d Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 21 Aug 2024 19:42:11 -0400 Subject: [PATCH] Add missing /cat API tests. Signed-off-by: dblock --- tests/default/cat/aliases.yaml | 4 +-- tests/default/cat/allocation.yaml | 12 ++++++++- tests/default/cat/cluster_manager.yaml | 2 +- tests/default/cat/count.yaml | 27 ++++++++++++++++++- tests/default/cat/fielddata.yaml | 15 +++++++++-- tests/default/cat/health.yaml | 22 +++++++-------- tests/default/cat/index.yaml | 2 +- tests/default/cat/indices.yaml | 26 +++++++++++------- tests/default/cat/master.yaml | 2 +- tests/default/cat/nodeattrs.yaml | 2 +- tests/default/cat/nodes.yaml | 4 +-- tests/default/cat/pending_tasks.yaml | 2 +- tests/default/cat/pit_segments/all.yaml | 2 +- .../cat/pit_segments/pit_segments.yaml | 2 +- tests/default/cat/plugins.yaml | 2 +- tests/default/cat/recovery.yaml | 24 ++++++++++++++++- tests/default/cat/repositories.yaml | 12 +++++++++ tests/default/cat/segment_replication.yaml | 20 +++++++++++++- tests/default/cat/segments.yaml | 21 ++++++++++++++- tests/default/cat/shards.yaml | 10 ++++--- tests/default/cat/tasks.yaml | 7 ++++- tests/default/cat/templates.yaml | 5 ++-- tests/default/cat/thread_pool.yaml | 5 ++-- tests/snapshot/cat/repositories.yaml | 2 +- tests/snapshot/cat/snapshots.yaml | 2 +- 25 files changed, 185 insertions(+), 49 deletions(-) create mode 100644 tests/default/cat/repositories.yaml diff --git a/tests/default/cat/aliases.yaml b/tests/default/cat/aliases.yaml index 30f9cebf9..2fb2101d7 100644 --- a/tests/default/cat/aliases.yaml +++ b/tests/default/cat/aliases.yaml @@ -16,13 +16,13 @@ prologues: index: games name: jeux chapters: - - synopsis: Cat with a text response. + - synopsis: List the mapping of aliases to indexes, plus routing and filtering information in plain text. path: /_cat/aliases method: GET response: status: 200 content_type: text/plain - - synopsis: Cat with a json response. + - synopsis: List the mapping of aliases to indexes, plus routing and filtering information in json. path: /_cat/aliases/{name} parameters: format: json diff --git a/tests/default/cat/allocation.yaml b/tests/default/cat/allocation.yaml index 60d603d3b..9d3d854c0 100644 --- a/tests/default/cat/allocation.yaml +++ b/tests/default/cat/allocation.yaml @@ -2,10 +2,20 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/allocation endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List the allocation of disk space for indexes and the number of shards on each node. path: /_cat/allocation method: GET parameters: format: json response: status: 200 + - synopsis: List the allocation of disk space for indexes and the number of shards on a data node. + path: /_cat/allocation/{node_id} + method: GET + parameters: + node_id: data:true + format: json + bytes: kb + local: true + response: + status: 200 diff --git a/tests/default/cat/cluster_manager.yaml b/tests/default/cat/cluster_manager.yaml index e984f2440..d35e9361e 100644 --- a/tests/default/cat/cluster_manager.yaml +++ b/tests/default/cat/cluster_manager.yaml @@ -2,7 +2,7 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/cluster_manager endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List information that helps identify the elected cluster manager node. version: '>= 2.0' path: /_cat/cluster_manager method: GET diff --git a/tests/default/cat/count.yaml b/tests/default/cat/count.yaml index 31e71c580..37078848d 100644 --- a/tests/default/cat/count.yaml +++ b/tests/default/cat/count.yaml @@ -1,11 +1,36 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/count endpoints. +prologues: + - path: /movies/_doc + method: POST + parameters: + refresh: true + request: + payload: + director: Bennett Miller + title: Moneyball + year: 2011 + status: [201] +epilogues: + - path: /movies + method: DELETE + status: [200, 404] chapters: - - synopsis: Cat with a json response. + - synopsis: List the number of documents in the cluster. path: /_cat/count method: GET parameters: format: json response: status: 200 + - synopsis: List the number of documents in an index. + path: /_cat/count/{index} + method: GET + parameters: + index: movies + format: json + response: + status: 200 + payload: + - count: '1' diff --git a/tests/default/cat/fielddata.yaml b/tests/default/cat/fielddata.yaml index ca8a11cb5..4afb57de0 100644 --- a/tests/default/cat/fielddata.yaml +++ b/tests/default/cat/fielddata.yaml @@ -2,14 +2,14 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/fielddata endpoints. chapters: - - synopsis: Cat with an empty response. + - synopsis: List the memory size used by each field per node. path: /_cat/fielddata method: GET parameters: format: json response: status: 200 - - synopsis: Cat with a json response (from security-analytics). + - synopsis: List the memory size used by each field per node with data from security-analytics. version: '>= 2.4' path: /_cat/fielddata method: GET @@ -19,3 +19,14 @@ chapters: status: 200 payload: - field: log_types + - synopsis: List the memory size used by each field per node with data from security-analytics. + version: '>= 2.4' + path: /_cat/fielddata/{fields} + method: GET + parameters: + format: json + fields: log_types + response: + status: 200 + payload: + - field: log_types diff --git a/tests/default/cat/health.yaml b/tests/default/cat/health.yaml index dff956b3e..9e9d1df43 100644 --- a/tests/default/cat/health.yaml +++ b/tests/default/cat/health.yaml @@ -2,13 +2,13 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/health endpoints. chapters: - - synopsis: Cat with a default text response. + - synopsis: List the status of the cluster in plain text. method: GET path: /_cat/health response: status: 200 content_type: text/plain - - synopsis: Cat with verbose output (v=true). + - synopsis: List the status of the cluster with verbose output (v=true). method: GET path: /_cat/health parameters: @@ -16,7 +16,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat with headers (h=header1,header2). + - synopsis: List the status of the cluster with headers (h=header1,header2). method: GET path: /_cat/health parameters: @@ -26,7 +26,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat displaying all available headers (help=true). + - synopsis: List the status of the cluster displaying all available headers (help=true). method: GET path: /_cat/health parameters: @@ -34,7 +34,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat with sorted results. + - synopsis: List the status of the cluster with sorted results. method: GET path: /_cat/health parameters: @@ -43,7 +43,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat in different formats (format=json). + - synopsis: List the status of the cluster in different formats (format=json). method: GET path: /_cat/health parameters: @@ -54,7 +54,7 @@ chapters: payload: - node.total: '1' node.data: '1' - - synopsis: Cat with master response (format=json). + - synopsis: List the status of the cluster with master response (format=json). method: GET path: /_cat/health version: < 2.0 @@ -67,7 +67,7 @@ chapters: - node.total: '1' node.data: '1' discovered_master: 'true' - - synopsis: Cat with cluster_manager response (format=json). + - synopsis: List the status of the cluster with cluster_manager response (format=json). method: GET path: /_cat/health version: '>= 2.0' @@ -80,7 +80,7 @@ chapters: - node.total: '1' node.data: '1' discovered_cluster_manager: 'true' - - synopsis: Cat in different formats (format=yaml). + - synopsis: List the status of the cluster in different formats (format=yaml). method: GET path: /_cat/health parameters: @@ -91,7 +91,7 @@ chapters: payload: - node.total: '1' node.data: '1' - - synopsis: Cat in different formats (format=cbor). + - synopsis: List the status of the cluster in different formats (format=cbor). distributions: excluded: - amazon-managed @@ -106,7 +106,7 @@ chapters: payload: - node.total: '1' node.data: '1' - - synopsis: Cat in different formats (format=smile). + - synopsis: List the status of the cluster in different formats (format=smile). distributions: excluded: - amazon-managed diff --git a/tests/default/cat/index.yaml b/tests/default/cat/index.yaml index ae20cdf3a..a40632a60 100644 --- a/tests/default/cat/index.yaml +++ b/tests/default/cat/index.yaml @@ -2,7 +2,7 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List available compact and aligned text (CAT) APIs in plain text. path: /_cat method: GET response: diff --git a/tests/default/cat/indices.yaml b/tests/default/cat/indices.yaml index 2e2ed1711..2c9e40238 100644 --- a/tests/default/cat/indices.yaml +++ b/tests/default/cat/indices.yaml @@ -13,13 +13,21 @@ epilogues: method: DELETE status: [200, 404] chapters: - - synopsis: Cat with a default text response. + - synopsis: List information related to indexes (text/plain). method: GET path: /_cat/indices response: status: 200 content_type: text/plain - - synopsis: Cat with verbose output (v=true). + - synopsis: List information related to one index (text/plain). + method: GET + path: /_cat/indices/{index} + parameters: + index: books + response: + status: 200 + content_type: text/plain + - synopsis: List information related to indexes with verbose output (v=true). method: GET path: /_cat/indices parameters: @@ -27,7 +35,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat with headers (h=header1,header2). + - synopsis: List information related to indexes with headers (h=header1,header2). method: GET path: /_cat/indices parameters: @@ -37,7 +45,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat displaying all available headers (help=true). + - synopsis: List information related to indexes displaying all available headers (help=true). method: GET path: /_cat/indices parameters: @@ -45,7 +53,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat with sorted results. + - synopsis: List information related to indexes with sorted results. method: GET path: /_cat/indices parameters: @@ -54,7 +62,7 @@ chapters: response: status: 200 content_type: text/plain - - synopsis: Cat in different formats (format=json). + - synopsis: List information related to indexes in different formats (format=json). method: GET path: /_cat/indices parameters: @@ -62,7 +70,7 @@ chapters: response: status: 200 content_type: application/json - - synopsis: Cat in different formats (format=yaml). + - synopsis: List information related to indexes in different formats (format=yaml). method: GET path: /_cat/indices parameters: @@ -70,7 +78,7 @@ chapters: response: status: 200 content_type: application/yaml - - synopsis: Cat in different formats (format=cbor). + - synopsis: List information related to indexes in different formats (format=cbor). distributions: excluded: - amazon-managed @@ -82,7 +90,7 @@ chapters: response: status: 200 content_type: application/cbor - - synopsis: Cat in different formats (format=smile). + - synopsis: List information related to indexes in different formats (format=smile). distributions: excluded: - amazon-managed diff --git a/tests/default/cat/master.yaml b/tests/default/cat/master.yaml index 93ab62942..ea193902d 100644 --- a/tests/default/cat/master.yaml +++ b/tests/default/cat/master.yaml @@ -3,7 +3,7 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/master endpoints. version: < 2.0 chapters: - - synopsis: Cat with a json response. + - synopsis: List information that helps identify the elected master node. path: /_cat/master method: GET parameters: diff --git a/tests/default/cat/nodeattrs.yaml b/tests/default/cat/nodeattrs.yaml index f59162b31..1d94a35ca 100644 --- a/tests/default/cat/nodeattrs.yaml +++ b/tests/default/cat/nodeattrs.yaml @@ -6,7 +6,7 @@ distributions: - amazon-managed - amazon-serverless chapters: - - synopsis: Cat with a json response. + - synopsis: List the attributes of custom nodes. path: /_cat/nodeattrs method: GET parameters: diff --git a/tests/default/cat/nodes.yaml b/tests/default/cat/nodes.yaml index 158354e23..5e38cbdaa 100644 --- a/tests/default/cat/nodes.yaml +++ b/tests/default/cat/nodes.yaml @@ -2,7 +2,7 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/nodes endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List node-level information. path: /_cat/nodes method: GET version: < 2.0 @@ -12,7 +12,7 @@ chapters: status: 200 payload: - master: '*' - - synopsis: Cat with a json response. + - synopsis: List node-level information. path: /_cat/nodes version: '>= 2.0' method: GET diff --git a/tests/default/cat/pending_tasks.yaml b/tests/default/cat/pending_tasks.yaml index c007487ad..811fcbd00 100644 --- a/tests/default/cat/pending_tasks.yaml +++ b/tests/default/cat/pending_tasks.yaml @@ -2,7 +2,7 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/pending_tasks endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List the progress of all pending tasks. path: /_cat/pending_tasks method: GET parameters: diff --git a/tests/default/cat/pit_segments/all.yaml b/tests/default/cat/pit_segments/all.yaml index 5e6d77632..6bbbdcaae 100644 --- a/tests/default/cat/pit_segments/all.yaml +++ b/tests/default/cat/pit_segments/all.yaml @@ -25,7 +25,7 @@ prologues: output: pit_id: payload.pit_id chapters: - - synopsis: Cat _all with a json response. + - synopsis: List information about the disk utilization of all PITs by describing their Lucene segments. path: /_cat/pit_segments/_all method: GET parameters: diff --git a/tests/default/cat/pit_segments/pit_segments.yaml b/tests/default/cat/pit_segments/pit_segments.yaml index d933ba55b..84b9cafd8 100644 --- a/tests/default/cat/pit_segments/pit_segments.yaml +++ b/tests/default/cat/pit_segments/pit_segments.yaml @@ -25,7 +25,7 @@ prologues: output: pit_id: payload.pit_id chapters: - - synopsis: Cat pit_segments/pit_id with a json response. + - synopsis: List information about the disk utilization of a PIT by describing its Lucene segments. path: /_cat/pit_segments method: GET parameters: diff --git a/tests/default/cat/plugins.yaml b/tests/default/cat/plugins.yaml index a2fb2b42f..a0b6d6b71 100644 --- a/tests/default/cat/plugins.yaml +++ b/tests/default/cat/plugins.yaml @@ -2,7 +2,7 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/plugins endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List the names, components, and versions of the installed plugins. path: /_cat/plugins method: GET parameters: diff --git a/tests/default/cat/recovery.yaml b/tests/default/cat/recovery.yaml index a1341f219..1731e42b4 100644 --- a/tests/default/cat/recovery.yaml +++ b/tests/default/cat/recovery.yaml @@ -1,11 +1,33 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/recovery endpoints. +prologues: + - path: /{index} + method: PUT + parameters: + index: books +epilogues: + - path: /books + method: DELETE + status: [200, 404] chapters: - - synopsis: Cat with a json response. + - synopsis: List all completed and ongoing index and shard recoveries. path: /_cat/recovery method: GET parameters: format: json response: status: 200 + - synopsis: List all completed and ongoing index and shard recoveries for a given index. + path: /_cat/recovery/{index} + method: GET + parameters: + format: json + index: + - books + active_only: true + bytes: kb + detailed: true + time: m + response: + status: 200 diff --git a/tests/default/cat/repositories.yaml b/tests/default/cat/repositories.yaml new file mode 100644 index 000000000..bf113f552 --- /dev/null +++ b/tests/default/cat/repositories.yaml @@ -0,0 +1,12 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test cat/repositories endpoints. +chapters: + - synopsis: List all snapshot repositories for a cluster. + path: /_cat/repositories + method: GET + parameters: + format: json + local: true + response: + status: 200 diff --git a/tests/default/cat/segment_replication.yaml b/tests/default/cat/segment_replication.yaml index 0495ece5f..9d8d5002a 100644 --- a/tests/default/cat/segment_replication.yaml +++ b/tests/default/cat/segment_replication.yaml @@ -2,11 +2,29 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/segment_replication endpoints. version: '>= 2.7' +prologues: + - path: /{index} + method: PUT + parameters: + index: books +epilogues: + - path: /books + method: DELETE + status: [200, 404] chapters: - - synopsis: Cat with a json response. + - synopsis: List information about active and last completed segment replication events on each replica shard. path: /_cat/segment_replication method: GET parameters: format: json response: status: 200 + - synopsis: List information about active and last completed segment replication events on each replica shard for an index. + path: /_cat/segment_replication/{index} + method: GET + parameters: + format: json + index: + - books + response: + status: 200 diff --git a/tests/default/cat/segments.yaml b/tests/default/cat/segments.yaml index b8cbb8f56..ecae37d0f 100644 --- a/tests/default/cat/segments.yaml +++ b/tests/default/cat/segments.yaml @@ -1,11 +1,30 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/segments endpoints. +prologues: + - path: /{index} + method: PUT + parameters: + index: books +epilogues: + - path: /books + method: DELETE + status: [200, 404] chapters: - - synopsis: Cat with a json response. + - synopsis: List Lucene segment-level information for all indices. path: /_cat/segments method: GET parameters: format: json response: status: 200 + - synopsis: List Lucene segment-level information for an index. + path: /_cat/segments/{index} + method: GET + parameters: + format: json + bytes: kb + index: + - books + response: + status: 200 diff --git a/tests/default/cat/shards.yaml b/tests/default/cat/shards.yaml index f2ab5c147..033f55ff8 100644 --- a/tests/default/cat/shards.yaml +++ b/tests/default/cat/shards.yaml @@ -11,17 +11,21 @@ prologues: parameters: index: games chapters: - - synopsis: Cat all with a json response. + - synopsis: List the state of all primary and replica shards and how they are distributed. path: /_cat/shards method: GET parameters: format: json - - synopsis: Cat index shards with a json response. + - synopsis: List the state of all primary and replica shards and how they are distributed for an index. path: /_cat/shards/{index} method: GET parameters: format: json - index: games + index: + - games + bytes: kb + local: true + time: s response: status: 200 payload: diff --git a/tests/default/cat/tasks.yaml b/tests/default/cat/tasks.yaml index aedcaab42..683652769 100644 --- a/tests/default/cat/tasks.yaml +++ b/tests/default/cat/tasks.yaml @@ -2,10 +2,15 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/tasks endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List the progress of all tasks currently running on your cluster. path: /_cat/tasks method: GET parameters: format: json + nodes: + - local + detailed: true + parent_task_id: node_id:-1 + time: s response: status: 200 diff --git a/tests/default/cat/templates.yaml b/tests/default/cat/templates.yaml index 330b6c12c..4c6b2e51e 100644 --- a/tests/default/cat/templates.yaml +++ b/tests/default/cat/templates.yaml @@ -18,19 +18,20 @@ prologues: number_of_shards: 2 number_of_replicas: 2 chapters: - - synopsis: Cat with a json response. + - synopsis: List the names, patterns, order numbers, and version numbers of index templates. path: /_cat/templates method: GET parameters: format: json response: status: 200 - - synopsis: Cat a specific template with a json response. + - synopsis: List the names, patterns, order numbers, and version numbers of index templates. path: /_cat/templates/{name} method: GET parameters: format: json name: daily_logs + local: true response: status: 200 payload: diff --git a/tests/default/cat/thread_pool.yaml b/tests/default/cat/thread_pool.yaml index b38cd8772..59a211ebf 100644 --- a/tests/default/cat/thread_pool.yaml +++ b/tests/default/cat/thread_pool.yaml @@ -2,19 +2,20 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test cat/thread_pool endpoints. chapters: - - synopsis: Cat with a json response. + - synopsis: List the active, queued, and rejected threads of different thread pools on each node. path: /_cat/thread_pool method: GET parameters: format: json response: status: 200 - - synopsis: Cat of a specific thread pool with a json response. + - synopsis: List the active, queued, and rejected threads of different thread pools on each node. path: /_cat/thread_pool/{thread_pool_patterns} method: GET parameters: format: json thread_pool_patterns: generic + local: true response: status: 200 payload: diff --git a/tests/snapshot/cat/repositories.yaml b/tests/snapshot/cat/repositories.yaml index 89d258e23..3124a0172 100644 --- a/tests/snapshot/cat/repositories.yaml +++ b/tests/snapshot/cat/repositories.yaml @@ -18,7 +18,7 @@ prologues: settings: location: /tmp/opensearch/repo chapters: - - synopsis: Cat with a json response. + - synopsis: List all snapshot repositories for a cluster. path: /_cat/repositories method: GET parameters: diff --git a/tests/snapshot/cat/snapshots.yaml b/tests/snapshot/cat/snapshots.yaml index 1e35ea574..81a51bfc2 100644 --- a/tests/snapshot/cat/snapshots.yaml +++ b/tests/snapshot/cat/snapshots.yaml @@ -14,7 +14,7 @@ prologues: settings: location: /tmp/opensearch/repo chapters: - - synopsis: Cat with a json response. + - synopsis: List all snapshots for a repository. path: /_cat/snapshots/{repository} method: GET parameters: