Skip to content

Commit

Permalink
adding specs and tests for upgrade api
Browse files Browse the repository at this point in the history
Signed-off-by: Tokesh <[email protected]>
  • Loading branch information
Tokesh committed Nov 24, 2024
1 parent f847731 commit af3ba3e
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
21 changes: 19 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: '2.0' # i dont know the actual version
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: '2.0' # i dont know the actual version
description: The _upgrade API is no longer useful and will be removed.
externalDocs:
url: https://opensearch.org/docs/latest
Expand Down Expand Up @@ -1850,6 +1852,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 +2269,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 @@ -2525,7 +2534,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/IndexUpgradeStatus'
indices.open@200:
content:
application/json:
Expand Down Expand Up @@ -2735,7 +2748,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 @@ -1010,3 +1010,57 @@ 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:
- open
- closed
- none
- all
ignore_unavailable:
type: boolean
wait_for_completion:
type: boolean
40 changes: 40 additions & 0 deletions tests/default/indices/upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
$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: Check index upgrade status (GET).
path: /{index}/_upgrade
method: GET
parameters:
index: [movies]
response:
status: 200

- 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

0 comments on commit af3ba3e

Please sign in to comment.