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

Index Upgrade API specs and tests for them #690

Merged
merged 21 commits into from
Dec 1, 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
25 changes: 23 additions & 2 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ paths:
operationId: indices.get_upgrade.0
x-operation-group: indices.get_upgrade
x-version-added: '1.0'
x-version-deprecated: '1.0'
description: The `_upgrade` API is no longer useful and will be removed.
externalDocs:
url: https://opensearch.org/docs/latest
Expand All @@ -858,6 +859,7 @@ paths:
operationId: indices.upgrade.0
x-operation-group: indices.upgrade
x-version-added: '1.0'
x-version-deprecated: '1.0'
description: The `_upgrade` API is no longer useful and will be removed.
externalDocs:
url: https://opensearch.org/docs/latest
Expand All @@ -867,6 +869,8 @@ paths:
- $ref: '#/components/parameters/indices.upgrade::query.ignore_unavailable'
- $ref: '#/components/parameters/indices.upgrade::query.only_ancient_segments'
- $ref: '#/components/parameters/indices.upgrade::query.wait_for_completion'
requestBody:
$ref: '#/components/requestBodies/indices.upgrade'
responses:
'200':
$ref: '#/components/responses/indices.upgrade@200'
Expand Down Expand Up @@ -1827,6 +1831,7 @@ paths:
operationId: indices.get_upgrade.1
x-operation-group: indices.get_upgrade
x-version-added: '1.0'
x-version-deprecated: '1.0'
description: The `_upgrade` API is no longer useful and will be removed.
externalDocs:
url: https://opensearch.org/docs/latest
Expand All @@ -1842,6 +1847,7 @@ paths:
operationId: indices.upgrade.1
x-operation-group: indices.upgrade
x-version-added: '1.0'
x-version-deprecated: '1.0'
description: The `_upgrade` API is no longer useful and will be removed.
externalDocs:
url: https://opensearch.org/docs/latest
Expand All @@ -1852,6 +1858,8 @@ paths:
- $ref: '#/components/parameters/indices.upgrade::query.ignore_unavailable'
- $ref: '#/components/parameters/indices.upgrade::query.only_ancient_segments'
- $ref: '#/components/parameters/indices.upgrade::query.wait_for_completion'
requestBody:
$ref: '#/components/requestBodies/indices.upgrade'
responses:
'200':
$ref: '#/components/responses/indices.upgrade@200'
Expand Down Expand Up @@ -2265,6 +2273,11 @@ components:
$ref: '../schemas/indices.update_aliases.yaml#/components/schemas/Action'
description: The definition of `actions` to perform
required: true
indices.upgrade:
content:
application/json:
schema:
$ref: '../schemas/indices._common.yaml#/components/schemas/UpgradeRequest'
indices.validate_query:
content:
application/json:
Expand Down Expand Up @@ -2530,7 +2543,11 @@ components:
type: object
additionalProperties:
$ref: '../schemas/indices._common.yaml#/components/schemas/TemplateMapping'
indices.get_upgrade@200: {}
indices.get_upgrade@200:
content:
application/json:
schema:
$ref: '../schemas/indices._common.yaml#/components/schemas/IndexGetUpgradeStatus'
indices.open@200:
content:
application/json:
Expand Down Expand Up @@ -2740,7 +2757,11 @@ components:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase'
indices.upgrade@200: {}
indices.upgrade@200:
content:
application/json:
schema:
$ref: '../schemas/indices._common.yaml#/components/schemas/IndexPostUpgradeStatus'
indices.validate_query@200:
content:
application/json:
Expand Down
54 changes: 54 additions & 0 deletions spec/schemas/indices._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,60 @@ components:
- mappings
- order
- settings
IndexGetUpgradeStatus:
type: object
properties:
size_in_bytes:
$ref: '_common.yaml#/components/schemas/ByteCount'
size_to_upgrade_in_bytes:
$ref: '_common.yaml#/components/schemas/ByteCount'
size_to_upgrade_ancient_in_bytes:
$ref: '_common.yaml#/components/schemas/ByteCount'
indices:
type: object
additionalProperties:
$ref: '#/components/schemas/UpgradeStatus'
UpgradeStatus:
type: object
properties:
size_in_bytes:
$ref: '_common.yaml#/components/schemas/ByteCount'
size_to_upgrade_in_bytes:
$ref: '_common.yaml#/components/schemas/ByteCount'
size_to_upgrade_ancient_in_bytes:
$ref: '_common.yaml#/components/schemas/ByteCount'
IndexPostUpgradeStatus:
type: object
properties:
_shards:
$ref: '_common.yaml#/components/schemas/ShardStatistics'
upgraded_indices:
type: object
additionalProperties:
$ref: '#/components/schemas/UpgradeVersionStatus'
UpgradeVersionStatus:
type: object
properties:
upgrade_version:
$ref: '_common.yaml#/components/schemas/VersionString'
oldest_lucene_segment_version:
$ref: '_common.yaml#/components/schemas/VersionString'
UpgradeRequest:
type: object
properties:
allow_no_indices:
type: boolean
expand_wildcards:
type: string
enum:
- all
- closed
- none
- open
ignore_unavailable:
type: boolean
wait_for_completion:
type: boolean
IndexError:
type: object
properties:
Expand Down
57 changes: 57 additions & 0 deletions tests/default/indices/upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test upgrading index using both GET and POST methods.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: movies, _id: movie1}}
- {director: Bennett Miller, title: The Cruise, year: 1998}
- {create: {_index: movies, _id: movie2}}
- {director: Nicolas Winding Refn, title: Drive, year: 1960}
chapters:
- synopsis: Trigger index upgrade (POST).
path: /{index}/_upgrade
method: POST
parameters:
index: [movies]
request:
payload:
allow_no_indices: true
expand_wildcards: open
ignore_unavailable: true
response:
status: 200

- synopsis: Check index upgrade status (GET).
path: /{index}/_upgrade
method: GET
parameters:
index: [movies]
response:
status: 200

- synopsis: Trigger upgrade (POST).
Copy link
Member

Choose a reason for hiding this comment

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

Note that this is not an /{index} API and should go in its own tests/default/_core/upgrade.yaml. I'll merge now, but appreciate it being split in a future PR.

path: /_upgrade
method: POST
request:
payload:
allow_no_indices: false
expand_wildcards: closed
ignore_unavailable: false
response:
status: 200

- synopsis: Check upgrade status (GET).
path: /_upgrade
method: GET
response:
status: 200