From 4d6d35db5495acdb1afb92cda51556370b3a84a0 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Mon, 27 Mar 2023 11:53:57 +0200 Subject: [PATCH] tests: initial commit of the manual tests Signed-off-by: Leonardo Alminana --- tests/leonardo/base.sh | 55 ++++++++++++++ tests/leonardo/filter_alter_size_1.sh | 12 ++++ tests/leonardo/filter_alter_size_2.sh | 12 ++++ tests/leonardo/filter_checklist.sh | 12 ++++ tests/leonardo/filter_expect.sh | 12 ++++ tests/leonardo/filter_modify_1.sh | 5 ++ tests/leonardo/filter_modify_2.sh | 5 ++ tests/leonardo/filter_rewrite_tag.sh | 5 ++ tests/leonardo/filter_throttle.sh | 5 ++ tests/leonardo/in_collectd.sh | 10 +++ tests/leonardo/in_elasticsearch.sh | 10 +++ tests/leonardo/in_forward_forward_mode.sh | 10 +++ tests/leonardo/in_forward_legacy_mode.sh | 10 +++ tests/leonardo/in_forward_message_mode.sh | 10 +++ tests/leonardo/in_http.sh | 9 +++ tests/leonardo/in_https.sh | 9 +++ tests/leonardo/in_mqtt.sh | 7 ++ tests/leonardo/in_otlp.sh | 10 +++ tests/leonardo/in_prometheus.sh | 11 +++ tests/leonardo/in_serial.sh | 9 +++ tests/leonardo/in_statsd.sh | 11 +++ tests/leonardo/in_stdin.sh | 5 ++ tests/leonardo/in_syslog.sh | 9 +++ tests/leonardo/in_tail.sh | 9 +++ tests/leonardo/in_tail_multiline.sh | 9 +++ tests/leonardo/in_tail_multiline_legacy.sh | 9 +++ tests/leonardo/in_tcp.sh | 9 +++ tests/leonardo/in_udp.sh | 9 +++ .../producers/json_log_record_producer.sh | 7 ++ tests/leonardo/setup.sh | 62 ++++++++++++++++ tests/leonardo/sinks/fb_collectd.sh | 25 +++++++ tests/leonardo/sinks/fb_elasticsearch.sh | 19 +++++ tests/leonardo/sinks/fb_forward.sh | 19 +++++ tests/leonardo/sinks/fb_http.sh | 19 +++++ tests/leonardo/sinks/fb_https.sh | 23 ++++++ tests/leonardo/sinks/fb_mqtt.sh | 21 ++++++ tests/leonardo/sinks/fb_otlp.sh | 19 +++++ .../sinks/fb_otlp_filter_alter_size_1.sh | 24 +++++++ .../sinks/fb_otlp_filter_alter_size_2.sh | 24 +++++++ .../sinks/fb_otlp_filter_checklist.sh | 31 ++++++++ tests/leonardo/sinks/fb_otlp_filter_expect.sh | 26 +++++++ .../leonardo/sinks/fb_otlp_filter_modify_1.sh | 31 ++++++++ .../leonardo/sinks/fb_otlp_filter_modify_2.sh | 31 ++++++++ .../sinks/fb_otlp_filter_rewrite_tag.sh | 31 ++++++++ .../leonardo/sinks/fb_otlp_filter_throttle.sh | 27 +++++++ tests/leonardo/sinks/fb_prometheus.sh | 21 ++++++ tests/leonardo/sinks/fb_serial.sh | 20 ++++++ tests/leonardo/sinks/fb_statsd.sh | 21 ++++++ tests/leonardo/sinks/fb_stdin.sh | 27 +++++++ tests/leonardo/sinks/fb_syslog.sh | 32 +++++++++ tests/leonardo/sinks/fb_tail.sh | 31 ++++++++ tests/leonardo/sinks/fb_tail_multiline.sh | 33 +++++++++ .../sinks/fb_tail_multiline_legacy.sh | 33 +++++++++ tests/leonardo/sinks/fb_tcp.sh | 20 ++++++ tests/leonardo/sinks/fb_udp.sh | 20 ++++++ tests/leonardo/sources/collectd.sh | 23 ++++++ tests/leonardo/sources/fb_elasticsearch.sh | 26 +++++++ .../sources/fb_forward_forward_mode.sh | 26 +++++++ .../sources/fb_forward_legacy_mode.sh | 27 +++++++ .../sources/fb_forward_message_mode.sh | 27 +++++++ tests/leonardo/sources/fb_prometheus.sh | 26 +++++++ tests/leonardo/sources/otelcol_otlp_logs.sh | 66 +++++++++++++++++ tests/leonardo/sources/shell_http.sh | 11 +++ tests/leonardo/sources/shell_https.sh | 13 ++++ tests/leonardo/sources/shell_mqtt.sh | 13 ++++ tests/leonardo/sources/shell_serial.sh | 7 ++ tests/leonardo/sources/shell_stdin.sh | 3 + tests/leonardo/sources/shell_syslog.sh | 9 +++ tests/leonardo/sources/shell_tail.sh | 17 +++++ .../leonardo/sources/shell_tail_multiline.sh | 72 +++++++++++++++++++ .../sources/shell_tail_multiline_legacy.sh | 33 +++++++++ tests/leonardo/sources/shell_tcp.sh | 6 ++ tests/leonardo/sources/shell_udp.sh | 6 ++ tests/leonardo/sources/vector_statsd.sh | 20 ++++++ 74 files changed, 1426 insertions(+) create mode 100755 tests/leonardo/base.sh create mode 100755 tests/leonardo/filter_alter_size_1.sh create mode 100755 tests/leonardo/filter_alter_size_2.sh create mode 100755 tests/leonardo/filter_checklist.sh create mode 100755 tests/leonardo/filter_expect.sh create mode 100755 tests/leonardo/filter_modify_1.sh create mode 100755 tests/leonardo/filter_modify_2.sh create mode 100755 tests/leonardo/filter_rewrite_tag.sh create mode 100755 tests/leonardo/filter_throttle.sh create mode 100755 tests/leonardo/in_collectd.sh create mode 100755 tests/leonardo/in_elasticsearch.sh create mode 100755 tests/leonardo/in_forward_forward_mode.sh create mode 100755 tests/leonardo/in_forward_legacy_mode.sh create mode 100755 tests/leonardo/in_forward_message_mode.sh create mode 100755 tests/leonardo/in_http.sh create mode 100755 tests/leonardo/in_https.sh create mode 100755 tests/leonardo/in_mqtt.sh create mode 100755 tests/leonardo/in_otlp.sh create mode 100755 tests/leonardo/in_prometheus.sh create mode 100755 tests/leonardo/in_serial.sh create mode 100755 tests/leonardo/in_statsd.sh create mode 100755 tests/leonardo/in_stdin.sh create mode 100755 tests/leonardo/in_syslog.sh create mode 100755 tests/leonardo/in_tail.sh create mode 100755 tests/leonardo/in_tail_multiline.sh create mode 100755 tests/leonardo/in_tail_multiline_legacy.sh create mode 100755 tests/leonardo/in_tcp.sh create mode 100755 tests/leonardo/in_udp.sh create mode 100755 tests/leonardo/producers/json_log_record_producer.sh create mode 100755 tests/leonardo/setup.sh create mode 100755 tests/leonardo/sinks/fb_collectd.sh create mode 100755 tests/leonardo/sinks/fb_elasticsearch.sh create mode 100755 tests/leonardo/sinks/fb_forward.sh create mode 100755 tests/leonardo/sinks/fb_http.sh create mode 100755 tests/leonardo/sinks/fb_https.sh create mode 100755 tests/leonardo/sinks/fb_mqtt.sh create mode 100755 tests/leonardo/sinks/fb_otlp.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_alter_size_1.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_alter_size_2.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_checklist.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_expect.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_modify_1.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_modify_2.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_rewrite_tag.sh create mode 100755 tests/leonardo/sinks/fb_otlp_filter_throttle.sh create mode 100755 tests/leonardo/sinks/fb_prometheus.sh create mode 100755 tests/leonardo/sinks/fb_serial.sh create mode 100755 tests/leonardo/sinks/fb_statsd.sh create mode 100755 tests/leonardo/sinks/fb_stdin.sh create mode 100755 tests/leonardo/sinks/fb_syslog.sh create mode 100755 tests/leonardo/sinks/fb_tail.sh create mode 100755 tests/leonardo/sinks/fb_tail_multiline.sh create mode 100755 tests/leonardo/sinks/fb_tail_multiline_legacy.sh create mode 100755 tests/leonardo/sinks/fb_tcp.sh create mode 100755 tests/leonardo/sinks/fb_udp.sh create mode 100755 tests/leonardo/sources/collectd.sh create mode 100755 tests/leonardo/sources/fb_elasticsearch.sh create mode 100755 tests/leonardo/sources/fb_forward_forward_mode.sh create mode 100755 tests/leonardo/sources/fb_forward_legacy_mode.sh create mode 100755 tests/leonardo/sources/fb_forward_message_mode.sh create mode 100755 tests/leonardo/sources/fb_prometheus.sh create mode 100755 tests/leonardo/sources/otelcol_otlp_logs.sh create mode 100755 tests/leonardo/sources/shell_http.sh create mode 100755 tests/leonardo/sources/shell_https.sh create mode 100755 tests/leonardo/sources/shell_mqtt.sh create mode 100755 tests/leonardo/sources/shell_serial.sh create mode 100755 tests/leonardo/sources/shell_stdin.sh create mode 100755 tests/leonardo/sources/shell_syslog.sh create mode 100755 tests/leonardo/sources/shell_tail.sh create mode 100755 tests/leonardo/sources/shell_tail_multiline.sh create mode 100755 tests/leonardo/sources/shell_tail_multiline_legacy.sh create mode 100755 tests/leonardo/sources/shell_tcp.sh create mode 100755 tests/leonardo/sources/shell_udp.sh create mode 100755 tests/leonardo/sources/vector_statsd.sh diff --git a/tests/leonardo/base.sh b/tests/leonardo/base.sh new file mode 100755 index 0000000..35d9e49 --- /dev/null +++ b/tests/leonardo/base.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +function elevate_privileges { + if [ "$EUID" -ne 0 ] + then + sudo $0 $@ + exit + fi +} + +function teardown { +# [[ -z "$(jobs -p)" ]] || kill -9 $(jobs -p) + + if [ ! -z "${CONTEXT_PATH}" ] + then + if [ -d "${CONTEXT_PATH}" ] + then + rm -rf "${CONTEXT_PATH}" + fi + fi + + rm -f /tmp/source.log 2>&1 >/dev/null + + pkill -g $$ + sleep 1 + pkill -9 -g $$ +} + +function delayed_exec_source { + sleep $1 + shift + rm -f /tmp/source.log 2>&1 >/dev/null + nohup $@ >/tmp/source.log 2>&1 +} + +function exec_source { + delayed_exec_source 1 $@ +} + +function exec_source_after_sink_launches { + while [ 1 ] + do + PTY=$(ps fax | grep $$ | head -n1 | awk '{print $2}') + PID=$(ps fax | grep "${PTY}" | grep fluent-bit | grep -v grep | awk '{print $1}') + + if [ -z "${PID}" ] + then + sleep 0.1 + else + break + fi + done + + exec_source $@ +} diff --git a/tests/leonardo/filter_alter_size_1.sh b/tests/leonardo/filter_alter_size_1.sh new file mode 100755 index 0000000..12ce8cf --- /dev/null +++ b/tests/leonardo/filter_alter_size_1.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SOURCE_ADDRESS="192.168.122.1" +export SINK_ADDRESS=${SOURCE_ADDRESS} +export SINK_PORT="4318" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/otelcol_otlp_logs.sh & + +./sinks/fb_otlp_filter_alter_size_1.sh diff --git a/tests/leonardo/filter_alter_size_2.sh b/tests/leonardo/filter_alter_size_2.sh new file mode 100755 index 0000000..ffc9759 --- /dev/null +++ b/tests/leonardo/filter_alter_size_2.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SOURCE_ADDRESS="192.168.122.1" +export SINK_ADDRESS=${SOURCE_ADDRESS} +export SINK_PORT="4318" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/otelcol_otlp_logs.sh & + +./sinks/fb_otlp_filter_alter_size_2.sh diff --git a/tests/leonardo/filter_checklist.sh b/tests/leonardo/filter_checklist.sh new file mode 100755 index 0000000..05c8268 --- /dev/null +++ b/tests/leonardo/filter_checklist.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SOURCE_ADDRESS="192.168.122.1" +export SINK_ADDRESS=${SOURCE_ADDRESS} +export SINK_PORT="4318" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/otelcol_otlp_logs.sh & + +./sinks/fb_otlp_filter_checklist.sh diff --git a/tests/leonardo/filter_expect.sh b/tests/leonardo/filter_expect.sh new file mode 100755 index 0000000..90a16d5 --- /dev/null +++ b/tests/leonardo/filter_expect.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SOURCE_ADDRESS="192.168.122.1" +export SINK_ADDRESS=${SOURCE_ADDRESS} +export SINK_PORT="4318" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/otelcol_otlp_logs.sh & + +./sinks/fb_otlp_filter_expect.sh diff --git a/tests/leonardo/filter_modify_1.sh b/tests/leonardo/filter_modify_1.sh new file mode 100755 index 0000000..b50614f --- /dev/null +++ b/tests/leonardo/filter_modify_1.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ./setup.sh + +./sinks/fb_otlp_filter_modify_1.sh diff --git a/tests/leonardo/filter_modify_2.sh b/tests/leonardo/filter_modify_2.sh new file mode 100755 index 0000000..f543ed2 --- /dev/null +++ b/tests/leonardo/filter_modify_2.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ./setup.sh + +./sinks/fb_otlp_filter_modify_2.sh diff --git a/tests/leonardo/filter_rewrite_tag.sh b/tests/leonardo/filter_rewrite_tag.sh new file mode 100755 index 0000000..16bee96 --- /dev/null +++ b/tests/leonardo/filter_rewrite_tag.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ./setup.sh + +./sinks/fb_otlp_filter_rewrite_tag.sh diff --git a/tests/leonardo/filter_throttle.sh b/tests/leonardo/filter_throttle.sh new file mode 100755 index 0000000..48cddeb --- /dev/null +++ b/tests/leonardo/filter_throttle.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ./setup.sh + +./sinks/fb_otlp_filter_throttle.sh diff --git a/tests/leonardo/in_collectd.sh b/tests/leonardo/in_collectd.sh new file mode 100755 index 0000000..27616f4 --- /dev/null +++ b/tests/leonardo/in_collectd.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="25826" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/collectd.sh & + +./sinks/fb_collectd.sh diff --git a/tests/leonardo/in_elasticsearch.sh b/tests/leonardo/in_elasticsearch.sh new file mode 100755 index 0000000..dc63094 --- /dev/null +++ b/tests/leonardo/in_elasticsearch.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="24224" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/fb_elasticsearch.sh & + +./sinks/fb_elasticsearch.sh diff --git a/tests/leonardo/in_forward_forward_mode.sh b/tests/leonardo/in_forward_forward_mode.sh new file mode 100755 index 0000000..8898985 --- /dev/null +++ b/tests/leonardo/in_forward_forward_mode.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="24224" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/fb_forward_forward_mode.sh & + +./sinks/fb_forward.sh diff --git a/tests/leonardo/in_forward_legacy_mode.sh b/tests/leonardo/in_forward_legacy_mode.sh new file mode 100755 index 0000000..d4c068d --- /dev/null +++ b/tests/leonardo/in_forward_legacy_mode.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="24224" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/fb_forward_legacy_mode.sh & + +./sinks/fb_forward.sh diff --git a/tests/leonardo/in_forward_message_mode.sh b/tests/leonardo/in_forward_message_mode.sh new file mode 100755 index 0000000..c0219fc --- /dev/null +++ b/tests/leonardo/in_forward_message_mode.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="24224" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/fb_forward_message_mode.sh & + +./sinks/fb_forward.sh diff --git a/tests/leonardo/in_http.sh b/tests/leonardo/in_http.sh new file mode 100755 index 0000000..ae1b232 --- /dev/null +++ b/tests/leonardo/in_http.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export SINK_PORT="9880" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_http.sh & + +./sinks/fb_http.sh diff --git a/tests/leonardo/in_https.sh b/tests/leonardo/in_https.sh new file mode 100755 index 0000000..cc90bd2 --- /dev/null +++ b/tests/leonardo/in_https.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export SINK_PORT="9880" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_https.sh & + +./sinks/fb_https.sh diff --git a/tests/leonardo/in_mqtt.sh b/tests/leonardo/in_mqtt.sh new file mode 100755 index 0000000..7f92404 --- /dev/null +++ b/tests/leonardo/in_mqtt.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_mqtt.sh & + +./sinks/fb_mqtt.sh diff --git a/tests/leonardo/in_otlp.sh b/tests/leonardo/in_otlp.sh new file mode 100755 index 0000000..2ade07a --- /dev/null +++ b/tests/leonardo/in_otlp.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="4318" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/otelcol_otlp_logs.sh & + +./sinks/fb_otlp.sh diff --git a/tests/leonardo/in_prometheus.sh b/tests/leonardo/in_prometheus.sh new file mode 100755 index 0000000..ffb048d --- /dev/null +++ b/tests/leonardo/in_prometheus.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="9100" +export SOURCE_PORT="${SINK_PORT}" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/fb_prometheus.sh & + +./sinks/fb_prometheus.sh diff --git a/tests/leonardo/in_serial.sh b/tests/leonardo/in_serial.sh new file mode 100755 index 0000000..5679af3 --- /dev/null +++ b/tests/leonardo/in_serial.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source ./setup.sh + +exec_source ./sources/shell_serial.sh & + +sleep 1 + +./sinks/fb_serial.sh diff --git a/tests/leonardo/in_statsd.sh b/tests/leonardo/in_statsd.sh new file mode 100755 index 0000000..fae3189 --- /dev/null +++ b/tests/leonardo/in_statsd.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +export ELEVATE_PRIVILEGES=1 +export SINK_PORT="8125" +export SOURCE_PORT="${SINK_PORT}" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/vector_statsd.sh & + +./sinks/fb_statsd.sh diff --git a/tests/leonardo/in_stdin.sh b/tests/leonardo/in_stdin.sh new file mode 100755 index 0000000..f38c46d --- /dev/null +++ b/tests/leonardo/in_stdin.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ./setup.sh + +./sources/shell_stdin.sh | ./sinks/fb_stdin.sh diff --git a/tests/leonardo/in_syslog.sh b/tests/leonardo/in_syslog.sh new file mode 100755 index 0000000..f4a3541 --- /dev/null +++ b/tests/leonardo/in_syslog.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export SINK_PORT="5514" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_syslog.sh & + +./sinks/fb_syslog.sh diff --git a/tests/leonardo/in_tail.sh b/tests/leonardo/in_tail.sh new file mode 100755 index 0000000..b6e2f3a --- /dev/null +++ b/tests/leonardo/in_tail.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export DO_NOT_ELEVATE_PRIVILEGES=1 + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_tail.sh & + +./sinks/fb_tail.sh diff --git a/tests/leonardo/in_tail_multiline.sh b/tests/leonardo/in_tail_multiline.sh new file mode 100755 index 0000000..8881d28 --- /dev/null +++ b/tests/leonardo/in_tail_multiline.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export DO_NOT_ELEVATE_PRIVILEGES=1 + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_tail_multiline.sh & + +./sinks/fb_tail_multiline.sh diff --git a/tests/leonardo/in_tail_multiline_legacy.sh b/tests/leonardo/in_tail_multiline_legacy.sh new file mode 100755 index 0000000..3fa392e --- /dev/null +++ b/tests/leonardo/in_tail_multiline_legacy.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export DO_NOT_ELEVATE_PRIVILEGES=1 + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_tail_multiline_legacy.sh & + +./sinks/fb_tail_multiline_legacy.sh diff --git a/tests/leonardo/in_tcp.sh b/tests/leonardo/in_tcp.sh new file mode 100755 index 0000000..56ff546 --- /dev/null +++ b/tests/leonardo/in_tcp.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export SINK_PORT="5170" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_tcp.sh & + +./sinks/fb_tcp.sh diff --git a/tests/leonardo/in_udp.sh b/tests/leonardo/in_udp.sh new file mode 100755 index 0000000..9a3c6a0 --- /dev/null +++ b/tests/leonardo/in_udp.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export SINK_PORT="5170" + +source ./setup.sh + +exec_source_after_sink_launches ./sources/shell_udp.sh & + +./sinks/fb_udp.sh diff --git a/tests/leonardo/producers/json_log_record_producer.sh b/tests/leonardo/producers/json_log_record_producer.sh new file mode 100755 index 0000000..f05dc0a --- /dev/null +++ b/tests/leonardo/producers/json_log_record_producer.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +while [ 1 ] +do + echo '{"timestamp": 0, "msg": "test data"}' + sleep 1 +done \ No newline at end of file diff --git a/tests/leonardo/setup.sh b/tests/leonardo/setup.sh new file mode 100755 index 0000000..d6243da --- /dev/null +++ b/tests/leonardo/setup.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +source ./base.sh + +if [ ! -z "${ELEVATE_PRIVILEGES}" ] +then + elevate_privileges +fi + +trap teardown EXIT + +CONTEXT_PATH="/tmp/fluent-bit-test-context/" + +if [ -z "${FLUENT_BIT_BINARY_PATH}" ] +then + if [ -f "./bin/fluent-bit" ] + then + export FLUENT_BIT_BINARY_PATH="./bin/fluent-bit" + elif [ -f "./fluent-bit" ] + then + export FLUENT_BIT_BINARY_PATH="./fluent-bit" + elif [ -f "../bin/fluent-bit" ] + then + export FLUENT_BIT_BINARY_PATH="../bin/fluent-bit" + elif [ -f "../fluent-bit" ] + then + export FLUENT_BIT_BINARY_PATH="../fluent-bit" + else + echo "fluent-bit could not be found, please provide a valid binary path in FLUENT_BIT_BINARY_PATH" + exit 1 + fi + + echo "FLUENT_BIT_BINARY_PATH not set, defaulting to ${FLUENT_BIT_BINARY_PATH}" +fi + +export CONTEXT_PATH="$(realpath ${CONTEXT_PATH})/" + +if [ ! -d "${CONTEXT_PATH}" ] +then + mkdir -p "${CONTEXT_PATH}" +fi + +if [ -z ${SOURCE_PATH} ] +then + export SOURCE_PATH="${CONTEXT_PATH}/source.log" + + echo "SOURCE_PATH not set, defaulting to ${SOURCE_PATH}" +fi + +if [ -z ${SINK_ADDRESS} ] +then + export SINK_ADDRESS="192.168.1.2" + + echo "SINK_ADDRESS not set, defaulting to ${SINK_ADDRESS}" +fi + +if [ -z ${SOURCE_ADDRESS} ] +then + export SOURCE_ADDRESS="192.168.1.2" + + echo "SOURCE_ADDRESS not set, defaulting to ${SOURCE_ADDRESS}" +fi diff --git a/tests/leonardo/sinks/fb_collectd.sh b/tests/leonardo/sinks/fb_collectd.sh new file mode 100755 index 0000000..d3e73eb --- /dev/null +++ b/tests/leonardo/sinks/fb_collectd.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name collectd + listen 0.0.0.0 + port 25826 + typesdb ${CONTEXT_PATH}/types.db + +[OUTPUT] + name stdout + match * +__EOF__ + +if [ ! -f ${CONTEXT_PATH}/types.db ] +then + wget -q https://raw.githubusercontent.com/collectd/collectd/main/src/types.db -O ${CONTEXT_PATH}/types.db +fi + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit.conf diff --git a/tests/leonardo/sinks/fb_elasticsearch.sh b/tests/leonardo/sinks/fb_elasticsearch.sh new file mode 100755 index 0000000..e3928c0 --- /dev/null +++ b/tests/leonardo/sinks/fb_elasticsearch.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name elasticsearch + listen 0.0.0.0 + port ${SINK_PORT} + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_forward.sh b/tests/leonardo/sinks/fb_forward.sh new file mode 100755 index 0000000..a9f510e --- /dev/null +++ b/tests/leonardo/sinks/fb_forward.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level trace + +[INPUT] + name forward + listen 0.0.0.0 + port ${SINK_PORT} + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_http.sh b/tests/leonardo/sinks/fb_http.sh new file mode 100755 index 0000000..431ecfb --- /dev/null +++ b/tests/leonardo/sinks/fb_http.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name http + listen 0.0.0.0 + port ${SINK_PORT} + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_https.sh b/tests/leonardo/sinks/fb_https.sh new file mode 100755 index 0000000..69c8434 --- /dev/null +++ b/tests/leonardo/sinks/fb_https.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name http + listen 0.0.0.0 + port ${SINK_PORT} + tls on + tls.verify off + tls.crt_file ${CONTEXT_PATH}/certificate.pem + tls.key_file ${CONTEXT_PATH}/private_key.pem + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_mqtt.sh b/tests/leonardo/sinks/fb_mqtt.sh new file mode 100755 index 0000000..030855e --- /dev/null +++ b/tests/leonardo/sinks/fb_mqtt.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +SINK_PORT="1883" + +cat >"${CONTEXT_PATH}/fluent-bit.conf" <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name mqtt + listen 0.0.0.0 + port ${SINK_PORT} + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c "${CONTEXT_PATH}/fluent-bit.conf" diff --git a/tests/leonardo/sinks/fb_otlp.sh b/tests/leonardo/sinks/fb_otlp.sh new file mode 100755 index 0000000..b0b7b01 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name opentelemetry + listen 0.0.0.0 + port ${SINK_PORT} + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_alter_size_1.sh b/tests/leonardo/sinks/fb_otlp_filter_alter_size_1.sh new file mode 100755 index 0000000..eb7c044 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_alter_size_1.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name opentelemetry + listen 0.0.0.0 + port ${SINK_PORT} + +[FILTER] + name alter_size + match * + add 1 + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_alter_size_2.sh b/tests/leonardo/sinks/fb_otlp_filter_alter_size_2.sh new file mode 100755 index 0000000..b5f1f68 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_alter_size_2.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name opentelemetry + listen 0.0.0.0 + port ${SINK_PORT} + +[FILTER] + name alter_size + match * + remove 1 + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_checklist.sh b/tests/leonardo/sinks/fb_otlp_filter_checklist.sh new file mode 100755 index 0000000..45ce896 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_checklist.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/checklist.txt <<__EOF__ +%papers +__EOF__ + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level trace + +[INPUT] + name opentelemetry + listen 0.0.0.0 + port ${SINK_PORT} + +[FILTER] + name checklist + match * + file ${CONTEXT_PATH}/checklist.txt + mode partial + lookup_key \$message + record match_signal found + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_expect.sh b/tests/leonardo/sinks/fb_otlp_filter_expect.sh new file mode 100755 index 0000000..270d806 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_expect.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name opentelemetry + listen 0.0.0.0 + port ${SINK_PORT} + +[FILTER] + name expect + match * + key_exists message + action result_key + result_key match_flag + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_modify_1.sh b/tests/leonardo/sinks/fb_otlp_filter_modify_1.sh new file mode 100755 index 0000000..32d0df4 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_modify_1.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name dummy + samples 1 + dummy {"message": "sample data line"} + metadata {"an interesting attribute": "this is not"} + +[INPUT] + name dummy + samples 1 + dummy {"log": "sample data line"} + metadata {"an interesting attribute": "this is not"} + +[FILTER] + name modify + match * + add added_key_name added_value + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_modify_2.sh b/tests/leonardo/sinks/fb_otlp_filter_modify_2.sh new file mode 100755 index 0000000..41f0305 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_modify_2.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name dummy + samples 1 + dummy {"message": "sample data line", "additional_data": 456} + metadata {"an interesting attribute": "this is not"} + +[INPUT] + name dummy + samples 1 + dummy {"log": "sample data line", "additional_data": 123} + metadata {"an interesting attribute": "this is not"} + +[FILTER] + name modify + match * + remove additional_data + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_rewrite_tag.sh b/tests/leonardo/sinks/fb_otlp_filter_rewrite_tag.sh new file mode 100755 index 0000000..accedf8 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_rewrite_tag.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name dummy + samples 1 + dummy {"message": "sample data line", "additional_data": "456"} + +[INPUT] + name dummy + samples 1 + dummy {"log": "sample data line", "additional_data": "123"} + + +[FILTER] + Name rewrite_tag + Match dummy.* + rule \$additional_data ^(123)$ 789 false + emitter_name re_emitter + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_otlp_filter_throttle.sh b/tests/leonardo/sinks/fb_otlp_filter_throttle.sh new file mode 100755 index 0000000..c826615 --- /dev/null +++ b/tests/leonardo/sinks/fb_otlp_filter_throttle.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name dummy + samples 10 + rate 1 + dummy {"message": "sample data line"} + metadata {"an interesting attribute": "this is not"} + +[FILTER] + name throttle + match * + window 5 + interval 2m + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_prometheus.sh b/tests/leonardo/sinks/fb_prometheus.sh new file mode 100755 index 0000000..4dcadb4 --- /dev/null +++ b/tests/leonardo/sinks/fb_prometheus.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name prometheus_scrape + listen ${SOURCE_ADDRESS} + port ${SOURCE_PORT} + metrics_path /v1/metrics + scrape_interval 5 + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_serial.sh b/tests/leonardo/sinks/fb_serial.sh new file mode 100755 index 0000000..0468484 --- /dev/null +++ b/tests/leonardo/sinks/fb_serial.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name serial + file ${CONTEXT_PATH}/virtual_serial.dev + bitrate 9600 + format json + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_statsd.sh b/tests/leonardo/sinks/fb_statsd.sh new file mode 100755 index 0000000..1896b83 --- /dev/null +++ b/tests/leonardo/sinks/fb_statsd.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +SINK_PORT="8125" + +cat >${CONTEXT_PATH}/fluent-bit.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + +[INPUT] + name statsd + listen 0.0.0.0 + port ${SINK_PORT} + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit.conf diff --git a/tests/leonardo/sinks/fb_stdin.sh b/tests/leonardo/sinks/fb_stdin.sh new file mode 100755 index 0000000..7ef198e --- /dev/null +++ b/tests/leonardo/sinks/fb_stdin.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink-parsers.conf <<__EOF__ +[PARSER] + Name json + Format json + Time_Key time + Time_Format %d/%b/%Y:%H:%M:%S %z +__EOF__ + +cat >${CONTEXT_PATH}/fluent-bit-sink.conf <<__EOF__ +[SERVICE] + flush 1 + grace 1 + log_level info + parsers_file ${CONTEXT_PATH}/fluent-bit-sink-parsers.conf + +[INPUT] + name stdin + parser json + +[OUTPUT] + name stdout + match * +__EOF__ + +${FLUENT_BIT_BINARY_PATH} -c ${CONTEXT_PATH}/fluent-bit-sink.conf diff --git a/tests/leonardo/sinks/fb_syslog.sh b/tests/leonardo/sinks/fb_syslog.sh new file mode 100755 index 0000000..e2cc99f --- /dev/null +++ b/tests/leonardo/sinks/fb_syslog.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +cat >${CONTEXT_PATH}/fluent-bit-sink-parsers.conf <<__EOF__ +[PARSER] + name syslog-rfc5424 + format regex + regex ^\<(?[0-9]{1,5})\>1 (?