Skip to content

Commit

Permalink
Index Upgrade API specs and tests for them (#690)
Browse files Browse the repository at this point in the history
* replication added

Signed-off-by: Tokesh <[email protected]>

* fixing lint and trying test verbose

Signed-off-by: Tokesh <[email protected]>

* changing docker compose

Signed-off-by: Tokesh <[email protected]>

* adding tests for replication namespace

Signed-off-by: Tokesh <[email protected]>

* fixing lint, validate specs ci

Signed-off-by: Tokesh <[email protected]>

* fixing docker-compose and validate specs ci

Signed-off-by: Tokesh <[email protected]>

* fixing validate specs ci

Signed-off-by: Tokesh <[email protected]>

* trying to fix validate specs

Signed-off-by: Tokesh <[email protected]>

* trying to fix validate specs v2

Signed-off-by: Tokesh <[email protected]>

* adding specs and tests for upgrade api

Signed-off-by: Tokesh <[email protected]>

* removing conflicts with rebase

Signed-off-by: Tokesh <[email protected]>

* hotfix lint

Signed-off-by: Tokesh <[email protected]>

* fixing ci cd conflicts

Signed-off-by: Tokesh <[email protected]>

* flipping post and get and adding real deprecated version in specs

Signed-off-by: Tokesh <[email protected]>

* adding two more upgrade specs

Signed-off-by: Tokesh <[email protected]>

---------

Signed-off-by: Tokesh <[email protected]>
Signed-off-by: Niyazbek Torekeldi <[email protected]>
  • Loading branch information
Tokesh authored Dec 1, 2024
1 parent c400057 commit b7e9744
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 2 deletions.
25 changes: 23 additions & 2 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,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 @@ -856,6 +857,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 @@ -865,6 +867,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 @@ -1825,6 +1829,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 @@ -1840,6 +1845,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 @@ -1850,6 +1856,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 @@ -2263,6 +2271,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 @@ -2528,7 +2541,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 @@ -2738,7 +2755,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).
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

0 comments on commit b7e9744

Please sign in to comment.