wait for ldap on cluster sturtup

re-run CI

proper cleanup in test
This commit is contained in:
Andrey Zvonov 2024-09-16 15:48:40 +00:00
parent 5eb3d9496a
commit 80b28e33bb
2 changed files with 35 additions and 1 deletions

View File

@ -4716,6 +4716,9 @@ class ClickHouseInstance:
if self.with_kerberized_hdfs:
depends_on.append("kerberizedhdfs1")
if self.with_ldap:
depends_on.append("openldap")
if self.with_rabbitmq:
depends_on.append("rabbitmq1")

View File

@ -48,9 +48,32 @@ ldapadd -H ldap://{host}:{port} -D "{admin_bind_dn}" -x -w {admin_password}
assert code == 0
def delete_ldap_group(ldap_cluster, group_cn):
code, (stdout, stderr) = ldap_cluster.ldap_container.exec_run(
[
"sh",
"-c",
"""ldapdelete -r 'cn={group_cn},dc=example,dc=org' \
-H ldap://{host}:{port} -D "{admin_bind_dn}" -x -w {admin_password}
""".format(
host=ldap_cluster.ldap_host,
port=ldap_cluster.ldap_port,
admin_bind_dn=LDAP_ADMIN_BIND_DN,
admin_password=LDAP_ADMIN_PASSWORD,
group_cn=group_cn,
),
],
demux=True,
)
logging.debug(
f"test_ldap_external_user_directory code:{code} stdout:{stdout}, stderr:{stderr}"
)
assert code == 0
def test_authentication_pass():
assert instance.query(
"select currentUser()", user="janedoe", password="qwerty"
"SELECT currentUser()", user="janedoe", password="qwerty"
) == TSV([["janedoe"]])
@ -93,3 +116,11 @@ def test_role_mapping(ldap_cluster):
user="johndoe",
password="qwertz",
) == TSV([["role_1"], ["role_2"], ["role_3"]])
instance.query("DROP ROLE role_1")
instance.query("DROP ROLE role_2")
instance.query("DROP ROLE role_3")
delete_ldap_group(ldap_cluster, group_cn="clickhouse-role_1")
delete_ldap_group(ldap_cluster, group_cn="clickhouse-role_2")
delete_ldap_group(ldap_cluster, group_cn="clickhouse-role_3")