Move setclass test from single-process_test to multi-process_test

This commit is contained in:
Chaoguang Lin 2021-08-25 13:04:01 -07:00
parent b6dc20875e
commit a1c8217260

View File

@ -104,45 +104,52 @@ def maintenance(logger):
@enable_logging() @enable_logging()
def setclass(logger): def setclass(logger):
# get all processes' network addresses
output1 = run_fdbcli_command('setclass') output1 = run_fdbcli_command('setclass')
class_type_line_1 = output1.split('\n')[-1] logger.debug(output1)
logger.debug(class_type_line_1) # except the first line, each line is one process
# check process' network address process_types = output1.split('\n')[1:]
assert '127.0.0.1' in class_type_line_1 assert len(process_types) == args.process_number
network_address = ':'.join(class_type_line_1.split(':')[:2]) addresses = []
logger.debug("Network address: {}".format(network_address)) for line in process_types:
# check class type assert '127.0.0.1' in line
assert 'unset' in class_type_line_1 # check class type
# check class source assert 'unset' in line
assert 'command_line' in class_type_line_1 # check class source
assert 'command_line' in line
# check process' network address
network_address = ':'.join(line.split(':')[:2])
logger.debug("Network address: {}".format(network_address))
addresses.append(network_address)
random_address = random.choice(addresses)
logger.debug("Randomly selected address: {}".format(random_address))
# set class to a random valid type # set class to a random valid type
class_types = ['storage', 'storage', 'transaction', 'resolution', class_types = ['storage', 'transaction', 'resolution',
'commit_proxy', 'grv_proxy', 'master', 'stateless', 'log', 'commit_proxy', 'grv_proxy', 'master', 'stateless', 'log',
'router', 'cluster_controller', 'fast_restore', 'data_distributor', 'router', 'cluster_controller', 'fast_restore', 'data_distributor',
'coordinator', 'ratekeeper', 'storage_cache', 'backup' 'coordinator', 'ratekeeper', 'storage_cache', 'backup'
] ]
random_class_type = random.choice(class_types) random_class_type = random.choice(class_types)
logger.debug("Change to type: {}".format(random_class_type)) logger.debug("Change to type: {}".format(random_class_type))
run_fdbcli_command('setclass', network_address, random_class_type) run_fdbcli_command('setclass', random_address, random_class_type)
# check the set successful # check the set successful
output2 = run_fdbcli_command('setclass') output2 = run_fdbcli_command('setclass')
class_type_line_2 = output2.split('\n')[-1] logger.debug(output2)
logger.debug(class_type_line_2) assert random_address in output2
process_types = output2.split('\n')[1:]
# check process' network address # check process' network address
assert network_address in class_type_line_2 for line in process_types:
# check class type changed to the specified value if random_address in line:
assert random_class_type in class_type_line_2 # check class type changed to the specified value
# check class source assert random_class_type in line
assert 'set_class' in class_type_line_2 # check class source
# wait for everything to settle down assert 'set_class' in line
wait_for_database_available(logger)
# set back to default # set back to default
run_fdbcli_command('setclass', network_address, 'default') run_fdbcli_command('setclass', random_address, 'default')
# everything should be back to the same as before
output3 = run_fdbcli_command('setclass') output3 = run_fdbcli_command('setclass')
class_type_line_3 = output3.split('\n')[-1] logger.debug(output3)
logger.debug(class_type_line_3) # everything should be back to the same as before
assert class_type_line_3 == class_type_line_1 assert output1 == output3
@enable_logging() @enable_logging()
@ -499,12 +506,14 @@ def profile(logger):
run_fdbcli_command('profile', 'client', 'set', 'default', 'default') run_fdbcli_command('profile', 'client', 'set', 'default', 'default')
assert run_fdbcli_command('profile', 'client', 'get') == default_profile_client_get_output assert run_fdbcli_command('profile', 'client', 'get') == default_profile_client_get_output
@enable_logging() @enable_logging()
def triggerddteaminfolog(logger): def triggerddteaminfolog(logger):
# this command is straightforward and only has one code path # this command is straightforward and only has one code path
output = run_fdbcli_command('triggerddteaminfolog') output = run_fdbcli_command('triggerddteaminfolog')
assert output == 'Triggered team info logging in data distribution.' assert output == 'Triggered team info logging in data distribution.'
if __name__ == '__main__': if __name__ == '__main__':
parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter, parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
description=""" description="""
@ -543,7 +552,6 @@ if __name__ == '__main__':
lockAndUnlock() lockAndUnlock()
maintenance() maintenance()
profile() profile()
setclass()
suspend() suspend()
transaction() transaction()
throttle() throttle()
@ -552,3 +560,4 @@ if __name__ == '__main__':
assert args.process_number > 1, "Process number should be positive" assert args.process_number > 1, "Process number should be positive"
coordinators() coordinators()
exclude() exclude()
setclass()