InfluxDB: metricFindQuery migration to backend (#44546)
* Send metricFindQuery to backend * Added feature toggle * Changed flag name * metricFindQuery backend * Added test for metricFindQuery backend parse * Added test for show tag values * Test for metricFindQueries * Updated tests * Put back comment * Case insensitive in transformRows * Check length ov value pair * Sep tests * Updated valuePair index
This commit is contained in:
@@ -91,6 +91,85 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Influxdb response parser should parse metricFindQueries normally", func(t *testing.T) {
|
||||
parser := &ResponseParser{}
|
||||
|
||||
response := `
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"series": [
|
||||
{
|
||||
"refId": "metricFindQuery",
|
||||
"name": "cpu",
|
||||
"values": [
|
||||
["cpu"],
|
||||
["disk"],
|
||||
["logs"]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
|
||||
var queries []Query
|
||||
queries = append(queries, Query{RefID: "metricFindQuery"})
|
||||
newField := data.NewField("value", nil, []string{
|
||||
"cpu", "disk", "logs",
|
||||
})
|
||||
testFrame := data.NewFrame("cpu",
|
||||
newField,
|
||||
)
|
||||
|
||||
result := parser.Parse(prepare(response), queries)
|
||||
|
||||
frame := result.Responses["metricFindQuery"]
|
||||
if diff := cmp.Diff(testFrame, frame.Frames[0], data.FrameTestCompareOptions()...); diff != "" {
|
||||
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Influxdb response parser should parse metricFindQueries->SHOW TAG VALUES normally", func(t *testing.T) {
|
||||
parser := &ResponseParser{}
|
||||
|
||||
response := `
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"series": [
|
||||
{
|
||||
"name": "cpu",
|
||||
"values": [
|
||||
["values", "cpu-total"],
|
||||
["values", "cpu0"],
|
||||
["values", "cpu1"]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
|
||||
var queries []Query
|
||||
queries = append(queries, Query{RawQuery: "SHOW TAG VALUES", RefID: "metricFindQuery"})
|
||||
newField := data.NewField("value", nil, []string{
|
||||
"cpu-total", "cpu0", "cpu1",
|
||||
})
|
||||
testFrame := data.NewFrame("cpu",
|
||||
newField,
|
||||
)
|
||||
|
||||
result := parser.Parse(prepare(response), queries)
|
||||
|
||||
frame := result.Responses["metricFindQuery"]
|
||||
if diff := cmp.Diff(testFrame, frame.Frames[0], data.FrameTestCompareOptions()...); diff != "" {
|
||||
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Influxdb response parser should parse two responses with different refIDs", func(t *testing.T) {
|
||||
parser := &ResponseParser{}
|
||||
|
||||
@@ -130,7 +209,12 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
||||
"series": [
|
||||
{
|
||||
"name": "cpu",
|
||||
"columns": ["time","mean"]
|
||||
"columns": ["time","cpu"],
|
||||
"values": [
|
||||
["values", "cpu-total"],
|
||||
["values", "cpu0"],
|
||||
["values", "cpu1"]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user