Infinite scrolling: Add X-Query-Tag header (#81089)
This commit is contained in:
@@ -332,6 +332,8 @@ func getSupportingQueryHeaderValue(req *http.Request, supportingQueryType Suppor
|
||||
value = "logsample"
|
||||
case SupportingQueryDataSample:
|
||||
value = "datasample"
|
||||
case SupportingQueryInfiniteScroll:
|
||||
value = "infinitescroll"
|
||||
default: //ignore
|
||||
}
|
||||
|
||||
|
||||
@@ -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(`
|
||||
{
|
||||
|
||||
@@ -30,9 +30,10 @@ const (
|
||||
|
||||
// Defines values for SupportingQueryType.
|
||||
const (
|
||||
SupportingQueryTypeDataSample SupportingQueryType = "dataSample"
|
||||
SupportingQueryTypeLogsSample SupportingQueryType = "logsSample"
|
||||
SupportingQueryTypeLogsVolume SupportingQueryType = "logsVolume"
|
||||
SupportingQueryTypeDataSample SupportingQueryType = "dataSample"
|
||||
SupportingQueryTypeInfiniteScroll SupportingQueryType = "infiniteScroll"
|
||||
SupportingQueryTypeLogsSample SupportingQueryType = "logsSample"
|
||||
SupportingQueryTypeLogsVolume SupportingQueryType = "logsVolume"
|
||||
)
|
||||
|
||||
// These are the common properties available to all queries in all datasources.
|
||||
|
||||
@@ -16,10 +16,11 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
SupportingQueryLogsVolume = dataquery.SupportingQueryTypeLogsVolume
|
||||
SupportingQueryLogsSample = dataquery.SupportingQueryTypeLogsSample
|
||||
SupportingQueryDataSample = dataquery.SupportingQueryTypeDataSample
|
||||
SupportingQueryNone SupportingQueryType = "none"
|
||||
SupportingQueryLogsVolume = dataquery.SupportingQueryTypeLogsVolume
|
||||
SupportingQueryLogsSample = dataquery.SupportingQueryTypeLogsSample
|
||||
SupportingQueryDataSample = dataquery.SupportingQueryTypeDataSample
|
||||
SupportingQueryInfiniteScroll = dataquery.SupportingQueryTypeInfiniteScroll
|
||||
SupportingQueryNone SupportingQueryType = "none"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user