Skip to content

Commit

Permalink
Dont run traces tests when just scraping
Browse files Browse the repository at this point in the history
  • Loading branch information
grcevski committed Feb 2, 2024
1 parent b2e1d86 commit 01f9e39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions test/integration/red_test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/grafana/beyla/test/integration/components/prom"
)

func testClientWithMethodAndStatusCode(t *testing.T, method string, statusCode int, traceIDLookup string) {
func testClientWithMethodAndStatusCode(t *testing.T, method string, statusCode int, traces bool, traceIDLookup string) {
// Eventually, Prometheus would make this query visible
pq := prom.Client{HostPort: prometheusHostPort}
var results []prom.Result
Expand Down Expand Up @@ -50,6 +50,10 @@ func testClientWithMethodAndStatusCode(t *testing.T, method string, statusCode i
assert.LessOrEqual(t, 1, val)
})

if !traces {
return
}

var trace jaeger.Trace
test.Eventually(t, testTimeout, func(t require.TestingT) {
resp, err := http.Get(jaegerQueryURL + fmt.Sprintf("?service=pingclient&operation=%s", method))
Expand Down Expand Up @@ -83,6 +87,11 @@ func testClientWithMethodAndStatusCode(t *testing.T, method string, statusCode i
}

func testREDMetricsForClientHTTPLibrary(t *testing.T) {
testClientWithMethodAndStatusCode(t, "GET", 200, "0000000000000000")
testClientWithMethodAndStatusCode(t, "OPTIONS", 204, "0000000000000001")
testClientWithMethodAndStatusCode(t, "GET", 200, true, "0000000000000000")
testClientWithMethodAndStatusCode(t, "OPTIONS", 204, true, "0000000000000001")
}

func testREDMetricsForClientHTTPLibraryNoTraces(t *testing.T) {
testClientWithMethodAndStatusCode(t, "GET", 200, false, "0000000000000000")
testClientWithMethodAndStatusCode(t, "OPTIONS", 204, false, "0000000000000001")
}
2 changes: 1 addition & 1 deletion test/integration/suites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestSuiteClientPromScrape(t *testing.T) {
)
require.NoError(t, err)
require.NoError(t, compose.Up())
t.Run("Client RED metrics", testREDMetricsForClientHTTPLibrary)
t.Run("Client RED metrics", testREDMetricsForClientHTTPLibraryNoTraces)
t.Run("BPF pinning folder mounted", testBPFPinningMounted)
require.NoError(t, compose.Close())
t.Run("BPF pinning folder unmounted", testBPFPinningUnmounted)
Expand Down

0 comments on commit 01f9e39

Please sign in to comment.