From b7e9744e2199258e4fcee7567948bccdb766e11b Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:27:53 +0500 Subject: [PATCH] Index `Upgrade` API specs and tests for them (#690) * replication added Signed-off-by: Tokesh * fixing lint and trying test verbose Signed-off-by: Tokesh * changing docker compose Signed-off-by: Tokesh * adding tests for replication namespace Signed-off-by: Tokesh * fixing lint, validate specs ci Signed-off-by: Tokesh * fixing docker-compose and validate specs ci Signed-off-by: Tokesh * fixing validate specs ci Signed-off-by: Tokesh * trying to fix validate specs Signed-off-by: Tokesh * trying to fix validate specs v2 Signed-off-by: Tokesh * adding specs and tests for upgrade api Signed-off-by: Tokesh * removing conflicts with rebase Signed-off-by: Tokesh * hotfix lint Signed-off-by: Tokesh * fixing ci cd conflicts Signed-off-by: Tokesh * flipping post and get and adding real deprecated version in specs Signed-off-by: Tokesh * adding two more upgrade specs Signed-off-by: Tokesh --------- Signed-off-by: Tokesh Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- spec/namespaces/indices.yaml | 25 +++++++++++-- spec/schemas/indices._common.yaml | 54 ++++++++++++++++++++++++++++ tests/default/indices/upgrade.yaml | 57 ++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 tests/default/indices/upgrade.yaml diff --git a/spec/namespaces/indices.yaml b/spec/namespaces/indices.yaml index b2b0e64de..442021c5b 100644 --- a/spec/namespaces/indices.yaml +++ b/spec/namespaces/indices.yaml @@ -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 @@ -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 @@ -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' @@ -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 @@ -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 @@ -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' @@ -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: @@ -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: @@ -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: diff --git a/spec/schemas/indices._common.yaml b/spec/schemas/indices._common.yaml index 2f08e5827..316cba4e3 100644 --- a/spec/schemas/indices._common.yaml +++ b/spec/schemas/indices._common.yaml @@ -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: diff --git a/tests/default/indices/upgrade.yaml b/tests/default/indices/upgrade.yaml new file mode 100644 index 000000000..281f94029 --- /dev/null +++ b/tests/default/indices/upgrade.yaml @@ -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 \ No newline at end of file