Skip to content

Commit

Permalink
Merge pull request #16365 from vzakaznikov/fix_another_ldap_test_issue
Browse files Browse the repository at this point in the history
Fixing another issue in LDAP tests
  • Loading branch information
alexey-milovidov authored Oct 26, 2020
2 parents fb8a48a + be95d3d commit e30e4a4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tests/testflows/ldap/authentication/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,29 @@ def add_config(config, timeout=60, restart=False):
:param config: configuration file description
: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.
"""
started = time.time()
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:
exitcode = node.command(command, steps=False).exitcode
if exitcode == 0:
break
if after_removal:
if exitcode == 1:
break
else:
if exitcode == 0:
break
time.sleep(1)

if settings.debug:
node.command(f"cat /var/lib/clickhouse/preprocessed_configs/{config.preprocessed_name}")
assert exitcode == 0, error()

if after_removal:
assert exitcode == 1, error()
else:
assert exitcode == 0, error()

def wait_for_config_to_be_loaded():
"""Wait for config to be loaded.
Expand Down Expand Up @@ -160,7 +170,7 @@ def wait_for_config_to_be_loaded():
node.command(f"rm -rf {config.path}", exitcode=0)

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"):
wait_for_config_to_be_loaded()
Expand Down

0 comments on commit e30e4a4

Please sign in to comment.