diff --git a/tests/templates/kuttl/authorizer/06-assert.yaml b/tests/templates/kuttl/authorizer/06-assert.yaml index 1f6e20c9..31fc7d24 100644 --- a/tests/templates/kuttl/authorizer/06-assert.yaml +++ b/tests/templates/kuttl/authorizer/06-assert.yaml @@ -2,5 +2,5 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/authcheck.py derby-druid + - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/authcheck.py derby-druid $NAMESPACE timeout: 600 diff --git a/tests/templates/kuttl/authorizer/authcheck.py b/tests/templates/kuttl/authorizer/authcheck.py index b6f8bf47..7f76baa5 100755 --- a/tests/templates/kuttl/authorizer/authcheck.py +++ b/tests/templates/kuttl/authorizer/authcheck.py @@ -2,12 +2,11 @@ import sys import logging -coordinator_host = "derby-druid-coordinator-default-headless" coordinator_port = "8281" authenticator_name = "MyBasicMetadataAuthenticator" -def create_user(user_name): +def create_user(user_name, coordinator_host): requests.post( f"https://{coordinator_host}:{coordinator_port}/druid-ext/basic-security/authentication/db/{authenticator_name}/users/{user_name}", auth=("admin", "password1"), @@ -36,13 +35,19 @@ def create_user(user_name): stream=sys.stdout, ) + druid_cluster_name = sys.argv[1] + namespace = sys.argv[2] + + # Build FQDN for coordinator for TLS/SNI validation + coordinator_host = ( + f"derby-druid-coordinator-default-headless.{namespace}.svc.cluster.local" + ) + print("CREATING USERS") - create_user("alice") - create_user("eve") + create_user("alice", coordinator_host) + create_user("eve", coordinator_host) print("USERS CREATED!") - druid_cluster_name = sys.argv[1] - druid_role_ports = { "broker": 8282, "coordinator": 8281, @@ -52,7 +57,9 @@ def create_user(user_name): } for role, port in druid_role_ports.items(): - url = f"https://{druid_cluster_name}-{role}-default-headless:{port}/status" + # Build FQDN for TLS/SNI validation + host = f"{druid_cluster_name}-{role}-default-headless.{namespace}.svc.cluster.local" + url = f"https://{host}:{port}/status" # make an authorized request -> return 401 expected print("Checking Unauthorized") res = requests.get(url, verify=False) diff --git a/tests/templates/kuttl/commons/ingestioncheck.py b/tests/templates/kuttl/commons/ingestioncheck.py index e0b3f6bc..cbdc7705 100755 --- a/tests/templates/kuttl/commons/ingestioncheck.py +++ b/tests/templates/kuttl/commons/ingestioncheck.py @@ -49,13 +49,22 @@ def query_datasource(self, url, sql, expected, iterations): druid_cluster_name = sys.argv[1] +namespace = sys.argv[2] druid = DruidClient() +# Build FQDNs for TLS/SNI validation +coordinator_host = ( + f"{druid_cluster_name}-coordinator-default-headless.{namespace}.svc.cluster.local" +) +broker_host = ( + f"{druid_cluster_name}-broker-default-headless.{namespace}.svc.cluster.local" +) + print(""" Query tasks ===========""") tasks = druid.get_tasks( - url=f"https://{druid_cluster_name}-coordinator-default-headless:8281/druid/indexer/v1/tasks", + url=f"https://{coordinator_host}:8281/druid/indexer/v1/tasks", ) task_count = len(json.loads(tasks)) print(f"existing tasks: {task_count}") @@ -64,7 +73,7 @@ def query_datasource(self, url, sql, expected, iterations): Start ingestion task ====================""") ingestion = druid.post_task( - url=f"https://{druid_cluster_name}-coordinator-default-headless:8281/druid/indexer/v1/task", + url=f"https://{coordinator_host}:8281/druid/indexer/v1/task", input="/tmp/druid-quickstartimport.json", ) task_id = json.loads(ingestion)["task"] @@ -74,7 +83,7 @@ def query_datasource(self, url, sql, expected, iterations): Re-query tasks ==============""") tasks = druid.get_tasks( - url=f"https://{druid_cluster_name}-coordinator-default-headless:8281/druid/indexer/v1/tasks", + url=f"https://{coordinator_host}:8281/druid/indexer/v1/tasks", ) new_task_count = len(json.loads(tasks)) print(f"new tasks: {new_task_count}") @@ -88,7 +97,7 @@ def query_datasource(self, url, sql, expected, iterations): while not job_finished: time.sleep(5) task = druid.get( - url=f"https://{druid_cluster_name}-coordinator-default-headless:8281/druid/indexer/v1/task/{url_encoded_taskid}/status", + url=f"https://{coordinator_host}:8281/druid/indexer/v1/task/{url_encoded_taskid}/status", ) task_status = json.loads(task)["status"]["statusCode"] print(f"Current task status: [{task_status}]") @@ -104,7 +113,7 @@ def query_datasource(self, url, sql, expected, iterations): while not broker_ready: time.sleep(2) broker_ready_rc = druid.check_rc( - f"https://{druid_cluster_name}-broker-default-headless:8282/druid/broker/v1/readiness" + f"https://{broker_host}:8282/druid/broker/v1/readiness" ) broker_ready = broker_ready_rc == 200 print(f"Broker respondend with [{broker_ready_rc}] to readiness check") @@ -114,7 +123,7 @@ def query_datasource(self, url, sql, expected, iterations): ==============""") sample_data_size = 39244 result = druid.query_datasource( - url=f"https://{druid_cluster_name}-broker-default-headless:8282/druid/v2/sql", + url=f"https://{broker_host}:8282/druid/v2/sql", sql={"query": 'select count(*) as c from "wikipedia-2015-09-12"'}, expected=sample_data_size, iterations=12, diff --git a/tests/templates/kuttl/hdfs-deep-storage/06-assert.yaml b/tests/templates/kuttl/hdfs-deep-storage/06-assert.yaml index 1e955ca3..a996def6 100644 --- a/tests/templates/kuttl/hdfs-deep-storage/06-assert.yaml +++ b/tests/templates/kuttl/hdfs-deep-storage/06-assert.yaml @@ -2,5 +2,5 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py derby-druid + - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py derby-druid $NAMESPACE timeout: 300 diff --git a/tests/templates/kuttl/ingestion-no-s3-ext/06-assert.yaml b/tests/templates/kuttl/ingestion-no-s3-ext/06-assert.yaml index 1e955ca3..a996def6 100644 --- a/tests/templates/kuttl/ingestion-no-s3-ext/06-assert.yaml +++ b/tests/templates/kuttl/ingestion-no-s3-ext/06-assert.yaml @@ -2,5 +2,5 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py derby-druid + - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py derby-druid $NAMESPACE timeout: 300 diff --git a/tests/templates/kuttl/ingestion-s3-ext/06-assert.yaml b/tests/templates/kuttl/ingestion-s3-ext/06-assert.yaml index 1e955ca3..a996def6 100644 --- a/tests/templates/kuttl/ingestion-s3-ext/06-assert.yaml +++ b/tests/templates/kuttl/ingestion-s3-ext/06-assert.yaml @@ -2,5 +2,5 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py derby-druid + - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py derby-druid $NAMESPACE timeout: 300 diff --git a/tests/templates/kuttl/ldap/20-assert.yaml b/tests/templates/kuttl/ldap/20-assert.yaml index 18d1e259..a70d1b63 100644 --- a/tests/templates/kuttl/ldap/20-assert.yaml +++ b/tests/templates/kuttl/ldap/20-assert.yaml @@ -2,5 +2,5 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: kubectl exec -n $NAMESPACE test-druid-0 -- python /tmp/authcheck.py + - script: kubectl exec -n $NAMESPACE test-druid-0 -- python /tmp/authcheck.py $NAMESPACE timeout: 180 diff --git a/tests/templates/kuttl/ldap/authcheck.py b/tests/templates/kuttl/ldap/authcheck.py index 6a42f0ac..f491eec4 100755 --- a/tests/templates/kuttl/ldap/authcheck.py +++ b/tests/templates/kuttl/ldap/authcheck.py @@ -10,6 +10,7 @@ def main(): result = 0 druid_cluster_name = "derby-druid" + namespace = sys.argv[1] druid_role_ports = { "broker": 8282, @@ -26,7 +27,9 @@ def main(): ) for role, port in druid_role_ports.items(): - url = f"https://{druid_cluster_name}-{role}-default-headless:{port}/status" + # Build FQDN for TLS/SNI validation + host = f"{druid_cluster_name}-{role}-default-headless.{namespace}.svc.cluster.local" + url = f"https://{host}:{port}/status" # make an authorized request -> return 401 expected logging.info(f"making unauthorized request to {role}.") res = requests.get(url, verify=False) diff --git a/tests/templates/kuttl/logging/test_log_aggregation.py b/tests/templates/kuttl/logging/test_log_aggregation.py index 5d5da3f4..eeefb504 100755 --- a/tests/templates/kuttl/logging/test_log_aggregation.py +++ b/tests/templates/kuttl/logging/test_log_aggregation.py @@ -23,9 +23,9 @@ def check_sent_events(): }, ) - assert ( - response.status_code == 200 - ), "Cannot access the API of the vector aggregator." + assert response.status_code == 200, ( + "Cannot access the API of the vector aggregator." + ) result = response.json() @@ -35,13 +35,13 @@ def check_sent_events(): componentId = transform["componentId"] if componentId == "filteredInvalidEvents": - assert ( - sentEvents is None or sentEvents["sentEventsTotal"] == 0 - ), "Invalid log events were sent." + assert sentEvents is None or sentEvents["sentEventsTotal"] == 0, ( + "Invalid log events were sent." + ) else: - assert ( - sentEvents is not None and sentEvents["sentEventsTotal"] > 0 - ), f'No events were sent in "{componentId}".' + assert sentEvents is not None and sentEvents["sentEventsTotal"] > 0, ( + f'No events were sent in "{componentId}".' + ) if __name__ == "__main__": diff --git a/tests/templates/kuttl/s3-deep-storage/12-assert.yaml b/tests/templates/kuttl/s3-deep-storage/12-assert.yaml index 49590839..a3ec6921 100644 --- a/tests/templates/kuttl/s3-deep-storage/12-assert.yaml +++ b/tests/templates/kuttl/s3-deep-storage/12-assert.yaml @@ -2,5 +2,5 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py druid-s3-deep-storage + - script: kubectl exec -n $NAMESPACE checks-0 -- python /tmp/ingestioncheck.py druid-s3-deep-storage $NAMESPACE timeout: 300