From 5491aa9627de96c89147229031546edf9c2d7ce9 Mon Sep 17 00:00:00 2001 From: Roman Vasin Date: Thu, 15 Dec 2022 11:50:23 +0000 Subject: [PATCH] Implement wait_kerberos_kdc_is_available --- tests/integration/helpers/cluster.py | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/integration/helpers/cluster.py b/tests/integration/helpers/cluster.py index 7557e8412d2..ba5d02095f3 100644 --- a/tests/integration/helpers/cluster.py +++ b/tests/integration/helpers/cluster.py @@ -206,6 +206,22 @@ def check_kafka_is_available(kafka_id, kafka_port): p.communicate() return p.returncode == 0 +def check_kerberos_kdc_is_available(kerberos_kdc_id): + p = subprocess.Popen( + ( + "docker", + "exec", + "-i", + kerberos_kdc_id, + "/etc/rc.d/init.d/krb5kdc", + "status", + ), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + p.communicate() + return p.returncode == 0 + def check_rabbitmq_is_available(rabbitmq_id): p = subprocess.Popen( @@ -458,7 +474,7 @@ class ClickHouseCluster: # available when with_kerberos_kdc == True self.kerberos_kdc_host = "kerberoskdc" - self.keberos_docker_id = self.get_instance_docker_id( + self.keberos_kdc_docker_id = self.get_instance_docker_id( self.kerberos_kdc_host ) @@ -2165,10 +2181,18 @@ class ClickHouseCluster: logging.debug("Waiting for Kafka to start up") time.sleep(1) - def wait_kerberos_kdc_is_available(self, kafka_docker_id): - logging.debug("Waiting for Kerberos KDC to start up") - # temp code: sleep 50 seconds - time.sleep(50) + def wait_kerberos_kdc_is_available(self, kerberos_kdc_docker_id, max_retries=50): + retries = 0 + while True: + if check_kerberos_kdc_is_available(kerberos_kdc_docker_id): + break + else: + retries += 1 + if retries > max_retries: + raise Exception("Kerberos KDC is not available") + logging.debug("Waiting for Kerberos KDC to start up") + time.sleep(1) + def wait_hdfs_to_start(self, timeout=300, check_marker=False): start = time.time() @@ -2527,7 +2551,7 @@ class ClickHouseCluster: + ["--renew-anon-volumes"] ) self.up_called = True - self.wait_kerberos_kdc_is_available(self.keberos_docker_id) + self.wait_kerberos_kdc_is_available(self.keberos_kdc_docker_id) if self.with_rabbitmq and self.base_rabbitmq_cmd: logging.debug("Setup RabbitMQ")