From 39f2962a8a9d284904a72a817a3d8e22032f6fa6 Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Wed, 10 Apr 2024 14:46:15 +0900 Subject: [PATCH] ci deb: extract confluent test case Signed-off-by: Kentaro Hayashi --- .github/workflows/apt.yml | 1 + fluent-package/apt/confluent-test.sh | 64 +++++++++++++++++++++++++++ fluent-package/apt/serverspec-test.sh | 49 +------------------- 3 files changed, 66 insertions(+), 48 deletions(-) create mode 100755 fluent-package/apt/confluent-test.sh diff --git a/.github/workflows/apt.yml b/.github/workflows/apt.yml index be57d9324..027d6ff25 100644 --- a/.github/workflows/apt.yml +++ b/.github/workflows/apt.yml @@ -116,6 +116,7 @@ jobs: - "install-newly.sh local" - "install-newly.sh v5" - "install-newly.sh lts" + - "confluent-test.sh" include: - label: Debian GNU/Linux bullseye amd64 rake-job: debian-bullseye diff --git a/fluent-package/apt/confluent-test.sh b/fluent-package/apt/confluent-test.sh new file mode 100755 index 000000000..36162db44 --- /dev/null +++ b/fluent-package/apt/confluent-test.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +set -exu + +export DEBIAN_FRONTEND=noninteractive + +apt update +apt install -V -y lsb-release + +. $(dirname $0)/commonvar.sh + +apt install -V -y \ + ${repositories_dir}/${distribution}/pool/${code_name}/${channel}/*/*/*_${architecture}.deb + +fluentd --version + +case ${code_name} in + xenial) + apt install -V -y gnupg2 wget apt-transport-https + ;; + *) + apt install -V -y gnupg2 wget + ;; +esac + +/usr/sbin/fluent-gem install --no-document serverspec +wget https://packages.confluent.io/deb/7.6/archive.key +gpg2 --homedir /tmp --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/confluent-archive-keyring.gpg --import archive.key +chmod 644 /usr/share/keyrings/confluent-archive-keyring.gpg +echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/confluent-archive-keyring.gpg] https://packages.confluent.io/deb/7.6 stable main" > /etc/apt/sources.list.d/confluent.list +apt update && apt install -y confluent-community-2.13 ${java_jdk} netcat-openbsd + +export KAFKA_OPTS=-Dzookeeper.4lw.commands.whitelist=ruok +/usr/bin/zookeeper-server-start /etc/kafka/zookeeper.properties & +N_POLLING=30 +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 +/usr/bin/kafka-server-start /etc/kafka/server.properties & +n=1 +while true ; do + sleep 1 + status=$(/usr/bin/zookeeper-shell localhost:2181 ls /brokers/ids | sed -n 6p) + if [ "$status" = "[0]" ]; then + break + fi + n=$((n + 1)) + if [ $n -ge $N_POLLING ]; then + echo "failed to get response from kafka-server" + exit 1 + fi +done +/usr/bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test +/usr/sbin/fluentd -c /fluentd/serverspec/test.conf & diff --git a/fluent-package/apt/serverspec-test.sh b/fluent-package/apt/serverspec-test.sh index 8bfe9d6c7..9258d6df6 100755 --- a/fluent-package/apt/serverspec-test.sh +++ b/fluent-package/apt/serverspec-test.sh @@ -14,54 +14,7 @@ apt install -V -y \ fluentd --version -case ${code_name} in - xenial) - apt install -V -y gnupg2 wget apt-transport-https - ;; - *) - apt install -V -y gnupg2 wget - ;; -esac - -/usr/sbin/fluent-gem install --no-document serverspec -wget https://packages.confluent.io/deb/6.0/archive.key -gpg2 --homedir /tmp --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/confluent-archive-keyring.gpg --import archive.key -chmod 644 /usr/share/keyrings/confluent-archive-keyring.gpg -echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/confluent-archive-keyring.gpg] https://packages.confluent.io/deb/6.0 stable main" > /etc/apt/sources.list.d/confluent.list -apt update && apt install -y confluent-community-2.13 ${java_jdk} netcat-openbsd - -export KAFKA_OPTS=-Dzookeeper.4lw.commands.whitelist=ruok -/usr/bin/zookeeper-server-start /etc/kafka/zookeeper.properties & -N_POLLING=30 -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 -/usr/bin/kafka-server-start /etc/kafka/server.properties & -n=1 -while true ; do - sleep 1 - status=$(/usr/bin/zookeeper-shell localhost:2181 ls /brokers/ids | sed -n 6p) - if [ "$status" = "[0]" ]; then - break - fi - n=$((n + 1)) - if [ $n -ge $N_POLLING ]; then - echo "failed to get response from kafka-server" - exit 1 - fi -done -/usr/bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test -/usr/sbin/fluentd -c /fluentd/serverspec/test.conf & export PATH=/opt/fluent/bin:$PATH export INSTALLATION_TEST=true +/usr/sbin/fluent-gem install --no-document serverspec cd /fluentd && rake serverspec:linux