Skip to content

Commit

Permalink
test(lokie2e): add trace_id/span_id lookup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jul 3, 2024
1 parent 9049a51 commit 0a01405
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions integration/lokie2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ func runTest(
{`{trace_id=~"AF3600.+000C517000.+00003"}`, 1},
{`{trace_id="badbadbadbadbadbaddeadbeafbadbad"}`, 0},
{`{trace_id=~"bad.+"}`, 0},
// By span id.
{`{span_id="e3daccf703000003"}`, 1},
{`{span_id="E3DACCF703000003"}`, 1},
{`{span_id=~"E3DA.+F7030000.+3"}`, 1},
{`{span_id="0123456789abcdef"}`, 0},
{`{span_id=~"bad.+"}`, 0},
// By severity.
{`{level="Info"}`, 121},
{`{level="INFO"}`, 121},
Expand Down Expand Up @@ -406,14 +412,24 @@ func runTest(
// Negative line matcher.
{`{http_method=~".+"} != "HEAD"`, len(set.Records) - 22},
{`{http_method=~".+"} !~ "HEAD"`, len(set.Records) - 22},
// Trace to logs.
// Trace to logs (span_id).
{`{http_method=~".+"} |= "e3daccf703000003"`, 1}, // lower case
{`{http_method=~".+"} |= "E3DACCF703000003"`, 1}, // upper case
{`{http_method=~".+"} |= "e3dacCF703000003"`, 1}, // mixed case
// Trace to logs (trace_id).
{`{http_method=~".+"} |= "af36000000000000c517000000000003"`, 1}, // lower case
{`{http_method=~".+"} |= "AF36000000000000C517000000000003"`, 1}, // upper case
{`{http_method=~".+"} |= "aF36000000000000c517000000000003"`, 1}, // mixed case

// Label filter.
{`{http_method=~".+"} | http_method = "GET"`, 21},
{`{http_method=~".+"} | http_method = "HEAD", http_status_code = "500"`, 2},
// Label filter (span_id).
{`{http_method=~".+"} | span_id = "e3daccf703000003"`, 1}, // lower case
{`{http_method=~".+"} | json | span_id = "e3daccf703000003"`, 1}, // lower case
// Label filter (trace_id).
{`{http_method=~".+"} | trace_id = "af36000000000000c517000000000003"`, 1}, // lower case
{`{http_method=~".+"} | json | trace_id = "af36000000000000c517000000000003"`, 1}, // lower case
// Number of lines per protocol.
//
// "HTTP/1.0" 55
Expand Down Expand Up @@ -448,12 +464,6 @@ func runTest(
t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
t.Parallel()

defer func() {
if t.Failed() {
t.Logf("query: \n%s", tt.query)
}
}()

for _, direction := range []lokiapi.Direction{
lokiapi.DirectionForward,
lokiapi.DirectionBackward,
Expand Down Expand Up @@ -596,6 +606,9 @@ func testLogQuery(c *lokiapi.Client, params LogQueryTest) func(*testing.T) {

streams, ok := resp.Data.GetStreamsResult()
require.True(t, ok)
if params.ExpectedEntries > 0 {
require.NotEmpty(t, streams.Result, "unexpected empty result")
}

entries := 0
for _, stream := range streams.Result {
Expand Down

0 comments on commit 0a01405

Please sign in to comment.