hyperdx/smoke-tests/otel-collector/severity-inference.bats
Warren Lee 4c42fdc3a4
fix(otel-collector): improve log level extraction with word boundaries in regex (#1747)
For a log line like 
```
x-amz-id-2: WxwS/N175wqLyRlzCXLpGZGszCEbQA0f63uFgdQN1qfcPr2IAmwE/P7HF2b1NdZLg18pNLF3ecTw5CrItXJid/uLe+fxh3jMBiJ7UlUxidw=
```
The level will be inferred as fatal because it contains `CrIt`, which is incorrect.

To fix this, we need to add a word boundary at the start

Ref: HDX-3439


CLAUDE: made a mistake.
```
 Test expects "ALERTING" to match "alert" keyword → "ALERTING" won't match with word boundary because "alert" is a substring, not at a word boundary. Expected should be "info",9,"ALERTING system engaged" not "fatal",21.
``` 
-> incorrect statement
2026-02-18 22:16:07 +00:00

58 lines
2 KiB
Bash

#!/usr/bin/env bats
load 'test_helpers/utilities.bash'
load 'test_helpers/assertions.bash'
@test "HDX-1514: should infer fatal log level" {
emit_otel_data "http://localhost:4318" "data/severity-inference/infer-fatal"
sleep 1
assert_test_data "data/severity-inference/infer-fatal"
}
@test "HDX-1514: should infer error log level" {
emit_otel_data "http://localhost:4318" "data/severity-inference/infer-error"
sleep 1
assert_test_data "data/severity-inference/infer-error"
}
@test "HDX-1514: should infer warn log level" {
emit_otel_data "http://localhost:4318" "data/severity-inference/infer-warn"
sleep 1
assert_test_data "data/severity-inference/infer-warn"
}
@test "HDX-1514: should infer debug log level" {
emit_otel_data "http://localhost:4318" "data/severity-inference/infer-debug"
sleep 1
assert_test_data "data/severity-inference/infer-debug"
}
@test "HDX-1514: should infer trace log level" {
emit_otel_data "http://localhost:4318" "data/severity-inference/infer-trace"
sleep 1
assert_test_data "data/severity-inference/infer-trace"
}
@test "HDX-1514: should infer info log level" {
emit_otel_data "http://localhost:4318" "data/severity-inference/infer-info"
sleep 1
assert_test_data "data/severity-inference/infer-info"
}
@test "HDX-1514: should skip inference if severity values are defined on the input" {
emit_otel_data "http://localhost:4318" "data/severity-inference/skip-infer"
sleep 1
assert_test_data "data/severity-inference/skip-infer"
}
@test "should not infer severity from keywords embedded mid-word" {
emit_otel_data "http://localhost:4318" "data/severity-inference/no-infer-substring"
sleep 1
assert_test_data "data/severity-inference/no-infer-substring"
}
@test "should infer severity from superstring keywords like WARNING and CRITICAL" {
emit_otel_data "http://localhost:4318" "data/severity-inference/infer-superstring"
sleep 1
assert_test_data "data/severity-inference/infer-superstring"
}