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))
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() _ = test.invoke( curator.cli, ['--config', self.args['configfile'], self.args['actionfile']], ) self.assertEqual(expected, self.client.indices.get_alias(name=alias))
def test_with_date_math(self): self.write_config(self.args['configfile'], testvars.client_config.format(host, port)) self.write_config(self.args['actionfile'], testvars.create_index.format('<testing-{now/d}>')) self.assertEqual([], curator.get_indices(self.client)) name = curator.parse_date_pattern('testing-%Y.%m.%d') test = clicktest.CliRunner() result = test.invoke( curator.cli, ['--config', self.args['configfile'], self.args['actionfile']], ) self.assertEqual([name], curator.get_indices(self.client))
def test_with_date(self): self.write_config( self.args['configfile'], testvars.client_config.format(host, port)) self.write_config(self.args['actionfile'], testvars.create_index.format('testing-%Y.%m.%d')) self.assertEqual([], curator.get_indices(self.client)) name = curator.parse_date_pattern('testing-%Y.%m.%d') test = clicktest.CliRunner() result = test.invoke( curator.cli, [ '--config', self.args['configfile'], self.args['actionfile'] ], ) self.assertEqual([name], curator.get_indices(self.client))