Skip to content

Commit

Permalink
fix snapshot restore and recovery endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com>
  • Loading branch information
hogesako committed Oct 12, 2024
1 parent 5dc65a5 commit 417ea13
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 2 deletions.
5 changes: 3 additions & 2 deletions spec/namespaces/snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,11 @@ components:
schema:
type: object
properties:
accepted:
description: Equals `true` if the restore was accepted. Present when the request had `wait_for_completion` set to `false`
type: boolean
snapshot:
$ref: '../schemas/snapshot.restore.yaml#/components/schemas/SnapshotRestore'
required:
- snapshot
snapshot.status@200:
content:
application/json:
Expand Down
8 changes: 8 additions & 0 deletions spec/schemas/indices.recovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ components:
$ref: '_common.yaml#/components/schemas/Uuid'
index:
$ref: '_common.yaml#/components/schemas/IndexName'
isSearchableSnapshot:
type: boolean
remoteStoreIndexShallowCopy:
type: boolean
sourceRemoteStoreRepository:
type: ['null', string]
sourceRemoteTranslogRepository:
type: ['null', string]
RecoveryStartStatus:
type: object
properties:
Expand Down
101 changes: 101 additions & 0 deletions tests/snapshot/snapshot/restore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test _snapshot/{repository}/{snapshot}/_restore 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
- path: /restore-index-wait-true
method: DELETE
status: [200, 404]
- path: /restore-index-wait-false
method: DELETE
status: [200, 404]
prologues:
- path: /_snapshot/{repository}
method: PUT
parameters:
repository: my-fs-repository
request:
payload:
type: fs
settings:
location: /tmp/opensearch/repo
- path: /restore-index-wait-true
method: PUT
- path: /restore-index-wait-false
method: PUT
- path: /_snapshot/{repository}/{snapshot}
method: PUT
parameters:
repository: my-fs-repository
snapshot: my-test-snapshot
wait_for_completion: true
request:
payload:
indices:
- restore-index-wait-false
- restore-index-wait-true
ignore_unavailable: true
include_global_state: false
partial: true
- path: /restore-index-wait-true
method: DELETE
status: [200, 404]
- path: /restore-index-wait-false
method: DELETE
status: [200, 404]
chapters:
- synopsis: Restore snapshot with wait_for_completion true.
path: /_snapshot/{repository}/{snapshot}/_restore
method: POST
parameters:
repository: my-fs-repository
snapshot: my-test-snapshot
wait_for_completion: true
request:
payload:
indices: restore-index-wait-true
response:
status: 200
payload:
snapshot:
snapshot: my-test-snapshot
- synopsis: Restore snapshot with wait_for_completion false.
path: /_snapshot/{repository}/{snapshot}/_restore
method: POST
parameters:
repository: my-fs-repository
snapshot: my-test-snapshot
wait_for_completion: false
request:
payload:
indices: restore-index-wait-false
response:
status: 200
payload:
accepted: true
- synopsis: Wait finish async restore.
path: /{index}/_recovery
warnings:
multiple-paths-detected: false
method: GET
parameters:
index: restore-index-wait-false
response:
status: 200
payload:
restore-index-wait-false:
shards:
- stage: DONE
type: SNAPSHOT
retry:
count: 3

0 comments on commit 417ea13

Please sign in to comment.