Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Refactored and renamed in prep for @cnadolny's PR. (#7)
Browse files Browse the repository at this point in the history
* Refactored and renamed in prep for @cnadolny's PR.
* Moved client helpers to a different folder to distinguish them from local tests scripts.
  • Loading branch information
sayar authored Jul 30, 2019
1 parent 21f3c92 commit 6aa4229
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 30 deletions.
28 changes: 0 additions & 28 deletions perftest/setup_ssl.sh → test/client_helpers/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 32 additions & 0 deletions test/client_helpers/perftest_ssl.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions perftest/perftest.sh → test/perftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 6aa4229

Please sign in to comment.