diff options
Diffstat (limited to 'src/fluent-bit/packaging/testing/smoke')
18 files changed, 828 insertions, 0 deletions
diff --git a/src/fluent-bit/packaging/testing/smoke/container/container-smoke-test.sh b/src/fluent-bit/packaging/testing/smoke/container/container-smoke-test.sh new file mode 100755 index 000000000..4ab03c917 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/container/container-smoke-test.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# Copyright 2021 Calyptia, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eux +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# Simple smoke test script of each local container architecture that runs up and then +# ensure we can access the web server. + +CONTAINER_NAME=${CONTAINER_NAME:-smoke-test} + +# Ensure the container name is valid as we need this to retrieve the exposed ports. +CONTAINER_NAME=${CONTAINER_NAME//\//-} +CONTAINER_ARCH=${CONTAINER_ARCH:-linux/amd64} +REGISTRY=${REGISTRY:-ghcr.io} +IMAGE_NAME=${IMAGE_NAME:-fluent/fluent-bit} +IMAGE_TAG=${IMAGE_TAG:-latest} + +# Remove any existing container +docker rm -f "$CONTAINER_NAME" + +# Repeat for YAML and legacy config - note the config file extension is important for format detection +declare -a CONFIG_FILES=("fluent-bit.conf" "fluent-bit.yaml") + +for CONFIG_FILE in "${CONFIG_FILES[@]}" +do + if [[ ! -f "$SCRIPT_DIR/$CONFIG_FILE" ]]; then + echo "Missing config file: $SCRIPT_DIR/$CONFIG_FILE" + exit 1 + fi + + echo "Testing: $CONFIG_FILE" + + # Run up the container + docker run --name "$CONTAINER_NAME" -d \ + --platform "$CONTAINER_ARCH" \ + --pull=always \ + --publish-all \ + --restart=no \ + -v "$SCRIPT_DIR/$CONFIG_FILE":"/fluent-bit/etc/$CONFIG_FILE":ro \ + "$REGISTRY/$IMAGE_NAME:$IMAGE_TAG" \ + "/fluent-bit/bin/fluent-bit" "-c" "/fluent-bit/etc/$CONFIG_FILE" + + # Get debug details + docker image inspect "$REGISTRY/$IMAGE_NAME:$IMAGE_TAG" + + # Stream the logs live + docker logs -f "$CONTAINER_NAME" & + + # # Wait for the container to start up as we have to pull it + until [[ $(docker ps --filter "status=running" --filter "name=$CONTAINER_NAME" --quiet | wc -l) -gt 0 ]] ; do + sleep 2 + done + docker ps + # Grab the ephemeral port + docker container inspect "$CONTAINER_NAME" + LOCAL_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "2020/tcp") 0).HostPort}}' "$CONTAINER_NAME") + # Allow to run for a bit + sleep 60 + docker ps + docker logs "$CONTAINER_NAME" + # Check we are still ok + curl -v localhost:"$LOCAL_PORT" | jq + curl -v localhost:"$LOCAL_PORT"/api/v1/metrics | jq + curl -v localhost:"$LOCAL_PORT"/api/v1/uptime | jq + curl -v localhost:"$LOCAL_PORT"/api/v1/health + + # Clean up + docker rm -f "$CONTAINER_NAME" +done diff --git a/src/fluent-bit/packaging/testing/smoke/container/fluent-bit.conf b/src/fluent-bit/packaging/testing/smoke/container/fluent-bit.conf new file mode 100644 index 000000000..5b987bc22 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/container/fluent-bit.conf @@ -0,0 +1,31 @@ +[SERVICE] + HTTP_Server On + HTTP_Listen 0.0.0.0 + HTTP_PORT 2020 + Health_Check On + HC_Errors_Count 5 + HC_Retry_Failure_Count 5 + HC_Period 5 + Log_level debug + +[INPUT] + Name random + Tag test + Samples 10 + +[FILTER] + Name Lua + Match * + call append_tag + code function append_tag(tag, timestamp, record) new_record = record new_record["tag"] = tag return 1, timestamp, new_record end + +[FILTER] + Name Expect + Match * + key_exists tag + key_val_eq tag test + action exit + +[OUTPUT] + Name stdout + Match *
\ No newline at end of file diff --git a/src/fluent-bit/packaging/testing/smoke/container/fluent-bit.yaml b/src/fluent-bit/packaging/testing/smoke/container/fluent-bit.yaml new file mode 100644 index 000000000..69167e0b4 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/container/fluent-bit.yaml @@ -0,0 +1,33 @@ +--- +# Translated according to https://github.com/fluent/fluent-bit/pull/4621 +service: + http_server: "on" + Health_Check: "on" + log_level: debug + +pipeline: + inputs: + - name: random + tag: test + samples: 10 + + filters: + - name: lua + match: test + call: append_tag + code: | + function append_tag(tag, timestamp, record) + new_record = record + new_record["tag"] = tag + return 1, timestamp, new_record + end + + - name: expect + match: test + key_exists: tag + key_val_eq: tag test + action: exit + + outputs: + - name: stdout + match: test diff --git a/src/fluent-bit/packaging/testing/smoke/k8s/k8s-smoke-test.sh b/src/fluent-bit/packaging/testing/smoke/k8s/k8s-smoke-test.sh new file mode 100755 index 000000000..e7e42a0da --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/k8s/k8s-smoke-test.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright 2021 Calyptia, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eux + +# Simple smoke test script using helm deployment to run up a deployment then +# ensure we can access the web server. +# Assumes a kubectl context is set up already, e.g. `kind create cluster` + +NAMESPACE=${NAMESPACE:-default} +REGISTRY=${REGISTRY:-ghcr.io} +IMAGE_NAME=${IMAGE_NAME:-fluent/fluent-bit} +IMAGE_TAG=${IMAGE_TAG:-latest} + +# Deploy using Helm chart +helm repo add fluent-bit https://fluent.github.io/helm-charts || helm repo add fluent-bit https://fluent.github.io/helm-charts/ +helm repo update +helm upgrade --install fluent-bit fluent-bit/fluent-bit \ + --namespace "$NAMESPACE" --create-namespace \ + --wait \ + --set kind=Deployment \ + --set replicaCount=1 \ + --set image.repository="$REGISTRY/$IMAGE_NAME" \ + --set image.tag="$IMAGE_TAG" + +# Output some information on pods running +kubectl describe -n "$NAMESPACE" pods --selector='app.kubernetes.io/name=fluent-bit' + +while true; do + # Find a free ephemeral port to use for port forwarding + FREE_PORTNUM=$(shuf -i 1025-65535 -n 1) + if ! lsof -Pi ":$FREE_PORTNUM" -sTCP:LISTEN; then + # Forward to the deployment web server port + kubectl port-forward -n "$NAMESPACE" deployment/fluent-bit "$FREE_PORTNUM":2020 & + PF_PID=$! + # Wait a bit + sleep 60 + # Provide debug output in case it is required + kubectl describe -n "$NAMESPACE" pods --selector='app.kubernetes.io/name=fluent-bit' + # Check we are still functional + curl -v localhost:"$FREE_PORTNUM" | jq + curl -v localhost:"$FREE_PORTNUM"/api/v1/metrics | jq + curl -v localhost:"$FREE_PORTNUM"/api/v1/uptime | jq + curl -v localhost:"$FREE_PORTNUM"/api/v1/health + kill -9 $PF_PID + exit 0 + fi +done +echo "Unable to find free port" +exit 1
\ No newline at end of file diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.amazonlinux2 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.amazonlinux2 new file mode 100644 index 000000000..c9025da61 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.amazonlinux2 @@ -0,0 +1,46 @@ +# For staging upgrade we use the 'staging-upgrade-prep' as the base +ARG STAGING_BASE=docker.io/dokken/amazonlinux-2 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/amazonlinux-2 as official-install + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/yum.repos.d/*-bit.repo + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +# hadolint ignore=DL3032 +RUN rpm --import "$FLUENT_BIT_PACKAGES_KEY" && \ + wget -q "$FLUENT_BIT_PACKAGES_URL/amazonlinux-2.repo" -O /etc/yum.repos.d/staging.repo && \ + yum update -y && yum install -y fluent-bit && \ + systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.amazonlinux2022 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.amazonlinux2022 new file mode 100644 index 000000000..7e62b4cf1 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.amazonlinux2022 @@ -0,0 +1,46 @@ +# For staging upgrade we use the 'staging-upgrade-prep' as the base +ARG STAGING_BASE=docker.io/dokken/amazonlinux-2022 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/amazonlinux-2022 as official-install + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/yum.repos.d/*-bit.repo + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +# hadolint ignore=DL3032 +RUN rpm --import "$FLUENT_BIT_PACKAGES_KEY" && \ + wget -q "$FLUENT_BIT_PACKAGES_URL/amazonlinux-2022.repo" -O /etc/yum.repos.d/staging.repo && \ + yum update -y && yum install -y fluent-bit && \ + systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos7 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos7 new file mode 100644 index 000000000..6ef5d3821 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos7 @@ -0,0 +1,47 @@ +# For staging upgrade we use the 'staging-upgrade-prep' as the base +ARG STAGING_BASE=docker.io/dokken/centos-7 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/centos-7 as official-install + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# Use the one-line install +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/yum.repos.d/*-bit.repo + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +RUN rpm --import "$FLUENT_BIT_PACKAGES_KEY" && \ + wget -nv "$FLUENT_BIT_PACKAGES_URL/centos-7.repo" -O /etc/yum.repos.d/staging.repo +# hadolint ignore=DL3032 +RUN yum update -y && yum install -y fluent-bit && \ + systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos8 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos8 new file mode 100644 index 000000000..6b103bba0 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos8 @@ -0,0 +1,53 @@ +# For staging upgrade we use the 'staging-upgrade-prep' as the base +ARG STAGING_BASE=docker.io/dokken/centos-8 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/centos-8 as official-install +# CentOS is now EOL so have to use the vault repos +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \ + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/yum.repos.d/*-bit.repo + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +# CentOS is now EOL so have to use the vault repos +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \ + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +RUN rpm --import "$FLUENT_BIT_PACKAGES_KEY" && \ + wget -nv "$FLUENT_BIT_PACKAGES_URL/centos-8.repo" -O /etc/yum.repos.d/staging.repo +# hadolint ignore=DL3032 +RUN yum update -y && yum install -y fluent-bit && \ + systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos9 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos9 new file mode 100644 index 000000000..008439bc8 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.centos9 @@ -0,0 +1,45 @@ +# For staging upgrade we use the 'staging-upgrade-prep' as the base +ARG STAGING_BASE=docker.io/dokken/centos-stream-9 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/centos-stream-9 as official-install +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/yum.repos.d/*-bit.repo + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +RUN rpm --import "$FLUENT_BIT_PACKAGES_KEY" && \ + wget -nv "$FLUENT_BIT_PACKAGES_URL/centos-9.repo" -O /etc/yum.repos.d/staging.repo +# hadolint ignore=DL3032 +RUN yum update -y && yum install -y fluent-bit && \ + systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian10 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian10 new file mode 100644 index 000000000..484a351bc --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian10 @@ -0,0 +1,48 @@ +# For staging upgrade we use the 'official-install' as the base +ARG STAGING_BASE=docker.io/dokken/debian-10 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/debian-10 as official-install + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +# Use the one-line install +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/apt/sources.list.d/fluent-bit.list + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN wget -qO - $FLUENT_BIT_PACKAGES_KEY | apt-key add - +RUN echo "deb $FLUENT_BIT_PACKAGES_URL/debian/buster buster main" >> /etc/apt/sources.list +# hadolint ignore=DL3015,DL3008,DL3009 +RUN apt-get update && apt-get install -y fluent-bit +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian11 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian11 new file mode 100644 index 000000000..b1cf7f815 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian11 @@ -0,0 +1,47 @@ +# For staging upgrade we use the 'official-install' as the base +ARG STAGING_BASE=docker.io/dokken/debian-11 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/debian-11 as official-install + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/apt/sources.list.d/fluent-bit.list + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN wget -qO - $FLUENT_BIT_PACKAGES_KEY | apt-key add - +RUN echo "deb $FLUENT_BIT_PACKAGES_URL/debian/bullseye bullseye main" >> /etc/apt/sources.list +# hadolint ignore=DL3015,DL3008,DL3009 +RUN apt-get update && apt-get install -y fluent-bit +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian12 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian12 new file mode 100644 index 000000000..2944d6883 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.debian12 @@ -0,0 +1,47 @@ +# For staging upgrade we use the 'official-install' as the base +ARG STAGING_BASE=docker.io/dokken/debian-12 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/debian-12 as official-install + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/apt/sources.list.d/fluent-bit.list + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN wget -qO - $FLUENT_BIT_PACKAGES_KEY | apt-key add - +RUN echo "deb $FLUENT_BIT_PACKAGES_URL/debian/bookworm bookworm main" >> /etc/apt/sources.list +# hadolint ignore=DL3015,DL3008,DL3009 +RUN apt-get update && apt-get install -y fluent-bit +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu1804 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu1804 new file mode 100644 index 000000000..b7fa3db25 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu1804 @@ -0,0 +1,50 @@ +# For staging upgrade we use the 'official-install' as the base +ARG STAGING_BASE=docker.io/dokken/ubuntu-18.04 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/ubuntu-18.04 as official-install +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +# Use the one-line install +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/apt/sources.list.d/fluent-bit.list + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install + +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN wget -qO - $FLUENT_BIT_PACKAGES_KEY | apt-key add - +RUN echo "deb $FLUENT_BIT_PACKAGES_URL/ubuntu/bionic bionic main" >> /etc/apt/sources.list +# hadolint ignore=DL3015,DL3008,DL3009 +RUN apt-get update && apt-get install -y fluent-bit +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu2004 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu2004 new file mode 100644 index 000000000..0099d3ea6 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu2004 @@ -0,0 +1,48 @@ +# For staging upgrade we use the 'official-install' as the base +ARG STAGING_BASE=docker.io/dokken/ubuntu-20.04 + +ARG RELEASE_URL=https://packages.fluentbit.io +ARG RELEASE_KEY=https://packages.fluentbit.io/fluentbit.key + +# hadolint ignore=DL3006 +FROM docker.io/dokken/ubuntu-20.04 as official-install +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ARG RELEASE_URL +ENV FLUENT_BIT_PACKAGES_URL=${RELEASE_URL} + +ARG RELEASE_KEY +ENV FLUENT_BIT_PACKAGES_KEY=${RELEASE_KEY} + +# Use the one-line install +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/apt/sources.list.d/fluent-bit.list + +# hadolint ignore=DL3006 +FROM ${STAGING_BASE} as staging-install +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} + +ARG STAGING_URL +ENV FLUENT_BIT_PACKAGES_URL=${STAGING_URL} + +ARG STAGING_KEY=${STAGING_URL}/fluentbit.key +ENV FLUENT_BIT_PACKAGES_KEY=${STAGING_KEY} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN wget -qO - $FLUENT_BIT_PACKAGES_KEY | apt-key add - +RUN echo "deb $FLUENT_BIT_PACKAGES_URL/ubuntu/focal focal main" >> /etc/apt/sources.list +# hadolint ignore=DL3015,DL3008,DL3009 +RUN apt-get update && apt-get install -y fluent-bit +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu2204 b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu2204 new file mode 100644 index 000000000..71edff7af --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/Dockerfile.ubuntu2204 @@ -0,0 +1,34 @@ +# For staging upgrade we use the 'official-install' as the base + +# hadolint ignore=DL3007 +FROM docker.io/dokken/ubuntu-22.04:latest as official-install +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# Use the one-line install +RUN curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +FROM official-install as staging-upgrade-prep +RUN rm -f /etc/apt/sources.list.d/fluent-bit.list + +# hadolint ignore=DL3007 +FROM docker.io/dokken/ubuntu-22.04:latest as staging-install +ARG STAGING_URL +ARG STAGING_VERSION +ENV STAGING_VERSION=${STAGING_VERSION} +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN wget -qO - $STAGING_URL/fluentbit.key | apt-key add - +RUN echo "deb $STAGING_URL/ubuntu/jammy jammy main" >> /etc/apt/sources.list +# hadolint ignore=DL3008 +RUN apt-get update && apt-get install --no-install-recommends -y fluent-bit \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +RUN systemctl enable fluent-bit + +COPY ./test.sh /test.sh +RUN chmod a+x /test.sh + +# hadolint ignore=DL3007 +FROM staging-install as staging-upgrade diff --git a/src/fluent-bit/packaging/testing/smoke/packages/local-test-all.sh b/src/fluent-bit/packaging/testing/smoke/packages/local-test-all.sh new file mode 100755 index 000000000..3c596aed9 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/local-test-all.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -eux +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# Simple script to test all supported targets easily. + +RELEASE_URL=${RELEASE_URL:-https://packages.fluentbit.io} +STAGING_URL=${STAGING_URL:-https://fluentbit-staging.s3.amazonaws.com} + +for DOCKERFILE in "$SCRIPT_DIR"/Dockerfile.*; do + DISTRO=${DOCKERFILE##*.} + echo "Testing $DISTRO" + PACKAGE_TEST="$DISTRO" RELEASE_URL="$RELEASE_URL" STAGING_URL="$STAGING_URL" "$SCRIPT_DIR"/run-package-tests.sh +done
\ No newline at end of file diff --git a/src/fluent-bit/packaging/testing/smoke/packages/run-package-tests.sh b/src/fluent-bit/packaging/testing/smoke/packages/run-package-tests.sh new file mode 100755 index 000000000..e51569f79 --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/run-package-tests.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# Copyright 2021 Calyptia, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eux +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +PACKAGE_TEST=${PACKAGE_TEST:-centos7} +RELEASE_URL=${RELEASE_URL:-https://packages.fluentbit.io} +RELEASE_KEY=${RELEASE_KEY:-https://packages.fluentbit.io/fluentbit.key} +STAGING_URL=${STAGING_URL:-https://fluentbit-staging.s3.amazonaws.com} +STAGING_KEY=${STAGING_KEY:-https://fluentbit-staging.s3.amazonaws.com/fluentbit.key} + +# Podman is preferred as better systemd support and cgroups handling +CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-podman} + +if [[ ! -f "$SCRIPT_DIR/Dockerfile.$PACKAGE_TEST" ]]; then + echo "No definition for $SCRIPT_DIR/Dockerfile.$PACKAGE_TEST" + exit 1 +fi + +declare -a CONTAINER_TARGETS=("official-install" "staging-install" "staging-upgrade") + +# Build all containers required +for TARGET in "${CONTAINER_TARGETS[@]}" +do + BUILD_ARGS="" + if [[ $TARGET == "staging-upgrade" ]]; then + BUILD_ARGS="--build-arg STAGING_BASE=staging-upgrade-prep" + fi + + CONTAINER_NAME="package-verify-$PACKAGE_TEST-$TARGET" + + # Cope with needing --ignore for podman but not for docker + "${CONTAINER_RUNTIME}" rm --force --ignore --volumes "$CONTAINER_NAME" || "${CONTAINER_RUNTIME}" rm --force --volumes "$CONTAINER_NAME" + + # We do want splitting for build args + # shellcheck disable=SC2086 + "${CONTAINER_RUNTIME}" build \ + --build-arg STAGING_KEY=$STAGING_KEY \ + --build-arg STAGING_URL=$STAGING_URL \ + --build-arg RELEASE_KEY=$RELEASE_KEY \ + --build-arg RELEASE_URL=$RELEASE_URL $BUILD_ARGS \ + --target "$TARGET" \ + -t "$CONTAINER_NAME" \ + -f "$SCRIPT_DIR/Dockerfile.$PACKAGE_TEST" "$SCRIPT_DIR/" + + if [[ "$CONTAINER_RUNTIME" == "docker" ]]; then + "${CONTAINER_RUNTIME}" run --rm -d \ + --privileged \ + -v /sys/fs/cgroup/:/sys/fs/cgroup:ro \ + --name "$CONTAINER_NAME" \ + "$CONTAINER_NAME" + else + "${CONTAINER_RUNTIME}" run --rm -d \ + --timeout 30 \ + --name "$CONTAINER_NAME" \ + "$CONTAINER_NAME" + fi + + "${CONTAINER_RUNTIME}" exec -t "$CONTAINER_NAME" /test.sh + + "${CONTAINER_RUNTIME}" rm --force --ignore --volumes "$CONTAINER_NAME" || "${CONTAINER_RUNTIME}" rm --force --volumes "$CONTAINER_NAME" +done diff --git a/src/fluent-bit/packaging/testing/smoke/packages/test.sh b/src/fluent-bit/packaging/testing/smoke/packages/test.sh new file mode 100644 index 000000000..b82ae6eae --- /dev/null +++ b/src/fluent-bit/packaging/testing/smoke/packages/test.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -ex + +if [ "$SKIP_TEST" = "yes" ]; then + echo "Skipping test" + exit 0 +fi + +echo "Check package installed" +rpm -q fluent-bit || dpkg -l fluent-bit + +echo "Check service enabled" +systemctl is-enabled fluent-bit + +until systemctl is-system-running; do + # On more recent systems we may see degrade when running + [ "$(systemctl is-system-running)" = "degraded" ] && break + systemctl --failed + sleep 10 +done + +echo "Check service running" +systemctl status -q --no-pager fluent-bit |