Infinite scrolling: Add X-Query-Tag header (#81089)

This commit is contained in:
Matias Chomicki
2024-01-29 11:24:05 +01:00
committed by GitHub
parent a83e01918a
commit df05c79d91
8 changed files with 41 additions and 8 deletions
+25
View File
@@ -7,6 +7,7 @@ import (
"strings"
"testing"
"github.com/grafana/grafana/pkg/tsdb/loki/kinds/dataquery"
"github.com/stretchr/testify/require"
)
@@ -82,6 +83,30 @@ func TestApiLogVolume(t *testing.T) {
})
}
func TestInfiniteScroll(t *testing.T) {
response := []byte(`
{
"status": "success",
"data": {
"resultType" : "matrix",
"result": []
}
}
`)
t.Run("infinite scrolling queries should set infinite scroll http header", func(t *testing.T) {
called := false
api := makeMockedAPI(200, "application/json", response, func(req *http.Request) {
called = true
require.Equal(t, "Source=infinitescroll", req.Header.Get("X-Query-Tags"))
}, false)
_, err := api.DataQuery(context.Background(), lokiQuery{Expr: "", SupportingQueryType: dataquery.SupportingQueryTypeInfiniteScroll, QueryType: QueryTypeRange}, ResponseOpts{})
require.NoError(t, err)
require.True(t, called)
})
}
func TestApiUrlHandling(t *testing.T) {
response := []byte(`
{