Introduce TSDB service (#31520)

* Introduce TSDB service

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
This commit is contained in:
Arve Knudsen
2021-03-08 07:02:49 +01:00
committed by GitHub
co-authored by Erik Sundell Will Browne Torkel Ödegaard Will Browne Zoltán Bedi
parent c899bf3592
commit b79e61656a
203 changed files with 5269 additions and 4776 deletions
+13 -13
View File
@@ -16,9 +16,9 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatchlogs/cloudwatchlogsiface"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/tests/testinfra"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch"
cwapi "github.com/aws/aws-sdk-go/service/cloudwatch"
@@ -69,16 +69,16 @@ func TestQueryCloudWatchMetrics(t *testing.T) {
}
tr := makeCWRequest(t, req, addr)
assert.Equal(t, tsdb.Response{
Results: map[string]*tsdb.QueryResult{
assert.Equal(t, plugins.DataResponse{
Results: map[string]plugins.DataQueryResult{
"A": {
RefId: "A",
RefID: "A",
Meta: simplejson.NewFromAny(map[string]interface{}{
"rowCount": float64(1),
}),
Tables: []*tsdb.Table{
Tables: []plugins.DataTable{
{
Columns: []tsdb.TableColumn{
Columns: []plugins.DataTableColumn{
{
Text: "text",
},
@@ -86,7 +86,7 @@ func TestQueryCloudWatchMetrics(t *testing.T) {
Text: "value",
},
},
Rows: []tsdb.RowValues{
Rows: []plugins.DataRowValues{
{
"Test_MetricName",
"Test_MetricName",
@@ -130,7 +130,7 @@ func TestQueryCloudWatchLogs(t *testing.T) {
}
tr := makeCWRequest(t, req, addr)
dataFrames := tsdb.NewDecodedDataFrames(data.Frames{
dataFrames := plugins.NewDecodedDataFrames(data.Frames{
&data.Frame{
Name: "logGroups",
Fields: []*data.Field{
@@ -145,10 +145,10 @@ func TestQueryCloudWatchLogs(t *testing.T) {
// In the future we should use gocmp instead and ignore this field
_, err := dataFrames.Encoded()
require.NoError(t, err)
assert.Equal(t, tsdb.Response{
Results: map[string]*tsdb.QueryResult{
assert.Equal(t, plugins.DataResponse{
Results: map[string]plugins.DataQueryResult{
"A": {
RefId: "A",
RefID: "A",
Dataframes: dataFrames,
},
},
@@ -156,7 +156,7 @@ func TestQueryCloudWatchLogs(t *testing.T) {
})
}
func makeCWRequest(t *testing.T, req dtos.MetricRequest, addr string) tsdb.Response {
func makeCWRequest(t *testing.T, req dtos.MetricRequest, addr string) plugins.DataResponse {
t.Helper()
buf := bytes.Buffer{}
@@ -179,7 +179,7 @@ func makeCWRequest(t *testing.T, req dtos.MetricRequest, addr string) tsdb.Respo
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
var tr tsdb.Response
var tr plugins.DataResponse
err = json.Unmarshal(buf.Bytes(), &tr)
require.NoError(t, err)