diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /fluent-bit/packaging/testing/smoke/container | |
parent | Initial commit. (diff) | |
download | netdata-upstream.tar.xz netdata-upstream.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/packaging/testing/smoke/container')
3 files changed, 145 insertions, 0 deletions
diff --git a/fluent-bit/packaging/testing/smoke/container/container-smoke-test.sh b/fluent-bit/packaging/testing/smoke/container/container-smoke-test.sh new file mode 100755 index 00000000..4ab03c91 --- /dev/null +++ b/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/fluent-bit/packaging/testing/smoke/container/fluent-bit.conf b/fluent-bit/packaging/testing/smoke/container/fluent-bit.conf new file mode 100644 index 00000000..5b987bc2 --- /dev/null +++ b/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/fluent-bit/packaging/testing/smoke/container/fluent-bit.yaml b/fluent-bit/packaging/testing/smoke/container/fluent-bit.yaml new file mode 100644 index 00000000..69167e0b --- /dev/null +++ b/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 |