mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
InfluxDB: Fix parsing multiple tags on backend mode (#77340)
* Multiple tags separated by comma in the result * A non-flaky unit test
This commit is contained in:
parent
df3184a94a
commit
6b13064cf6
@ -258,6 +258,7 @@ func buildFrameNameFromQuery(row models.Row, column string, frameName []byte, re
|
||||
first := true
|
||||
for k, v := range row.Tags {
|
||||
if !first {
|
||||
frameName = append(frameName, ',')
|
||||
frameName = append(frameName, ' ')
|
||||
} else {
|
||||
first = false
|
||||
|
@ -365,6 +365,46 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
||||
assert.Equal(t, "alias logins.count", result.Frames[1].Name)
|
||||
})
|
||||
|
||||
t.Run("Influxdb response parser when multiple measurement in response", func(t *testing.T) {
|
||||
response := `
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"series": [
|
||||
{
|
||||
"name": "cpu.upc",
|
||||
"columns": ["time","mean"],
|
||||
"tags": {
|
||||
"datacenter": "America",
|
||||
"cluster-name": "Cluster"
|
||||
},
|
||||
"values": [
|
||||
[111,222]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "logins.count",
|
||||
"columns": ["time","mean"],
|
||||
"tags": {
|
||||
"datacenter": "America",
|
||||
"cluster-name": "Cluster"
|
||||
},
|
||||
"values": [
|
||||
[111,222]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
|
||||
query := models.Query{}
|
||||
result := ResponseParse(prepare(response), 200, generateQuery(query))
|
||||
assert.True(t, strings.Contains(result.Frames[0].Name, ","))
|
||||
assert.True(t, strings.Contains(result.Frames[1].Name, ","))
|
||||
})
|
||||
|
||||
t.Run("Influxdb response parser with alias", func(t *testing.T) {
|
||||
response := `
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user