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

Added _cat tests. #373

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .github/opensearch-cluster/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ services:
- "9600:9600"
environment:
- discovery.type=single-node
- "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}"
- "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}"
- "path.repo=/tmp/opensearch/repo"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed `pages_processed` in `/_plugins/_rollup` ([#341](https://github.com/opensearch-project/opensearch-api-specification/pull/341))
- Fixed `_bulk` spec request and response types ([#355](https://github.com/opensearch-project/opensearch-api-specification/pull/355))
- Fixed `text/plain` response in `/_cat` ([#357](https://github.com/opensearch-project/opensearch-api-specification/pull/357))
- Fixed `/_cat/cluster_manager`, `/_cat/allocation`, `/_cat/shards`, and `/_cat/thread_pool` ([#373](https://github.com/opensearch-project/opensearch-api-specification/pull/373))

### Security

Expand Down
10 changes: 9 additions & 1 deletion spec/namespaces/cat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,14 @@ components:
$ref: '../schemas/cat.allocation.yaml#/components/schemas/AllocationRecord'
cat.cluster_manager@200:
description: ''
content:
text/plain:
type: string
application/json:
schema:
type: array
items:
$ref: '../schemas/cat.cluster_manager.yaml#/components/schemas/ClusterManagerRecord'
cat.count@200:
description: ''
content:
Expand Down Expand Up @@ -1768,7 +1776,7 @@ components:
name: full_id
description: If `true`, return the full node ID. If `false`, return the shortened node ID.
schema:
oneOf:
anyOf:
- type: boolean
- type: string
default: false
Expand Down
14 changes: 7 additions & 7 deletions spec/schemas/cat.allocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ components:
description: |-
Disk space used by the node’s shards. Does not include disk space for the translog or unassigned shards.
IMPORTANT: This metric double-counts disk space for hard-linked files, such as those created when shrinking, splitting, or cloning an index.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/ByteSize'
- nullable: true
type: string
Expand All @@ -26,7 +26,7 @@ components:
OpenSearch retrieves this metric from the node’s operating system (OS).
The metric includes disk space for: OpenSearch, including the translog and unassigned shards; the node’s operating system; any other applications or files on the node.
Unlike `disk.indices`, this metric does not double-count disk space for hard-linked files.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/ByteSize'
- nullable: true
type: string
Expand All @@ -35,31 +35,31 @@ components:
Free disk space available to OpenSearch.
OpenSearch retrieves this metric from the node’s operating system.
Disk-based shard allocation uses this metric to assign shards to nodes based on available disk space.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/ByteSize'
- nullable: true
type: string
disk.total:
description: Total disk space for the node, including in-use and available space.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/ByteSize'
- nullable: true
type: string
disk.percent:
description: Total percentage of disk space in use. Calculated as `disk.used / disk.total`.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/Percentage'
- nullable: true
type: string
host:
description: Network host for the node. Set using the `network.host` setting.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/Host'
- nullable: true
type: string
ip:
description: IP address and port for the node.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/Ip'
- nullable: true
type: string
Expand Down
23 changes: 23 additions & 0 deletions spec/schemas/cat.cluster_manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
openapi: 3.1.0
info:
title: Schemas of cat.cluster_manager category
description: Schemas of cat.cluster_manager category
version: 1.0.0
paths: {}
components:
schemas:
ClusterManagerRecord:
type: object
properties:
id:
description: node id
type: string
host:
description: host name
type: string
ip:
description: ip address
type: string
node:
description: node name
type: string
8 changes: 4 additions & 4 deletions spec/schemas/cat.shards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ components:
type: string
docs:
description: The number of documents in the shard.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
store:
description: The disk space used by the shard.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
ip:
description: The IP address of the node.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
Expand All @@ -50,7 +50,7 @@ components:
type: string
node:
description: The name of node.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
Expand Down
2 changes: 1 addition & 1 deletion spec/schemas/cat.templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ components:
type: string
version:
description: The template version.
oneOf:
anyOf:
- $ref: '_common.yaml#/components/schemas/VersionString'
- nullable: true
type: string
Expand Down
8 changes: 4 additions & 4 deletions spec/schemas/cat.thread_pool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ components:
type: string
core:
description: The core number of active threads allowed in a scaling thread pool.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
max:
description: The maximum number of active threads allowed in a scaling thread pool.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
size:
description: The number of active threads allowed in a fixed thread pool.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
keep_alive:
description: The thread keep alive time.
oneOf:
anyOf:
- type: string
- nullable: true
type: string
75 changes: 75 additions & 0 deletions tests/_core/aliases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test aliases endpoints.
epilogues:
- path: /games
method: DELETE
status: [200, 404]
prologues:
- path: /{index}
method: PUT
parameters:
index: games
chapters:
- synopsis: Create an alias.
path: /{index}/_aliases/{name}
method: PUT
parameters:
index: games
name: jeux
- synopsis: Get an alias from index.
method: GET
path: /{index}/_alias/{name}
parameters:
index: games
name: jeux
response:
status: 200
content_type: application/json
payload:
games:
aliases:
jeux: {}
- synopsis: Get an alias from _aliases.
method: GET
path: /_alias/{name}
parameters:
name: jeux
response:
status: 200
content_type: application/json
payload:
games:
aliases:
jeux: {}
- synopsis: Multiple alias operations.
path: /_aliases
method: POST
request_body:
payload:
actions:
- remove:
index: games
alias: jeux
- add:
index: games
alias: plays1
- add:
index: games
alias: plays2
response:
status: 200
payload:
acknowledged: true
- synopsis: Delete an alias from _aliases.
path: /{index}/_aliases/{name}
method: DELETE
parameters:
index: games
name: plays1
- synopsis: Delete an alias from _alias.
path: /{index}/_alias/{name}
method: DELETE
parameters:
index: games
name: plays2
18 changes: 17 additions & 1 deletion tests/cat/aliases.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/aliases endpoints.
epilogues:
- path: /games
method: DELETE
status: [200, 404]
prologues:
- path: /{index}
method: PUT
parameters:
index: games
- path: /{index}/_aliases/{name}
method: PUT
parameters:
index: games
name: jeux
chapters:
- synopsis: Cat with a text response.
path: /_cat/aliases
Expand All @@ -16,4 +30,6 @@ chapters:
response:
status: 200
content_type: application/json
payload: []
payload:
- alias: jeux
index: games
11 changes: 11 additions & 0 deletions tests/cat/allocation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/allocation endpoints.
chapters:
- synopsis: Cat with a json response.
path: /_cat/allocation
method: GET
parameters:
format: json
response:
status: 200
11 changes: 11 additions & 0 deletions tests/cat/cluster_manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/cluster_manager endpoints.
chapters:
- synopsis: Cat with a json response.
path: /_cat/cluster_manager
method: GET
parameters:
format: json
response:
status: 200
11 changes: 11 additions & 0 deletions tests/cat/count.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/count endpoints.
chapters:
- synopsis: Cat with a json response.
path: /_cat/count
method: GET
parameters:
format: json
response:
status: 200
13 changes: 13 additions & 0 deletions tests/cat/fielddata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/fielddata endpoints.
chapters:
- synopsis: Cat with a json response.
path: /_cat/fielddata
method: GET
parameters:
format: json
response:
status: 200
payload:
- field: log_types # from security-analytics
14 changes: 14 additions & 0 deletions tests/cat/nodeattrs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/nodeattrs endpoints.
chapters:
- synopsis: Cat with a json response.
path: /_cat/nodeattrs
method: GET
parameters:
format: json
response:
status: 200
payload:
- attr: shard_indexing_pressure_enabled
value: 'true'
13 changes: 13 additions & 0 deletions tests/cat/nodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/nodes endpoints.
chapters:
- synopsis: Cat with a json response.
path: /_cat/nodes
method: GET
parameters:
format: json
response:
status: 200
payload:
- cluster_manager: '*'
11 changes: 11 additions & 0 deletions tests/cat/pending_tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/pending_tasks endpoints.
chapters:
- synopsis: Cat with a json response.
path: /_cat/pending_tasks
method: GET
parameters:
format: json
response:
status: 200
Loading
Loading