Skip to content

Commit

Permalink
Merge pull request #1010 from tschroeder-zendesk/new_index_with_date_…
Browse files Browse the repository at this point in the history
…pattern

Allow dates in new_index value for rollover action
  • Loading branch information
untergeek committed Aug 23, 2017
2 parents cf85134 + 7b670d5 commit 5460bc1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion curator/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def __init__(
self.settings = extra_settings
#: Instance variable.
#: Internal reference to `new_index`
self.new_index = new_index
self.new_index = parse_date_pattern(new_index) if new_index else new_index
#: Instance variable.
#: Internal reference to `wait_for_active_shards`
self.wait_for_active_shards = wait_for_active_shards
Expand Down
52 changes: 51 additions & 1 deletion test/integration/test_rollover.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,54 @@ def test_max_age_with_new_name(self):
self.args['actionfile']
],
)
self.assertEqual(expected, self.client.indices.get_alias(name=alias))
self.assertEqual(expected, self.client.indices.get_alias(name=alias))
def test_max_age_with_new_name_with_date(self):
oldindex = 'rolltome-000001'
newindex = 'crazy_test-%Y.%m.%d'
alias = 'delamitri'
condition = 'max_age'
value = '1s'
expected = {curator.parse_date_pattern(newindex): {u'aliases': {alias: {}}}}
self.client.indices.create(
index=oldindex,
body={ 'aliases': { alias: {} } }
)
time.sleep(1)
self.write_config(
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.rollover_with_name.format(alias, condition, value, newindex))
test = clicktest.CliRunner()
result = test.invoke(
curator.cli,
[
'--config', self.args['configfile'],
self.args['actionfile']
],
)
self.assertEqual(expected, self.client.indices.get_alias(name=alias))
def test_max_age_old_index_with_date_with_new_index(self):
oldindex = 'crazy_test-2017.01.01'
newindex = 'crazy_test-%Y.%m.%d'
alias = 'delamitri'
condition = 'max_age'
value = '1s'
expected = {"%s" % curator.parse_date_pattern(newindex): {u'aliases': {alias: {}}}}
self.client.indices.create(
index=oldindex,
body={ 'aliases': { alias: {} } }
)
time.sleep(1)
self.write_config(
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.rollover_with_name.format(alias, condition, value, newindex))
test = clicktest.CliRunner()
result = test.invoke(
curator.cli,
[
'--config', self.args['configfile'],
self.args['actionfile']
],
)
self.assertEqual(expected, self.client.indices.get_alias(name=alias))

0 comments on commit 5460bc1

Please sign in to comment.