Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/templates/kuttl/authorizer/06-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 14 additions & 7 deletions tests/templates/kuttl/authorizer/authcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
21 changes: 15 additions & 6 deletions tests/templates/kuttl/commons/ingestioncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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"]
Expand All @@ -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}")
Expand All @@ -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}]")
Expand All @@ -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")
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/templates/kuttl/hdfs-deep-storage/06-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/templates/kuttl/ingestion-no-s3-ext/06-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/templates/kuttl/ingestion-s3-ext/06-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/templates/kuttl/ldap/20-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion tests/templates/kuttl/ldap/authcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def main():
result = 0

druid_cluster_name = "derby-druid"
namespace = sys.argv[1]

druid_role_ports = {
"broker": 8282,
Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions tests/templates/kuttl/logging/test_log_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion tests/templates/kuttl/s3-deep-storage/12-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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