Skip to content

Commit

Permalink
tests: runtime_shell: custom_calyptia: add checks for fleet management
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Stephens <[email protected]>
  • Loading branch information
patrick-stephens committed Dec 17, 2024
1 parent bfacebb commit 9e2234e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
CC: ${{ matrix.compiler }}
CXX: ${{ matrix.compiler }}
FLB_OPT: ${{ matrix.flb_option }}
CALYPTIA_FLEET_TOKEN: ${{ secrets.CALYPTIA_FLEET_TOKEN }}

run-macos-unit-tests:
# We chain this after Linux one as there are costs and restrictions associated
Expand Down Expand Up @@ -111,6 +112,7 @@ jobs:
CC: gcc
CXX: g++
FLB_OPT: ${{ matrix.flb_option }}
CALYPTIA_FLEET_TOKEN: ${{ secrets.CALYPTIA_FLEET_TOKEN }}

run-aarch64-unit-tests:
# Ensure for OSS Fluent Bit repo we enable usage of Actuated runners for ARM builds, for forks it should keep existing ubuntu-latest usage.
Expand Down Expand Up @@ -167,6 +169,7 @@ jobs:
env:
CC: ${{ matrix.config.compiler }}
CXX: ${{ matrix.config.compiler }}
CALYPTIA_FLEET_TOKEN: ${{ secrets.CALYPTIA_FLEET_TOKEN }}

run-qemu-ubuntu-unit-tests:
# We chain this after Linux one as there are CPU time costs for QEMU emulation
Expand Down Expand Up @@ -218,7 +221,6 @@ jobs:
make -j $nparallel
ctest -j $nparallel --build-run-dir . --output-on-failure
# Required check looks at this so do not remove
run-all-unit-tests:
if: always()
Expand Down
1 change: 1 addition & 0 deletions tests/runtime_shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ configure_file(
)

set(UNIT_TESTS_SH
custom_calyptia.sh
in_dummy_expect.sh
in_tail_expect.sh
in_http_tls_expect.sh
Expand Down
17 changes: 17 additions & 0 deletions tests/runtime_shell/conf/custom_calyptia_fleet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[INPUT]
name cpu
tag cpu.local

# Read interval (sec) Default: 1
interval_sec 1

[CUSTOM]
name calyptia
API_Key ${CALYPTIA_FLEET_TOKEN}
Fleet_Name fluent-bit-ci-fleet
fleet_config_legacy_format ${CALYPTIA_FLEET_FORMAT}
fleet_config_dir ${CALYPTIA_FLEET_DIR}

[OUTPUT]
name null
match *
67 changes: 67 additions & 0 deletions tests/runtime_shell/custom_calyptia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

test_custom_calyptia_fleet_yaml() {
[ -z "${CALYPTIA_FLEET_TOKEN:-}" ] && startSkipping

export CALYPTIA_FLEET_TOKEN
export CALYPTIA_FLEET_FORMAT="off"
export CALYPTIA_FLEET_DIR="${CALYPTIA_FLEET_DIR:-/tmp/fleet-test}"
rm -rf "$CALYPTIA_FLEET_DIR"

# Dry-run to check it is valid
if $FLB_BIN -c "$FLB_RUNTIME_SHELL_CONF/custom_calyptia_fleet.conf" --dry-run; then
fail 'Dry run failed'
fi

$FLB_BIN -c "$FLB_RUNTIME_SHELL_CONF/custom_calyptia_fleet.conf" &
FLB_PID=$!

# Allow us to register and retrieve fleet config
sleep 30

# Check we have YAML files
if find "$CALYPTIA_FLEET_DIR" -name '*.yaml' -type f -exec false {} +; then
fail 'No YAML files found'
fi

# Check we are still running
assertTrue 'Fluent bit not running' "[ kill -0 $FLB_PID ]"

# Clean up
kill -15 $FLB_PID
}

test_custom_calyptia_fleet_toml() {
[ -z "${CALYPTIA_FLEET_TOKEN:-}" ] && startSkipping

export CALYPTIA_FLEET_TOKEN
export CALYPTIA_FLEET_FORMAT="on"
export CALYPTIA_FLEET_DIR="${CALYPTIA_FLEET_DIR:-/tmp/fleet-test}"
rm -rf "$CALYPTIA_FLEET_DIR"

# Dry-run to check it is valid
if $FLB_BIN -c "$FLB_RUNTIME_SHELL_CONF/custom_calyptia_fleet.conf" --dry-run; then
fail 'Dry run failed'
fi

$FLB_BIN -c "$FLB_RUNTIME_SHELL_CONF/custom_calyptia_fleet.conf" &
FLB_PID=$!

# Allow us to register and retrieve fleet config
sleep 30

# Check we have no YAML files
if ! find "$CALYPTIA_FLEET_DIR" -name '*.yaml' -type f -exec false {} +; then
fail 'YAML files found'
fi

# Check we are still running
assertTrue 'Fluent bit not running' "[ kill -0 $FLB_PID ]"

# Clean up
kill -15 $FLB_PID
}

# The following command launch the unit test
# shellcheck source=/dev/null
. "$FLB_RUNTIME_SHELL_PATH/runtime_shell.env"

0 comments on commit 9e2234e

Please sign in to comment.