def test_closed_index_allocation_can_be_modified(self): self.create_index('test_index') self.client.indices.close(index='test_index') index_metadata = self.client.cluster.state( index='test_index', metric='metadata', ) self.assertEquals( 'close', index_metadata['metadata']['indices']['test_index']['state']) curator.apply_allocation_rule(self.client, 'test_index', rule="key=value") self.assertEquals( 'value', self.client.indices.get_settings(index='test_index')['test_index'] ['settings']['index']['routing']['allocation']['require']['key']) self.client.indices.open(index='test_index') index_metadata = self.client.cluster.state( index='test_index', metric='metadata', ) self.assertEquals( 'open', index_metadata['metadata']['indices']['test_index']['state']) self.assertEquals( 'value', self.client.indices.get_settings(index='test_index')['test_index'] ['settings']['index']['routing']['allocation']['require']['key'])
def test_index_allocation_can_be_modified(self): self.create_index('test_index') curator.apply_allocation_rule(self.client, 'test_index', rule="key=value") self.assertEquals( 'value', self.client.indices.get_settings(index='test_index')['test_index'] ['settings']['index']['routing']['allocation']['require']['key'])
def test_apply_allocation_rule_negative(self): client = Mock() client.cluster.state.return_value = open_index client.indices.get_settings.return_value = allocation_in client.indices.put_settings.return_value = None # It should return true now because after skipping one, it results in an empty list. #531 self.assertTrue(curator.apply_allocation_rule(client, named_index, rule="foo=bar"))
def test_allocation_rule_positive(self): client = Mock() client.indices.get_settings.return_value = allocation_out client.cluster.state.return_value = open_index client.indices.put_settings.return_value = None self.assertTrue( curator.apply_allocation_rule(client, named_index, rule="foo=bar"))
def test_closed_index_allocation_can_be_modified(self): self.create_index('test_index') self.client.indices.close(index='test_index') index_metadata = self.client.cluster.state( index='test_index', metric='metadata', ) self.assertEquals('close', index_metadata['metadata']['indices']['test_index']['state']) curator.apply_allocation_rule(self.client, 'test_index', rule="key=value") self.assertEquals('value', self.client.indices.get_settings(index='test_index')['test_index']['settings']['index']['routing']['allocation']['require']['key']) self.client.indices.open(index='test_index') index_metadata = self.client.cluster.state( index='test_index', metric='metadata', ) self.assertEquals('open', index_metadata['metadata']['indices']['test_index']['state']) self.assertEquals('value', self.client.indices.get_settings(index='test_index')['test_index']['settings']['index']['routing']['allocation']['require']['key'])
def test_apply_allocation_rule_empty_list(self): client = Mock() self.assertFalse(curator.apply_allocation_rule(client, [], rule="foo=bar"))
def test_apply_allocation_rule_negative(self): client = Mock() client.cluster.state.return_value = open_index client.indices.get_settings.return_value = allocation_in client.indices.put_settings.return_value = None self.assertFalse(curator.apply_allocation_rule(client, named_index, rule="foo=bar"))
def test_apply_allocation_rule_param_check(self): client = Mock() # Testing for the omission of the rule param self.assertFalse(curator.apply_allocation_rule(client, named_indices))
def test_apply_allocation_rule_empty_list(self): client = Mock() # It should return true now, even with an empty list. #531 self.assertTrue(curator.apply_allocation_rule(client, [], rule="foo=bar"))
def test_index_allocation_can_be_modified_for_exclude(self): self.create_index('test_index') curator.apply_allocation_rule(self.client, 'test_index', rule="key=value", allocation_type='exclude') self.assertEquals('value', self.client.indices.get_settings(index='test_index')['test_index']['settings']['index']['routing']['allocation']['exclude']['key'])