diff --git a/perftest/setup_ssl.sh b/test/client_helpers/common.sh similarity index 53% rename from perftest/setup_ssl.sh rename to test/client_helpers/common.sh index d5e0ca1..c88f7dc 100644 --- a/perftest/setup_ssl.sh +++ b/test/client_helpers/common.sh @@ -35,31 +35,3 @@ function create_keystore { fi RANDFILE=/tmp/.rnd openssl pkcs12 -export -in "$3" -inkey "$4" -name "$HOSTNAME" -password "pass:$2" -out "$1" } - -if [ "$CA_CRT" ]; -then - echo "Preparing truststore" - TRUSTSTORE_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32) - echo "$CA_CRT" > /tmp/ca.crt - create_truststore /opt/kafka/truststore.p12 "$TRUSTSTORE_PASSWORD" /tmp/ca.crt ca -fi - -if [[ "$USER_CRT" && "$USER_KEY" ]]; -then - echo "Preparing keystore" - KEYSTORE_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32) - echo "$USER_CRT" > /tmp/user.crt - echo "$USER_KEY" > /tmp/user.key - create_keystore /opt/kafka/keystore.p12 "$KEYSTORE_PASSWORD" /tmp/user.crt /tmp/user.key /tmp/ca.crt "$HOSTNAME" -fi - -cat << EOF > /opt/kafka/config/ssl-config.properties -security.protocol=SSL -ssl.truststore.location=/opt/kafka/truststore.p12 -ssl.truststore.password=$TRUSTSTORE_PASSWORD -ssl.truststore.type=PKCS12 -ssl.keystore.location=/opt/kafka/keystore.p12 -ssl.keystore.password=$KEYSTORE_PASSWORD -ssl.keystore.type=PKCS12 -ssl.key.password=$KEYSTORE_PASSWORD -EOF \ No newline at end of file diff --git a/test/client_helpers/perftest_ssl.sh b/test/client_helpers/perftest_ssl.sh new file mode 100644 index 0000000..853c1d2 --- /dev/null +++ b/test/client_helpers/perftest_ssl.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set +x + +source ./common.sh + +if [ "$CA_CRT" ]; +then + echo "Preparing truststore" + TRUSTSTORE_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32) + echo "$CA_CRT" > /tmp/ca.crt + create_truststore /opt/kafka/truststore.p12 "$TRUSTSTORE_PASSWORD" /tmp/ca.crt ca +fi + +if [[ "$USER_CRT" && "$USER_KEY" ]]; +then + echo "Preparing keystore" + KEYSTORE_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32) + echo "$USER_CRT" > /tmp/user.crt + echo "$USER_KEY" > /tmp/user.key + create_keystore /opt/kafka/keystore.p12 "$KEYSTORE_PASSWORD" /tmp/user.crt /tmp/user.key /tmp/ca.crt "$HOSTNAME" +fi + +cat << EOF > /opt/kafka/config/ssl-config.properties +security.protocol=SSL +ssl.truststore.location=/opt/kafka/truststore.p12 +ssl.truststore.password=$TRUSTSTORE_PASSWORD +ssl.truststore.type=PKCS12 +ssl.keystore.location=/opt/kafka/keystore.p12 +ssl.keystore.password=$KEYSTORE_PASSWORD +ssl.keystore.type=PKCS12 +ssl.key.password=$KEYSTORE_PASSWORD +EOF diff --git a/perftest/kafka-client.yaml b/test/kafka-client.yaml similarity index 100% rename from perftest/kafka-client.yaml rename to test/kafka-client.yaml diff --git a/perftest/kafka-topics.yaml b/test/kafka-topics.yaml similarity index 100% rename from perftest/kafka-topics.yaml rename to test/kafka-topics.yaml diff --git a/perftest/kafka-users.yaml b/test/kafka-users.yaml similarity index 100% rename from perftest/kafka-users.yaml rename to test/kafka-users.yaml diff --git a/perftest/perftest.sh b/test/perftest.sh similarity index 96% rename from perftest/perftest.sh rename to test/perftest.sh index 57f8515..2221bcb 100755 --- a/perftest/perftest.sh +++ b/test/perftest.sh @@ -31,8 +31,9 @@ sleep 5s setup_kafka_client_ssl () { echo "Setting Up Kafka Client for SSL" for i in $(seq 0 2); do # End Number is replication factor of kafka client - 1 - kubectl cp ./setup_ssl.sh "kafka/kafkaclient-$i:/opt/kafka/setup_ssl.sh" - kubectl exec -n kafka -it "kafkaclient-$i" -- bash setup_ssl.sh + kubectl cp ./client_helpers/common.sh "kafka/kafkaclient-$i:/opt/kafka/" + kubectl cp ./client_helpers/perftest_ssl.sh "kafka/kafkaclient-$i:/opt/kafka/" + kubectl exec -n kafka -it "kafkaclient-$i" -- bash perftest_ssl.sh done }