From 1b537ca112e2b86b2b7b1702bbbf94ccfabb6939 Mon Sep 17 00:00:00 2001 From: Patrick Stephens Date: Thu, 19 Mar 2026 17:18:48 +0000 Subject: [PATCH 1/3] test: add basic git config checks Signed-off-by: Patrick Stephens --- .../git_config/resources/fluent-bit.yaml | 19 +++++++++ .../resources/initial-fluent-bit.yaml | 10 +++++ .../git_config/verify-git-config-plugin.bats | 37 +++++++++++++++++ .../plugins/verify-custom-plugins.bats | 41 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml create mode 100644 testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml create mode 100644 testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats create mode 100644 testing/bats/tests/functional/plugins/verify-custom-plugins.bats diff --git a/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml b/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml new file mode 100644 index 00000000..0c41ab86 --- /dev/null +++ b/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml @@ -0,0 +1,19 @@ +service: + flush: 1 + log_level: info + +pipeline: + inputs: + - name: dummy + dummy: '{"message": "Switched to updated configuration"}' + alias: input_dummy + + outputs: + - name: stdout + match: '*' + alias: output_stdout + - name: exit + match: '*' + # Exit after processing 5 records to ensure the test completes in a reasonable time frame + record_count: 5 + alias: output_exit \ No newline at end of file diff --git a/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml b/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml new file mode 100644 index 00000000..e0496a69 --- /dev/null +++ b/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml @@ -0,0 +1,10 @@ +service: + flush: 1 + log_level: debug + +customs: + - name: git_config + repo: https://github.com/telemetryforge/agent.git + ref: main + path: testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml + poll_interval: 1 \ No newline at end of file diff --git a/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats b/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats new file mode 100644 index 00000000..19b734db --- /dev/null +++ b/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats + +ensure_variables_set BATS_SUPPORT_ROOT BATS_ASSERT_ROOT BATS_FILE_ROOT FLUENT_BIT_BINARY + +load "$BATS_SUPPORT_ROOT/load.bash" +load "$BATS_ASSERT_ROOT/load.bash" +load "$BATS_FILE_ROOT/load.bash" + +# bats file_tags=functional +setup() { +} + +teardown() { + if [[ -n "${SKIP_TEARDOWN:-}" ]]; then + echo "Skipping teardown" + fi +} + +@test "verify git config plugin basic configuration" { + # Verify the configuration files are valid and the plugin can start without errors with the provided configuration + run "$FLUENT_BIT_BINARY" -c "$BATS_FILE_ROOT/resources/initial-fluent-bit.yaml" --dry-run + assert_success + refute_output --partial "[error]" + + # This is the one we should switch to after the first poll interval + run "$FLUENT_BIT_BINARY" -c "$BATS_FILE_ROOT/resources/fluent-bit.yaml" --dry-run + assert_success + refute_output --partial "[error]" + + run "$FLUENT_BIT_BINARY" -c "$BATS_FILE_ROOT/resources/initial-fluent-bit.yaml" + assert_success + # Check we are correctly polling the repository and not encountering errors extracting the config file + assert_output --partial 'polling repository https://github.com/telemetryforge/agent.git' + refute_output --partial 'failed to extract config file' + # The output should contain the message about switching to the updated configuration after the first poll interval + assert_output --partial 'Switched to updated configuration' +} diff --git a/testing/bats/tests/functional/plugins/verify-custom-plugins.bats b/testing/bats/tests/functional/plugins/verify-custom-plugins.bats new file mode 100644 index 00000000..bf14bc27 --- /dev/null +++ b/testing/bats/tests/functional/plugins/verify-custom-plugins.bats @@ -0,0 +1,41 @@ +#!/usr/bin/env bats + +ensure_variables_set BATS_SUPPORT_ROOT BATS_ASSERT_ROOT BATS_FILE_ROOT FLUENT_BIT_BINARY + +load "$BATS_SUPPORT_ROOT/load.bash" +load "$BATS_ASSERT_ROOT/load.bash" +load "$BATS_FILE_ROOT/load.bash" + +# bats file_tags=functional + +setup() { +} + +teardown() { + if [[ -n "${SKIP_TEARDOWN:-}" ]]; then + echo "Skipping teardown" + fi +} + +@test "verify git_config plugin exists" { + run "$FLUENT_BIT_BINARY" --help + assert_success + assert_output --partial "git_config" + run "$FLUENT_BIT_BINARY" -C git_config --help + assert_success + refute_output --partial "[error]" + refute_output --partial "tried to instance a plugin name that doesn't exist" +} + +@test "verify log_sampling processor exists" { + run "$FLUENT_BIT_BINARY" --help + assert_success + assert_output --partial "log_sampling" +} + +@test "verify dedupe processor exists" { + run "$FLUENT_BIT_BINARY" --help + assert_success + assert_output --partial "dedupe" +} + From 24129ebf298971bb33ee020fd05c8402c88db90c Mon Sep 17 00:00:00 2001 From: Patrick Stephens Date: Thu, 19 Mar 2026 17:25:32 +0000 Subject: [PATCH 2/3] test: reduce grace period Signed-off-by: Patrick Stephens --- .../functional/plugins/git_config/resources/fluent-bit.yaml | 1 + .../plugins/git_config/resources/initial-fluent-bit.yaml | 3 +++ .../plugins/git_config/verify-git-config-plugin.bats | 1 + 3 files changed, 5 insertions(+) diff --git a/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml b/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml index 0c41ab86..fe612933 100644 --- a/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml +++ b/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml @@ -1,5 +1,6 @@ service: flush: 1 + grace: 1 log_level: info pipeline: diff --git a/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml b/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml index e0496a69..a6b0474e 100644 --- a/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml +++ b/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml @@ -1,10 +1,13 @@ service: flush: 1 + grace: 1 log_level: debug customs: - name: git_config repo: https://github.com/telemetryforge/agent.git + # We may need to adjust this per-PR appropriately to ensure we are testing the correct branch/PR ref: main path: testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml + # Fast polling poll_interval: 1 \ No newline at end of file diff --git a/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats b/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats index 19b734db..39ab10b2 100644 --- a/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats +++ b/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats @@ -32,6 +32,7 @@ teardown() { # Check we are correctly polling the repository and not encountering errors extracting the config file assert_output --partial 'polling repository https://github.com/telemetryforge/agent.git' refute_output --partial 'failed to extract config file' + assert_output --partial 'new commit detected' # The output should contain the message about switching to the updated configuration after the first poll interval assert_output --partial 'Switched to updated configuration' } From 9ae46e63c1a17c6b5460eabb735e55b50228c949 Mon Sep 17 00:00:00 2001 From: Patrick Stephens Date: Fri, 20 Mar 2026 15:26:30 +0000 Subject: [PATCH 3/3] ci: add support for the current branch Signed-off-by: Patrick Stephens --- .github/workflows/call-test-containers-k8s.yaml | 2 ++ .github/workflows/call-test-containers.yaml | 2 ++ .github/workflows/call-test-packages.yaml | 5 +++++ testing/bats/run-bats.sh | 4 ++++ .../functional/plugins/git_config/resources/fluent-bit.yaml | 6 +++--- .../plugins/git_config/resources/initial-fluent-bit.yaml | 6 +++--- .../plugins/git_config/verify-git-config-plugin.bats | 3 ++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/call-test-containers-k8s.yaml b/.github/workflows/call-test-containers-k8s.yaml index 77df8f4b..8f6bee60 100644 --- a/.github/workflows/call-test-containers-k8s.yaml +++ b/.github/workflows/call-test-containers-k8s.yaml @@ -88,6 +88,8 @@ jobs: BATS_NO_PARALLELIZE_ACROSS_FILES: 1 BATS_NUMBER_OF_PARALLEL_JOBS: 4 BATS_PARALLEL_BINARY_NAME: rush + # See https://github.com/orgs/community/discussions/25191 + GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} # Debugging steps to run if something goes wrong - name: Debug - List all pods diff --git a/.github/workflows/call-test-containers.yaml b/.github/workflows/call-test-containers.yaml index 95f74bb3..c7e44dc6 100644 --- a/.github/workflows/call-test-containers.yaml +++ b/.github/workflows/call-test-containers.yaml @@ -105,6 +105,8 @@ jobs: BATS_NO_PARALLELIZE_ACROSS_FILES: 1 BATS_NUMBER_OF_PARALLEL_JOBS: 4 BATS_PARALLEL_BINARY_NAME: rush + # See https://github.com/orgs/community/discussions/25191 + GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} test-verify-signatures: name: Verify image signatures for ${{ inputs.image }}:${{ inputs.image-tag }} diff --git a/.github/workflows/call-test-packages.yaml b/.github/workflows/call-test-packages.yaml index fe6af623..dd95ad55 100644 --- a/.github/workflows/call-test-packages.yaml +++ b/.github/workflows/call-test-packages.yaml @@ -158,6 +158,8 @@ jobs: env: BASE_IMAGE: ${{ matrix.config.image }} DISTRO: ${{ matrix.config.distro }} + # See https://github.com/orgs/community/discussions/25191 + GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} # Test packages installed on the actual target OS # For now we just use the ephemeral runners @@ -249,6 +251,9 @@ jobs: - name: Run integration tests run: ./testing/bats/run-package-integration-tests.sh shell: bash + env: + # See https://github.com/orgs/community/discussions/25191 + GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} - name: Debug linux binary if: runner.os == 'Linux' diff --git a/testing/bats/run-bats.sh b/testing/bats/run-bats.sh index 26c1eee9..4bf8506a 100755 --- a/testing/bats/run-bats.sh +++ b/testing/bats/run-bats.sh @@ -17,9 +17,13 @@ export FLUENT_BIT_BINARY=${FLUENT_BIT_BINARY:-/fluent-bit/bin/fluent-bit} export TELEMETRY_FORGE_AGENT_VERSION=${TELEMETRY_FORGE_AGENT_VERSION:-26.3.4} export TELEMETRY_FORGE_AGENT_URL="${TELEMETRY_FORGE_AGENT_URL:-https://staging.telemetryforge.io}" +# Used primarily for testing the git config plugin: the actual SHA of the commit for a PR, etc. +export GIT_SHA=${GIT_SHA:-main} + echo "INFO: Testing with binary '$FLUENT_BIT_BINARY'" echo "INFO: Testing with version '$TELEMETRY_FORGE_AGENT_VERSION'" echo "INFO: Testing with URL '$TELEMETRY_FORGE_AGENT_URL'" +echo "INFO: Testing with SHA '$GIT_SHA'" # Optional variables for container/k8s tests # TELEMETRY_FORGE_AGENT_IMAGE=... diff --git a/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml b/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml index fe612933..5e5b3f95 100644 --- a/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml +++ b/testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml @@ -6,7 +6,7 @@ service: pipeline: inputs: - name: dummy - dummy: '{"message": "Switched to updated configuration"}' + dummy: '{"message": "Switched to updated configuration", "sha": "${GIT_SHA}"}' alias: input_dummy outputs: @@ -15,6 +15,6 @@ pipeline: alias: output_stdout - name: exit match: '*' - # Exit after processing 5 records to ensure the test completes in a reasonable time frame - record_count: 5 + # Exit after processing 2 records to ensure the test completes in a reasonable time frame + record_count: 2 alias: output_exit \ No newline at end of file diff --git a/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml b/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml index a6b0474e..1b7c6ba8 100644 --- a/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml +++ b/testing/bats/tests/functional/plugins/git_config/resources/initial-fluent-bit.yaml @@ -7,7 +7,7 @@ customs: - name: git_config repo: https://github.com/telemetryforge/agent.git # We may need to adjust this per-PR appropriately to ensure we are testing the correct branch/PR - ref: main + ref: ${GIT_SHA} path: testing/bats/tests/functional/plugins/git_config/resources/fluent-bit.yaml - # Fast polling - poll_interval: 1 \ No newline at end of file + # Do not poll too fast as we still need to apply the commit between polls + poll_interval: 10 \ No newline at end of file diff --git a/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats b/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats index 39ab10b2..c7ae0961 100644 --- a/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats +++ b/testing/bats/tests/functional/plugins/git_config/verify-git-config-plugin.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -ensure_variables_set BATS_SUPPORT_ROOT BATS_ASSERT_ROOT BATS_FILE_ROOT FLUENT_BIT_BINARY +ensure_variables_set BATS_SUPPORT_ROOT BATS_ASSERT_ROOT BATS_FILE_ROOT FLUENT_BIT_BINARY GIT_SHA load "$BATS_SUPPORT_ROOT/load.bash" load "$BATS_ASSERT_ROOT/load.bash" @@ -29,6 +29,7 @@ teardown() { run "$FLUENT_BIT_BINARY" -c "$BATS_FILE_ROOT/resources/initial-fluent-bit.yaml" assert_success + assert_output --partial 'no existing git config found' # Check we are correctly polling the repository and not encountering errors extracting the config file assert_output --partial 'polling repository https://github.com/telemetryforge/agent.git' refute_output --partial 'failed to extract config file'