Skip to content

Commit

Permalink
fix: kafkacat is called with kcat, shellcheck formatting (#6887)
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms authored Aug 6, 2024
1 parent acef485 commit c247927
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions ci/tasks/galoy-deps-smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ set -eu

source smoketest-settings/helpers.sh

kafka_broker_host=`setting "kafka_broker_endpoint"`
kafka_broker_port=`setting "kafka_broker_port"`
kafka_topic=`setting "smoketest_topic"`
kafka_broker_host=$(setting "kafka_broker_endpoint")
kafka_broker_port=$(setting "kafka_broker_port")
kafka_topic=$(setting "smoketest_topic")
kafka_service_name_prefix="kafka-kafka-plain"
kafka_namespace=`setting "kafka_namespace"`
setting "smoketest_kubeconfig" | base64 --decode > kubeconfig.json
kafka_namespace=$(setting "kafka_namespace")
setting "smoketest_kubeconfig" | base64 --decode >kubeconfig.json
export KUBECONFIG=$(pwd)/kubeconfig.json

cat <<EOF > topic.tf
cat <<EOF >topic.tf
provider "kafka" {
bootstrap_servers = [
"${kafka_service_name_prefix}-0.${kafka_namespace}:9092",
Expand All @@ -32,15 +32,14 @@ terraform {
}
resource "kafka_topic" "smoketest_topic" {
name = "${kafka_topic}"
replication_factor = 3
partitions = 3
name = "${kafka_topic}"
replication_factor = 3
partitions = 3
}
EOF

set +e
for i in 1 2 3
do
for i in 1 2 3; do
kubectl -n $kafka_namespace wait --for=condition=Ready pod -l strimzi.io/component-type=kafka && break
sleep 5
done
Expand All @@ -49,23 +48,25 @@ set -e
terraform init

set +e
for i in 1 2 3
do
for i in 1 2 3; do
terraform apply -auto-approve && break
sleep 5
done

msg="kafka message"
for i in {1..15}; do
echo "Attempt ${i} to produce and consume from kafka"
echo $msg | kafkacat -P -b $kafka_broker_host:$kafka_broker_port -t $kafka_topic
consumed_message=$(kafkacat -C -b $kafka_broker_host:$kafka_broker_port -t $kafka_topic -e)
if [[ "$consumed_message" == "$msg" ]]; then success="true"; break; fi;
echo $msg | kcat -P -b $kafka_broker_host:$kafka_broker_port -t $kafka_topic
consumed_message=$(kcat -C -b $kafka_broker_host:$kafka_broker_port -t $kafka_topic -e)
if [[ "$consumed_message" == "$msg" ]]; then
success="true"
break
fi
sleep 1
done

terraform destroy -auto-approve

if [[ "$success" != "true" ]]; then echo "Smoke test failed" && exit 1; fi;
if [[ "$success" != "true" ]]; then echo "Smoke test failed" && exit 1; fi

set -e

0 comments on commit c247927

Please sign in to comment.