Skip to content

Commit

Permalink
Merge pull request #990 from untergeek/test/wildcard_restore
Browse files Browse the repository at this point in the history
Properly catch wildcard index restores
  • Loading branch information
untergeek committed Jun 14, 2017
2 parents 229ae60 + fbac2f7 commit 2c358b9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion curator/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '5.1.1'
__version__ = '5.1.2.dev0'

5 changes: 4 additions & 1 deletion curator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,10 @@ def restore_check(client, index_list):
if response == {}:
logger.info('_recovery returned an empty response. Trying again.')
return False
for index in index_list:
# Fixes added in #989
logger.info('Provided indices: {0}'.format(index_list))
logger.info('Found indices: {0}'.format(list(response.keys())))
for index in response:
for shard in range(0, len(response[index]['shards'])):
# Apparently `is not` is not always `!=`. Unsure why, will
# research later. Using != fixes #966
Expand Down
8 changes: 8 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Changelog
=========

5.1.2 (? ? ?)

**Bug Fixes**

* The ``restore_check`` function did not work properly with wildcard index
patterns. This has been rectified, and an integration test added to
satisfy this. Reported in #989 (untergeek)

5.1.1 (8 June 2017)

**Bug Fixes**
Expand Down
2 changes: 1 addition & 1 deletion docs/asciidoc/index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:curator_version: 5.1.1
:curator_version: 5.1.2.dev0
:curator_major: 5
:curator_doc_tree: 5.1
:es_py_version: 5.4.0
Expand Down
52 changes: 52 additions & 0 deletions test/integration/test_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,55 @@ def test_restore_with_rename(self):
# The test runs so fast that it tries to execute the cleanup step
# and delete the repository before Elasticsearch is actually ready
time.sleep(1)
def test_restore_wildcard(self):
indices = []
my_indices = []
wildcard = ['my_*']
for i in range(1,4):
for prefix in ['my_', 'not_my_']:
self.add_docs('{0}index{1}'.format(prefix, i))
indices.append('{0}index{1}'.format(prefix, i))
if prefix == 'my_':
my_indices.append('{0}index{1}'.format(prefix, i))
snap_name = 'snapshot1'
self.create_snapshot(snap_name, ','.join(indices))
snapshot = curator.get_snapshot(
self.client, self.args['repository'], '_all'
)
self.assertEqual(1, len(snapshot['snapshots']))
self.client.indices.delete(','.join(indices))
self.assertEqual([], curator.get_indices(self.client))
self.write_config(
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.restore_snapshot_proto.format(
self.args['repository'],
snap_name,
wildcard,
False,
False,
True,
False,
' ',
' ',
' ',
True,
False,
301,
1,
3
)
)
test = clicktest.CliRunner()
result = test.invoke(
curator.cli,
[
'--config', self.args['configfile'],
self.args['actionfile']
],
)
restored_indices = sorted(curator.get_indices(self.client))
self.assertEqual(my_indices, restored_indices)
# The test runs so fast that it tries to execute the cleanup step
# and delete the repository before Elasticsearch is actually ready
time.sleep(0.5)

0 comments on commit 2c358b9

Please sign in to comment.