Skip to content

Commit

Permalink
rpm: simplify test case
Browse files Browse the repository at this point in the history
kafka related test case was extracted into confluent-test.sh.

Signed-off-by: Kentaro Hayashi <[email protected]>
  • Loading branch information
kenhys committed Jul 24, 2024
1 parent 2b7f1af commit 5fd347c
Showing 1 changed file with 4 additions and 60 deletions.
64 changes: 4 additions & 60 deletions fluent-package/yum/serverspec-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@ set -exu
distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f2)
version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f4)

ENABLE_SERVERSPEC_TEST=1
ENABLE_KAFKA_TEST=1
JAVA_JRE=java-21-openjdk-headless
N_POLLING=30
case ${distribution} in
amazon)
case ${version} in
2)
DNF=yum
DISTRIBUTION_VERSION=${version}
JAVA_JRE=java-17-amazon-corretto-headless
;;
2023)
DNF=dnf
DISTRIBUTION_VERSION=${version}
JAVA_JRE=java-21-amazon-corretto-headless
;;
esac
;;
Expand Down Expand Up @@ -73,57 +67,7 @@ ${DNF} install -y \

fluentd --version

if [ $ENABLE_SERVERSPEC_TEST -eq 1 ]; then
curl -V > /dev/null 2>&1 || ${DNF} install -y curl
${DNF} install -y which ${repositories_dir}/${distribution}/${DISTRIBUTION_VERSION}/x86_64/Packages/*.rpm

/usr/sbin/fluent-gem install --no-document serverspec
if [ $ENABLE_KAFKA_TEST -eq 1 ]; then
rpm --import https://packages.confluent.io/rpm/7.4/archive.key
cat >/etc/yum.repos.d/confluent.repo <<EOF;
[Confluent]
name=Confluent repository
baseurl=https://packages.confluent.io/rpm/7.6
gpgcheck=1
gpgkey=https://packages.confluent.io/rpm/7.6/archive.key
enabled=1
EOF
yum update -y && yum install -y confluent-community-2.13 ${JAVA_JRE} nc
export KAFKA_OPTS=-Dzookeeper.4lw.commands.whitelist=ruok
/usr/bin/zookeeper-server-start /etc/kafka/zookeeper.properties &
n=1
while true ; do
sleep 1
status=$(echo ruok | nc localhost 2181)
if [ "$status" = "imok" ]; then
break
fi
n=$((n + 1))
if [ $n -ge $N_POLLING ]; then
echo "failed to get response from zookeeper-server"
exit 1
fi
done
# Allow connection to kafka server
echo "listeners=PLAINTEXT://localhost:9092" | tee -a /etc/kafka/server.properties
/usr/bin/kafka-server-start /etc/kafka/server.properties &
n=1
while true ; do
sleep 1
status=$(/usr/bin/kafka-topics --bootstrap-server localhost:9092 --list)
if [ "$status" = "" ]; then
break
fi
n=$((n + 1))
if [ $n -ge $N_POLLING ]; then
echo "failed to get list of topics from kafka-server"
exit 1
fi
done
/usr/bin/kafka-topics --bootstrap-server localhost:9092 --topic test --create --replication-factor 1 --partitions 1
/usr/sbin/fluentd -c /fluentd/serverspec/test.conf &
fi
export PATH=/opt/fluent/bin:$PATH
export INSTALLATION_TEST=true
cd /fluentd && rake serverspec:linux
fi
/usr/sbin/fluent-gem install --no-document serverspec
export PATH=/opt/fluent/bin:$PATH
export INSTALLATION_TEST=true
cd /fluentd && rake serverspec:linux

0 comments on commit 5fd347c

Please sign in to comment.