mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 02:18:39 +08:00
Add test coverage for coordinators command
This commit is contained in:
parent
07882d809d
commit
4659c028f5
@ -332,33 +332,63 @@ def transaction(logger):
|
|||||||
output7 = run_fdbcli_command('get', 'key')
|
output7 = run_fdbcli_command('get', 'key')
|
||||||
assert output7 == "`key': not found"
|
assert output7 == "`key': not found"
|
||||||
|
|
||||||
@enable_logging(logging.DEBUG)
|
def get_fdb_process_addresses():
|
||||||
def coordinator(logger):
|
# get all processes' network addresses
|
||||||
output1 = run_fdbcli_command('coordinators')
|
output = run_fdbcli_command('kill')
|
||||||
logger.debug(output1)
|
# except the first line, each line is one process
|
||||||
output2 = run_fdbcli_command('status', 'details')
|
addresses = output.split('\n')[1:]
|
||||||
logger.debug(output2)
|
assert len(addresses) == process_number
|
||||||
|
return addresses
|
||||||
|
|
||||||
@enable_logging(logging.DEBUG)
|
@enable_logging()
|
||||||
|
def coordinators(logger):
|
||||||
|
# we should only have one coordinator for now
|
||||||
|
output1 = run_fdbcli_command('coordinators')
|
||||||
|
assert len(output1.split('\n')) > 2
|
||||||
|
cluster_description = output1.split('\n')[0].split(': ')[-1]
|
||||||
|
logger.debug("Cluster description: {}".format(cluster_description))
|
||||||
|
coordinators = output1.split('\n')[1].split(': ')[-1]
|
||||||
|
# verify the coordinator
|
||||||
|
coordinator_list = get_value_from_status_json(True, 'client', 'coordinators', 'coordinators')
|
||||||
|
assert len(coordinator_list) == 1
|
||||||
|
assert coordinator_list[0]['address'] == coordinators
|
||||||
|
# verify the cluster description
|
||||||
|
assert get_value_from_status_json(True, 'cluster', 'connection_string').startswith('{}:'.format(cluster_description))
|
||||||
|
addresses = get_fdb_process_addresses()
|
||||||
|
# set all 5 processes as coordinators and update the cluster description
|
||||||
|
new_cluster_description = 'a_simple_description'
|
||||||
|
run_fdbcli_command('coordinators', *addresses, 'description={}'.format(new_cluster_description))
|
||||||
|
# verify now we have 5 coordinators and the description is updated
|
||||||
|
output2 = run_fdbcli_command('coordinators')
|
||||||
|
assert output2.split('\n')[0].split(': ')[-1] == new_cluster_description
|
||||||
|
assert output2.split('\n')[1] == 'Cluster coordinators ({}): {}'.format(5, ','.join(addresses))
|
||||||
|
# auto change should go back to 1 coordinator
|
||||||
|
run_fdbcli_command('coordinators', 'auto')
|
||||||
|
assert len(get_value_from_status_json(True, 'client', 'coordinators', 'coordinators')) == 1
|
||||||
|
|
||||||
|
@enable_logging()
|
||||||
def exclude(logger):
|
def exclude(logger):
|
||||||
# get all processes' network addresses
|
# get all processes' network addresses
|
||||||
output1 = run_fdbcli_command('kill')
|
addresses = get_fdb_process_addresses()
|
||||||
# except the first line, each line is one process
|
|
||||||
addresses = output1.split('\n')[1:]
|
|
||||||
assert len(addresses) == process_number
|
|
||||||
logger.debug("Cluster processes: {}".format(' '.join(addresses)))
|
logger.debug("Cluster processes: {}".format(' '.join(addresses)))
|
||||||
# There should be no excluded process for now
|
# There should be no excluded process for now
|
||||||
no_excluded_process_output = 'There are currently no servers or localities excluded from the database.'
|
no_excluded_process_output = 'There are currently no servers or localities excluded from the database.'
|
||||||
output2 = run_fdbcli_command('exclude')
|
output1 = run_fdbcli_command('exclude')
|
||||||
assert no_excluded_process_output in output2
|
assert no_excluded_process_output in output1
|
||||||
# randomly pick one and exclude the process
|
# randomly pick one and exclude the process
|
||||||
excluded_address = random.choice(addresses)
|
excluded_address = random.choice(addresses)
|
||||||
|
# sometimes we need to retry the exclude
|
||||||
|
while True:
|
||||||
logger.debug("Excluding process: {}".format(excluded_address))
|
logger.debug("Excluding process: {}".format(excluded_address))
|
||||||
temp = run_fdbcli_command('exclude', excluded_address)
|
error_message = run_fdbcli_command_and_get_error('exclude', excluded_address)
|
||||||
output3 = run_fdbcli_command('exclude')
|
if not error_message:
|
||||||
|
break
|
||||||
|
logger.debug("Retry exclude after 1 second")
|
||||||
|
time.sleep(1)
|
||||||
|
output2 = run_fdbcli_command('exclude')
|
||||||
# logger.debug(output3)
|
# logger.debug(output3)
|
||||||
assert 'There are currently 1 servers or localities being excluded from the database' in output3
|
assert 'There are currently 1 servers or localities being excluded from the database' in output2
|
||||||
assert excluded_address in output3
|
assert excluded_address in output2
|
||||||
run_fdbcli_command('include', excluded_address)
|
run_fdbcli_command('include', excluded_address)
|
||||||
# check the include is successful
|
# check the include is successful
|
||||||
output4 = run_fdbcli_command('exclude')
|
output4 = run_fdbcli_command('exclude')
|
||||||
@ -385,8 +415,7 @@ if __name__ == '__main__':
|
|||||||
transaction()
|
transaction()
|
||||||
else:
|
else:
|
||||||
assert process_number > 1, "Process number should be positive"
|
assert process_number > 1, "Process number should be positive"
|
||||||
# wait for cluster to be ready
|
coordinators()
|
||||||
time.sleep(5)
|
|
||||||
exclude()
|
exclude()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user