Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: initial commit of the manual tests #100

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions tests/leonardo/base.sh
Original file line number Diff line number Diff line change
@@ -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 $@
}
12 changes: 12 additions & 0 deletions tests/leonardo/filter_alter_size_1.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/leonardo/filter_alter_size_2.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/leonardo/filter_checklist.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/leonardo/filter_expect.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/leonardo/filter_modify_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ./setup.sh

./sinks/fb_otlp_filter_modify_1.sh
5 changes: 5 additions & 0 deletions tests/leonardo/filter_modify_2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ./setup.sh

./sinks/fb_otlp_filter_modify_2.sh
5 changes: 5 additions & 0 deletions tests/leonardo/filter_rewrite_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ./setup.sh

./sinks/fb_otlp_filter_rewrite_tag.sh
5 changes: 5 additions & 0 deletions tests/leonardo/filter_throttle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ./setup.sh

./sinks/fb_otlp_filter_throttle.sh
10 changes: 10 additions & 0 deletions tests/leonardo/in_collectd.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/leonardo/in_elasticsearch.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/leonardo/in_forward_forward_mode.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/leonardo/in_forward_legacy_mode.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/leonardo/in_forward_message_mode.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_http.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_https.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tests/leonardo/in_mqtt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source ./setup.sh

exec_source_after_sink_launches ./sources/shell_mqtt.sh &

./sinks/fb_mqtt.sh
10 changes: 10 additions & 0 deletions tests/leonardo/in_otlp.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions tests/leonardo/in_prometheus.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_serial.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

source ./setup.sh

exec_source ./sources/shell_serial.sh &

sleep 1

./sinks/fb_serial.sh
11 changes: 11 additions & 0 deletions tests/leonardo/in_statsd.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/leonardo/in_stdin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ./setup.sh

./sources/shell_stdin.sh | ./sinks/fb_stdin.sh
9 changes: 9 additions & 0 deletions tests/leonardo/in_syslog.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_tail.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_tail_multiline.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_tail_multiline_legacy.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_tcp.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/leonardo/in_udp.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tests/leonardo/producers/json_log_record_producer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

while [ 1 ]
do
echo '{"timestamp": 0, "msg": "test data"}'
sleep 1
done
62 changes: 62 additions & 0 deletions tests/leonardo/setup.sh
Original file line number Diff line number Diff line change
@@ -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
Loading