Skip to content

Commit 2054f2d

Browse files
authored
test: Use bootstrap listener from discovery ConfigMap in tls test (#780)
1 parent 2d5584a commit 2054f2d

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

tests/templates/kuttl/tls/30_test_client_auth_tls.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env bash
22
# Usage: test_client_auth_tls.sh namespace
33

4-
NAMESPACE=$1
5-
64
# to be safe
75
unset TOPIC
86
unset BAD_TOPIC
97

10-
SERVER="test-kafka-broker-default-0.test-kafka-broker-default.${NAMESPACE}.svc.cluster.local:9093"
8+
echo "Connecting to boostrap address $KAFKA"
119

1210
echo "Start client auth TLS testing..."
1311
############################################################################
@@ -20,15 +18,15 @@ BAD_TOPIC=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20 ; echo '')
2018
# write client config
2119
echo $'security.protocol=SSL\nssl.keystore.location=/stackable/tls_keystore_server/keystore.p12\nssl.keystore.password=\nssl.truststore.location=/stackable/tls_keystore_server/truststore.p12\nssl.truststore.password=' > /tmp/client.config
2220

23-
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$TOPIC" --bootstrap-server "$SERVER" --command-config /tmp/client.config
21+
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$TOPIC" --bootstrap-server "$KAFKA" --command-config /tmp/client.config
2422
then
2523
echo "[SUCCESS] Secure client topic created!"
2624
else
2725
echo "[ERROR] Secure client topic creation failed!"
2826
exit 1
2927
fi
3028

31-
if /stackable/kafka/bin/kafka-topics.sh --list --topic "$TOPIC" --bootstrap-server "$SERVER" --command-config /tmp/client.config | grep "$TOPIC"
29+
if /stackable/kafka/bin/kafka-topics.sh --list --topic "$TOPIC" --bootstrap-server "$KAFKA" --command-config /tmp/client.config | grep "$TOPIC"
3230
then
3331
echo "[SUCCESS] Secure client topic read!"
3432
else
@@ -39,7 +37,7 @@ fi
3937
############################################################################
4038
# Test the connection without certificates
4139
############################################################################
42-
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$BAD_TOPIC" --bootstrap-server "$SERVER" &> /dev/null
40+
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$BAD_TOPIC" --bootstrap-server "$KAFKA" &> /dev/null
4341
then
4442
echo "[ERROR] Secure client topic created without certificates!"
4543
exit 1
@@ -62,7 +60,7 @@ fi
6260
# Test the connection with bad certificate
6361
############################################################################
6462
echo $'security.protocol=SSL\nssl.keystore.location=/tmp/wrong_keystore.p12\nssl.keystore.password=changeit\nssl.truststore.location=/tmp/wrong_truststore.p12\nssl.truststore.password=changeit' > /tmp/client.config
65-
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$BAD_TOPIC" --bootstrap-server "$SERVER" --command-config /tmp/client.config &> /dev/null
63+
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$BAD_TOPIC" --bootstrap-server "$KAFKA" --command-config /tmp/client.config &> /dev/null
6664
then
6765
echo "[ERROR] Secure client topic created with wrong certificate!"
6866
exit 1

tests/templates/kuttl/tls/30_test_client_tls.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env bash
22
# Usage: test_client_tls.sh namespace
33

4-
NAMESPACE=$1
5-
64
# to be safe
75
unset TOPIC
86
unset BAD_TOPIC
97

10-
SERVER="test-kafka-broker-default-0.test-kafka-broker-default.${NAMESPACE}.svc.cluster.local:9093"
8+
echo "Connecting to boostrap address $KAFKA"
119

1210
echo "Start client TLS testing..."
1311
############################################################################
@@ -20,15 +18,15 @@ BAD_TOPIC=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20 ; echo '')
2018
# write client config
2119
echo $'security.protocol=SSL\nssl.truststore.location=/stackable/tls_keystore_server/truststore.p12\nssl.truststore.password=' > /tmp/client.config
2220

23-
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$TOPIC" --bootstrap-server "$SERVER" --command-config /tmp/client.config
21+
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$TOPIC" --bootstrap-server "$KAFKA" --command-config /tmp/client.config
2422
then
2523
echo "[SUCCESS] Secure client topic created!"
2624
else
2725
echo "[ERROR] Secure client topic creation failed!"
2826
exit 1
2927
fi
3028

31-
if /stackable/kafka/bin/kafka-topics.sh --list --topic "$TOPIC" --bootstrap-server "$SERVER" --command-config /tmp/client.config | grep "$TOPIC"
29+
if /stackable/kafka/bin/kafka-topics.sh --list --topic "$TOPIC" --bootstrap-server "$KAFKA" --command-config /tmp/client.config | grep "$TOPIC"
3230
then
3331
echo "[SUCCESS] Secure client topic read!"
3432
else
@@ -39,7 +37,7 @@ fi
3937
############################################################################
4038
# Test the connection without certificates
4139
############################################################################
42-
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$BAD_TOPIC" --bootstrap-server "$SERVER" &> /dev/null
40+
if /stackable/kafka/bin/kafka-topics.sh --create --topic "$BAD_TOPIC" --bootstrap-server "$KAFKA" &> /dev/null
4341
then
4442
echo "[ERROR] Secure client topic created without certificates!"
4543
exit 1

tests/templates/kuttl/tls/31_test-tls-job.yaml.j2

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ spec:
1313
{% if test_scenario['values']['use-client-auth-tls'] == 'true' %}
1414
command:
1515
- ./test_client_auth_tls.sh
16-
args:
17-
- ${NAMESPACE}
1816
{% elif test_scenario['values']['use-client-tls'] == 'true' %}
1917
command:
2018
- ./test_client_tls.sh
21-
args:
22-
- ${NAMESPACE}
2319
{% else %}
2420
command:
2521
- "true"
2622
{% endif %}
23+
env:
24+
- name: KAFKA
25+
valueFrom:
26+
configMapKeyRef:
27+
name: test-kafka
28+
key: KAFKA
2729
volumeMounts:
2830
- name: test-scripts
2931
mountPath: /stackable/test

0 commit comments

Comments
 (0)