Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow definition of body in restore-snapshot operation #798

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/track.rst
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ With the operation ``restore-snapshot`` you can restore a snapshot from an alrea

* ``repository`` (mandatory): The name of the snapshot repository to use. This snapshot repository must exist prior to calling ``restore-snapshot``.
* ``snapshot`` (mandatory): The name of the snapshot to restore.
* ``body`` (optional): The body of the `snapshot restore request <https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html#restore-snapshot>`_.
* ``wait-for-completion`` (optional, defaults to ``False``): Whether this call should return immediately or block until the snapshot is restored.
* ``request-params`` (optional): A structure containing HTTP request parameters.

Expand Down
1 change: 1 addition & 0 deletions esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,7 @@ def __call__(self, es, params):

es.snapshot.restore(repository=mandatory(params, "repository", repr(self)),
snapshot=mandatory(params, "snapshot", repr(self)),
body=params.get("body"),
wait_for_completion=params.get("wait-for-completion", False),
params=request_params)

Expand Down
37 changes: 37 additions & 0 deletions tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,43 @@ def test_restore_snapshot(self, es):

es.snapshot.restore.assert_called_once_with(repository="backups",
snapshot="snapshot-001",
body=None,
wait_for_completion=True,
params={
"request_timeout": 7200,
"retries": 0
})

@mock.patch("elasticsearch.Elasticsearch")
def test_restore_snapshot_with_body(self, es):
params = {
"repository": "backups",
"snapshot": "snapshot-001",
"body": {
"indices": "index1,index2",
"include_global_state": False,
"index_settings": {
"index.number_of_replicas": 0
}
},
"wait-for-completion": True,
"request-params": {
"request_timeout": 7200
}
}

r = runner.RestoreSnapshot()
r(es, params)

es.snapshot.restore.assert_called_once_with(repository="backups",
snapshot="snapshot-001",
body={
"indices": "index1,index2",
"include_global_state": False,
"index_settings": {
"index.number_of_replicas": 0
}
},
wait_for_completion=True,
params={
"request_timeout": 7200,
Expand Down