Skip to content

Commit 5608edf

Browse files
santriseusMikhail
andauthored
Fix TS.INFO error for simple string values. (#159)
* Fix redis time-series error, add integration test. * Format Co-authored-by: Mikhail <[email protected]>
1 parent 5ec4faa commit 5608edf

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

pkg/datasource_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func TestQueryData(t *testing.T) {
176176
PluginContext: backend.PluginContext{},
177177
Headers: nil,
178178
Queries: []backend.DataQuery{
179-
backend.DataQuery{
179+
{
180180
RefID: "",
181181
QueryType: "",
182182
MaxDataPoints: 100,
@@ -212,7 +212,7 @@ func TestQueryDataWithError(t *testing.T) {
212212
PluginContext: backend.PluginContext{},
213213
Headers: nil,
214214
Queries: []backend.DataQuery{
215-
backend.DataQuery{
215+
{
216216
RefID: "",
217217
QueryType: "",
218218
MaxDataPoints: 100,

pkg/redis-time-series.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ func queryTsInfo(qm queryModel, client redisClient) backend.DataResponse {
288288
frame.Fields = append(frame.Fields, field)
289289
case []byte:
290290
frame.Fields = append(frame.Fields, data.NewField(key, nil, []string{string(value)}))
291+
case string:
292+
frame.Fields = append(frame.Fields, data.NewField(key, nil, []string{value}))
291293
case []interface{}:
292294
frame = addFrameFieldsFromArray(value, frame)
293295
default:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// +build integration
2+
3+
package main
4+
5+
import (
6+
"fmt"
7+
"testing"
8+
9+
"github.com/mediocregopher/radix/v3"
10+
"github.com/stretchr/testify/require"
11+
)
12+
13+
/**
14+
* TS.INFO
15+
*/
16+
func TestTSInfoIntegration(t *testing.T) {
17+
// Client
18+
radixClient, _ := radix.NewPool("tcp", fmt.Sprintf("127.0.0.1:%d", integrationTestPort), 10)
19+
client := radixV3Impl{radixClient: radixClient}
20+
21+
// Response
22+
resp := queryTsInfo(queryModel{Command: "ts.info", Key: "test:timeseries2"}, &client)
23+
require.Len(t, resp.Frames, 1)
24+
require.Len(t, resp.Frames[0].Fields, 12)
25+
}

pkg/redis-time-series_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,16 @@ func TestQueryTsInfo(t *testing.T) {
494494
"lastTimestamp": int64(1548149279),
495495
"retentionTime": int64(0),
496496
"chunkCount": int64(1),
497+
"byteField": []byte("byteField"),
497498
"chunkSize": int64(256),
498-
"chunkType": []byte("compressed"),
499+
"chunkType": "compressed",
499500
"duplicatePolicy": interface{}(nil),
500501
"labels": []interface{}{[]interface{}{[]byte("sensor_id"), []byte("2")}, []interface{}{[]byte("area_id"), []byte("32")}},
501502
"sourceKey": interface{}(nil),
502503
"unsupportedType": nil,
503504
"rules": []interface{}{},
504505
},
505-
10,
506+
11,
506507
1,
507508
[]valueToCheckByLabelInResponse{
508509
{frameIndex: 0, fieldName: "totalSamples", rowIndex: 0, value: int64(100)},

0 commit comments

Comments
 (0)