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 index tests and fixed /index/_dangling. #391

Merged
merged 12 commits into from
Jul 10, 2024
2 changes: 1 addition & 1 deletion .github/workflows/test-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
test-opensearch-spec:
runs-on: ubuntu-latest
env:
OPENSEARCH_VERSION: 2.12.0
OPENSEARCH_VERSION: 2.15.0
OPENSEARCH_PASSWORD: myStrongPassword123!
steps:
- name: Checkout Repo
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed optional field in `/_nodes` ([#365](https://github.com/opensearch-project/opensearch-api-specification/pull/365))
- Fixed `/{index}/_open` can return a `task` ([#376](https://github.com/opensearch-project/opensearch-api-specification/pull/376))
- Fixed `_source` in `bulk` responses ([#375](https://github.com/opensearch-project/opensearch-api-specification/pull/375))
- Fixed `/{index}/_dangling` that can return `nodes` and `cluster_name` ([#391](https://github.com/opensearch-project/opensearch-api-specification/pull/391))

### Security

Expand Down
4 changes: 4 additions & 0 deletions spec/namespaces/dangling_indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ components:
schema:
type: object
properties:
_nodes:
$ref: '../schemas/_common.yaml#/components/schemas/NodeStatistics'
cluster_name:
$ref: '../schemas/_common.yaml#/components/schemas/Name'
dangling_indices:
type: array
items:
Expand Down
File renamed without changes.
39 changes: 39 additions & 0 deletions tests/indices/clone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cloning an index.
prologues:
- path: /movies
method: PUT
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
- path: /games
method: DELETE
status: [200, 404]
chapters:
- synopsis: Block writes to the source index.
path: /{index}/_settings
method: PUT
parameters:
index: movies
request_body:
payload:
settings:
index.blocks.write: true
- synopsis: Clone an index.
path: /{index}/_clone/{target}
method: POST
parameters:
index: movies
target: games
wait_for_active_shards: 1
cluster_manager_timeout: 10s
timeout: 10s
wait_for_completion: true
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
index: games
7 changes: 7 additions & 0 deletions tests/indices/dangling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test dangling indexes.
chapters:
- synopsis: Get dangling indexes.
path: /_dangling
method: GET
49 changes: 49 additions & 0 deletions tests/indices/flush.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test flushing an index.
prologues:
- path: /movies
method: PUT
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Flush all indexes (GET).
path: /_flush
method: GET
parameters:
allow_no_indices: true
expand_wildcards: none
force: true
ignore_unavailable: true
wait_if_ongoing: true
response:
status: 200
payload:
_shards: {}
- synopsis: Flush all indexes (POST).
path: /_flush
method: POST
response:
status: 200
payload:
_shards: {}
- synopsis: Flush an index (GET).
path: /{index}/_flush
method: GET
parameters:
index: movies
response:
status: 200
payload:
_shards: {}
- synopsis: Flush an index (POST).
path: /{index}/_flush
method: POST
parameters:
index: movies
response:
status: 200
payload:
_shards: {}
47 changes: 47 additions & 0 deletions tests/indices/forcemerge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

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

description: Test force merging an index.
prologues:
- path: /movies
method: PUT
- path: /games
method: PUT
epilogues:
- path: /movies,games
method: DELETE
status: [200, 404]
chapters:
- synopsis: Force merge all indexes.
path: /_forcemerge
method: POST
parameters:
allow_no_indices: true
expand_wildcards: none
flush: true
max_num_segments: 1
only_expunge_deletes: true
primary_only: false
ignore_unavailable: true
response:
status: 200
payload:
_shards: {}
- synopsis: Force merge an index.
path: /{index}/_forcemerge
method: POST
parameters:
index: movies
response:
status: 200
payload:
_shards: {}
- synopsis: Force merge multiple indexes.
path: /{index}/_forcemerge
method: POST
parameters:
index: movies,games
response:
status: 200
payload:
_shards: {}
6 changes: 6 additions & 0 deletions tests/indices/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ chapters:
method: HEAD
parameters:
index: books
allow_no_indices: true
expand_wildcards: none
flat_settings: true
include_defaults: true
ignore_unavailable: true
local: true

- synopsis: Check if the index `movies` exists. It should not.
path: /{index}
Expand Down
File renamed without changes.
69 changes: 69 additions & 0 deletions tests/indices/settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

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

description: Test settings for an index.
prologues:
- path: /movies
method: PUT
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Get global settings.
path: /_settings
method: GET
parameters:
allow_no_indices: true
expand_wildcards: none
flat_settings: true
include_defaults: true
ignore_unavailable: true
local: true
cluster_manager_timeout: 1s
response:
status: 200
- synopsis: Write a setting to an index.
path: /{index}/_settings
method: PUT
parameters:
index: movies
request_body:
payload:
settings:
index.blocks.write: true
index:
number_of_replicas: 4
- synopsis: Get settings for an index.
path: /{index}/_settings
method: GET
parameters:
index: movies
allow_no_indices: true
expand_wildcards: none
response:
status: 200
payload:
movies:
settings:
index:
provided_name: movies
blocks:
write: 'true'
- synopsis: Get a specific setting for an index.
path: /{index}/_settings/{name}
method: GET
parameters:
index: movies
name: index.blocks.write
response:
status: 200
payload:
movies:
settings:
index:
blocks:
write: 'true'



62 changes: 62 additions & 0 deletions tests/indices/shrink.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test shrinking an index.
prologues:
- path: /movies
method: PUT
request_body:
payload:
settings:
index.number_of_shards: 3
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
- path: /movies1
method: DELETE
status: [200, 404]
- path: /movies2
method: DELETE
status: [200, 404]
chapters:
- synopsis: Block writes to the source index.
path: /{index}/_settings
method: PUT
parameters:
index: movies
request_body:
payload:
settings:
index.blocks.write: true
- synopsis: Shrink an index (POST).
path: /{index}/_shrink/{target}
method: POST
parameters:
index: movies
target: movies1
wait_for_active_shards: 1
cluster_manager_timeout: 10s
timeout: 10s
wait_for_completion: true
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
index: movies1
- synopsis: Shrink an index (PUT).
path: /{index}/_shrink/{target}
method: PUT
parameters:
index: movies
target: movies2
wait_for_active_shards: 1
cluster_manager_timeout: 10s
timeout: 10s
wait_for_completion: true
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
index: movies2
72 changes: 72 additions & 0 deletions tests/indices/split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test splitting an index.
prologues:
- path: /movies
method: PUT
request_body:
payload:
settings:
index.number_of_shards: 3
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
- path: /movies1
method: DELETE
status: [200, 404]
- path: /movies2
method: DELETE
status: [200, 404]
chapters:
- synopsis: Block writes to the source index.
path: /{index}/_settings
method: PUT
parameters:
index: movies
request_body:
payload:
settings:
index.blocks.write: true
- synopsis: Split an index (POST).
path: /{index}/_split/{target}
method: POST
parameters:
index: movies
target: movies1
wait_for_active_shards: 1
cluster_manager_timeout: 10s
timeout: 10s
wait_for_completion: true
request_body:
payload:
settings:
index:
number_of_shards: 6
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
index: movies1
- synopsis: Split an index (PUT).
path: /{index}/_split/{target}
method: PUT
parameters:
index: movies
target: movies2
wait_for_active_shards: 1
cluster_manager_timeout: 10s
timeout: 10s
wait_for_completion: true
request_body:
payload:
settings:
index:
number_of_shards: 6
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
index: movies2
Loading