From 5a2582e21cade53235c5c163ab4c3b658217d4fc Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Tue, 10 Nov 2026 23:21:56 +0300 Subject: [PATCH] test(observability-proxy): preserve JSON seed request bodies Send JSON seeds with their content type so VictoriaLogs does not consume log records while parsing form parameters before ingestion. Fixes: ebb5a9cec4f6 ("test(observability-proxy): cover the namespace logs scope end to end") Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- hack/e2e-chainsaw/observability-proxy/lib.sh | 2 +- hack/observability-proxy-seed.bats | 51 ++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 hack/observability-proxy-seed.bats diff --git a/hack/e2e-chainsaw/observability-proxy/lib.sh b/hack/e2e-chainsaw/observability-proxy/lib.sh index a9a1f28a5..9601cb826 100644 --- a/hack/e2e-chainsaw/observability-proxy/lib.sh +++ b/hack/e2e-chainsaw/observability-proxy/lib.sh @@ -25,7 +25,7 @@ forward() { ingest() { printf '{"kubernetes_namespace_name":"%s","log":"%s"}\n' "$1" "$2" | timeout 15 curl --silent --show-error --fail --data-binary @- \ - --header "AccountID: ${3:-0}" --header "ProjectID: 0" \ + --header 'Content-Type: application/json' --header "AccountID: ${3:-0}" --header "ProjectID: 0" \ "$STORE/insert/jsonline?_stream_fields=kubernetes_namespace_name&_msg_field=log" } diff --git a/hack/observability-proxy-seed.bats b/hack/observability-proxy-seed.bats new file mode 100644 index 000000000..8815b0db5 --- /dev/null +++ b/hack/observability-proxy-seed.bats @@ -0,0 +1,51 @@ +#!/usr/bin/env bats + +load test_helper + +REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)" + +setup() { + strict_setup + mkdir -p "$BATS_TEST_TMPDIR/bin" + export SEED_CAPTURE="$BATS_TEST_TMPDIR/seed" + export TMPDIR="$BATS_TEST_TMPDIR" + export PATH="$BATS_TEST_TMPDIR/bin:$PATH" + cat > "$BATS_TEST_TMPDIR/bin/curl" <<'EOF' +#!/usr/bin/env bash +set -eu +printf '%s\n' "$@" > "$SEED_CAPTURE.args" +cat > "$SEED_CAPTURE.body" +if ! grep --fixed-strings --line-regexp --quiet 'Content-Type: application/json' "$SEED_CAPTURE.args"; then + echo 'seed request is missing its JSON content type' >&2 + exit 22 +fi +EOF + chmod +x "$BATS_TEST_TMPDIR/bin/curl" +} + +assert_seed_request() { + local account=$1 + # shellcheck source=e2e-chainsaw/observability-proxy/lib.sh + . "$REPO_ROOT/hack/e2e-chainsaw/observability-proxy/lib.sh" + if [ "$account" = 0 ]; then + ingest tenant-test-logsa e2e-marker-a + else + ingest tenant-test-logsa e2e-marker-a "$account" + fi + grep --fixed-strings --line-regexp --quiet "AccountID: $account" "$SEED_CAPTURE.args" + grep --fixed-strings --line-regexp --quiet 'ProjectID: 0' "$SEED_CAPTURE.args" + grep --fixed-strings --line-regexp --quiet 'http://localhost:19471/insert/jsonline?_stream_fields=kubernetes_namespace_name&_msg_field=log' "$SEED_CAPTURE.args" + grep --fixed-strings --line-regexp --quiet -- '--data-binary' "$SEED_CAPTURE.args" + grep --fixed-strings --line-regexp --quiet '@-' "$SEED_CAPTURE.args" + printf '%s\n' '{"kubernetes_namespace_name":"tenant-test-logsa","log":"e2e-marker-a"}' > "$SEED_CAPTURE.expected" + cmp "$SEED_CAPTURE.expected" "$SEED_CAPTURE.body" + rm "$body" +} + +@test "observability seeds send JSON without consuming the body as form data" { + assert_seed_request 0 +} + +@test "observability seeds preserve an explicit VictoriaLogs account" { + assert_seed_request 7 +}