1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
"""Test replica count changing functionality"""
# pylint: disable=C0115, C0116, invalid-name
import os
from . import CuratorTestCase
from . import testvars
HOST = os.environ.get('TEST_ES_SERVER', 'http://127.0.0.1:9200')
class TestActionFileReplicas(CuratorTestCase):
def test_increase_count(self):
count = 2
idx = 'my_index'
self.write_config(self.args['configfile'], testvars.client_config.format(HOST))
self.write_config(self.args['actionfile'], testvars.replicas_test.format(count))
self.create_index(idx)
self.invoke_runner()
assert count == int(
self.client.indices.get_settings(index=idx)[idx]['settings']['index'][
'number_of_replicas'
]
)
def test_no_count(self):
self.create_index('foo')
self.write_config(self.args['configfile'], testvars.client_config.format(HOST))
self.write_config(self.args['actionfile'], testvars.replicas_test.format(' '))
self.invoke_runner()
assert 1 == self.result.exit_code
def test_extra_option(self):
self.create_index('foo')
self.write_config(self.args['configfile'], testvars.client_config.format(HOST))
self.write_config(
self.args['actionfile'], testvars.bad_option_proto_test.format('replicas')
)
self.invoke_runner()
assert 1 == self.result.exit_code
class TestCLIReplicas(CuratorTestCase):
def test_increase_count(self):
count = 2
idx = 'my_index'
self.create_index(idx)
args = self.get_runner_args()
args += [
'--config',
self.args['configfile'],
'replicas',
'--count',
str(count),
'--filter_list',
'{"filtertype":"pattern","kind":"prefix","value":"my"}',
]
assert 0 == self.run_subprocess(
args, logname='TestCLIOpenClosed.test_open_closed'
)
assert count == int(
self.client.indices.get_settings(index=idx)[idx]['settings']['index'][
'number_of_replicas'
]
)
|