Merge pull request #16365 from vzakaznikov/fix_another_ldap_test_issue

Fixing another issue in LDAP tests
This commit is contained in:
alexey-milovidov 2020-10-26 07:38:20 +03:00 committed by GitHub
commit e30e4a47fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,18 +85,28 @@ def add_config(config, timeout=60, restart=False):
:param config: configuration file description :param config: configuration file description
:param timeout: timeout, default: 20 sec :param timeout: timeout, default: 20 sec
""" """
def check_preprocessed_config_is_updated(): def check_preprocessed_config_is_updated(after_removal=False):
"""Check that preprocessed config is updated. """Check that preprocessed config is updated.
""" """
started = time.time() started = time.time()
command = f"cat /var/lib/clickhouse/preprocessed_configs/{config.preprocessed_name} | grep {config.uid}{' > /dev/null' if not settings.debug else ''}" command = f"cat /var/lib/clickhouse/preprocessed_configs/{config.preprocessed_name} | grep {config.uid}{' > /dev/null' if not settings.debug else ''}"
while time.time() - started < timeout: while time.time() - started < timeout:
exitcode = node.command(command, steps=False).exitcode exitcode = node.command(command, steps=False).exitcode
if after_removal:
if exitcode == 1:
break
else:
if exitcode == 0: if exitcode == 0:
break break
time.sleep(1) time.sleep(1)
if settings.debug: if settings.debug:
node.command(f"cat /var/lib/clickhouse/preprocessed_configs/{config.preprocessed_name}") node.command(f"cat /var/lib/clickhouse/preprocessed_configs/{config.preprocessed_name}")
if after_removal:
assert exitcode == 1, error()
else:
assert exitcode == 0, error() assert exitcode == 0, error()
def wait_for_config_to_be_loaded(): def wait_for_config_to_be_loaded():
@ -160,7 +170,7 @@ def add_config(config, timeout=60, restart=False):
node.command(f"rm -rf {config.path}", exitcode=0) node.command(f"rm -rf {config.path}", exitcode=0)
with Then(f"{config.preprocessed_name} should be updated", description=f"timeout {timeout}"): with Then(f"{config.preprocessed_name} should be updated", description=f"timeout {timeout}"):
check_preprocessed_config_is_updated() check_preprocessed_config_is_updated(after_removal=True)
with And("I wait for config to be reloaded"): with And("I wait for config to be reloaded"):
wait_for_config_to_be_loaded() wait_for_config_to_be_loaded()