From e9552789307b48a953d84ea4f58734620e9cb941 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 13 Dec 2024 04:33:23 +1300 Subject: [PATCH] Fix snapshot status numeric property types (#729) * Fix snapshot status numeric property types Signed-off-by: Thomas Farr * changelog Signed-off-by: Thomas Farr * Add test Signed-off-by: Thomas Farr * Fix tests Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- CHANGELOG.md | 1 + spec/schemas/snapshot._common.yaml | 68 ++++++++++++++++++----------- tests/snapshot/snapshot/status.yaml | 66 ++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 25 deletions(-) create mode 100644 tests/snapshot/snapshot/status.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index d5e840236..e6fdd6040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed response code in `PUT /_plugins/_rollup/jobs/{id}` ([#716](https://github.com/opensearch-project/opensearch-api-specification/pull/716)) - Fixed response schema for `/_render/template` and `/_render/template/{id}` ([#724](https://github.com/opensearch-project/opensearch-api-specification/pull/724)) - Fixed data stream schema numeric property types ([#725](https://github.com/opensearch-project/opensearch-api-specification/pull/725)) +- Fixed snapshot status numeric property types ([#729](https://github.com/opensearch-project/opensearch-api-specification/pull/729)) ### Changed - Changed `tasks._common:TaskInfo` and `tasks._common:TaskGroup` to be composed of a `tasks._common:TaskInfoBase` ([#683](https://github.com/opensearch-project/opensearch-api-specification/pull/683)) diff --git a/spec/schemas/snapshot._common.yaml b/spec/schemas/snapshot._common.yaml index 8eae7a0ea..f894210dd 100644 --- a/spec/schemas/snapshot._common.yaml +++ b/spec/schemas/snapshot._common.yaml @@ -95,19 +95,13 @@ components: chunk_size: type: string compress: - oneOf: - - type: string - - type: boolean + $ref: '_common.yaml#/components/schemas/StringifiedBoolean' concurrent_streams: - oneOf: - - type: string - - type: number + $ref: '_common.yaml#/components/schemas/StringifiedInteger' location: type: string read_only: - oneOf: - - type: string - - type: boolean + $ref: '_common.yaml#/components/schemas/StringifiedBoolean' required: - location Status: @@ -132,7 +126,6 @@ components: uuid: $ref: '_common.yaml#/components/schemas/Uuid' required: - - include_global_state - indices - repository - shards_stats @@ -158,6 +151,10 @@ components: SnapshotShardsStatus: type: object properties: + node: + $ref: '_common.yaml#/components/schemas/NodeId' + reason: + type: string stage: $ref: '#/components/schemas/ShardsStatsStage' stats: @@ -166,18 +163,29 @@ components: - stage - stats ShardsStatsStage: - type: string - enum: - - DONE - - FAILURE - - FINALIZE - - INIT - - STARTED + oneOf: + - type: string + const: DONE + description: Number of shards in the snapshot that were successfully stored in the repository. + - type: string + const: FAILURE + description: Number of shards in the snapshot that were not successfully stored in the repository. + - type: string + const: FINALIZE + description: Number of shards in the snapshot that are in the finalizing stage of being stored in the repository. + - type: string + const: INIT + description: Number of shards in the snapshot that are in the initializing stage of being stored in the repository. + - type: string + const: STARTED + description: Number of shards in the snapshot that are in the started stage of being stored in the repository. ShardsStatsSummary: type: object properties: incremental: $ref: '#/components/schemas/ShardsStatsSummaryItem' + processed: + $ref: '#/components/schemas/ShardsStatsSummaryItem' total: $ref: '#/components/schemas/ShardsStatsSummaryItem' start_time_in_millis: @@ -195,7 +203,8 @@ components: type: object properties: file_count: - type: number + type: integer + format: int64 size_in_bytes: $ref: '_common.yaml#/components/schemas/ByteCount' required: @@ -205,17 +214,23 @@ components: type: object properties: done: - type: number + type: integer + format: int64 failed: - type: number + type: integer + format: int64 finalizing: - type: number + type: integer + format: int64 initializing: - type: number + type: integer + format: int64 started: - type: number + type: integer + format: int64 total: - type: number + type: integer + format: int64 required: - done - failed @@ -228,6 +243,8 @@ components: properties: incremental: $ref: '#/components/schemas/FileCountSnapshotStats' + processed: + $ref: '#/components/schemas/FileCountSnapshotStats' start_time_in_millis: $ref: '_common.yaml#/components/schemas/EpochTimeUnitMillis' time: @@ -245,7 +262,8 @@ components: type: object properties: file_count: - type: number + type: integer + format: int32 size_in_bytes: $ref: '_common.yaml#/components/schemas/ByteCount' required: diff --git a/tests/snapshot/snapshot/status.yaml b/tests/snapshot/snapshot/status.yaml new file mode 100644 index 000000000..af00860da --- /dev/null +++ b/tests/snapshot/snapshot/status.yaml @@ -0,0 +1,66 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _snapshot/{repository}/snapshot endpoints. +epilogues: + - path: /_snapshot/{repository}/{snapshot} + method: DELETE + status: [200, 404] + parameters: + repository: my-fs-repository + snapshot: my-test-snapshot + - path: /_snapshot/{repository} + method: DELETE + status: [200, 404] + parameters: + repository: my-fs-repository +prologues: + - path: /_snapshot/{repository} + method: PUT + parameters: + repository: my-fs-repository + request: + payload: + type: fs + settings: + location: /tmp/opensearch/repo + - path: /_snapshot/{repository}/{snapshot} + method: PUT + parameters: + repository: my-fs-repository + snapshot: my-test-snapshot + request: + payload: + indices: '*' + ignore_unavailable: true + include_global_state: false + partial: true +chapters: + - synopsis: Get status of all running snapshots. + path: /_snapshot/_status + method: GET + response: + status: 200 + payload: + snapshots: + - snapshot: my-test-snapshot + - synopsis: Get status of all running snapshots in specific repository. + path: /_snapshot/{repository}/_status + method: GET + parameters: + repository: my-fs-repository + response: + status: 200 + payload: + snapshots: + - snapshot: my-test-snapshot + - synopsis: Get status of specific snapshot in specific repository. + path: /_snapshot/{repository}/{snapshot}/_status + method: GET + parameters: + repository: my-fs-repository + snapshot: my-test-snapshot + response: + status: 200 + payload: + snapshots: + - snapshot: my-test-snapshot \ No newline at end of file