Skip to content

Commit

Permalink
test(lokie2e): ensure that tokens are collected
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jul 16, 2024
1 parent 998771c commit 9eceb31
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions integration/lokie2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"regexp"
"slices"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -533,6 +534,17 @@ func runTest(
[]string{
`Offloading line filters.+|=`,
`Pipeline could be fully offloaded to Clickhouse`,
`Adding hasToken.+HEAD`,
},
},
{
`{http_method=~".+"} |= "HEAD" |= "\"error\": \"ENOENT\""`,
[]string{
`Offloading line filters.+|=`,
`Pipeline could be fully offloaded to Clickhouse`,
`Adding hasToken.+HEAD`,
`Adding hasToken.+error`,
`Adding hasToken.+ENOENT`,
},
},
{
Expand All @@ -547,6 +559,7 @@ func runTest(
[]string{
`Offloading line filters.+|=`,
`Offloading pipeline label filters.+http_method=`,
`Adding hasToken.+HEAD`,
},
},

Expand All @@ -562,6 +575,7 @@ func runTest(
`Offloading line filters.+|=`,
`Pipeline could be fully offloaded to Clickhouse`,
`Sampling could be offloaded to Clickhouse`,
`Adding hasToken.+HEAD`,
},
},
} {
Expand All @@ -587,6 +601,19 @@ func runTest(
entries := streams[0].Values
require.NotEmpty(t, streams, entries)

defer func() {
if !t.Failed() {
return
}
for _, e := range entries {
msg := strings.TrimSpace(e.V)
if strings.Contains(msg, "explain.ch") {
continue
}
t.Log(msg)
}
}()

for _, pattern := range tt.contains {
re, err := regexp.Compile(pattern)
require.NoError(t, err)
Expand All @@ -595,9 +622,8 @@ func runTest(
slices.ContainsFunc(entries, func(s lokiapi.LogEntry) bool {
return re.MatchString(s.V)
}),
"There is should be at least one log entry that matches %q in %#v",
"There is should be at least one log entry that matches %q",
pattern,
entries,
)
}
})
Expand Down

0 comments on commit 9eceb31

Please sign in to comment.