@@ -23,11 +23,6 @@ import (
2323 log "github.com/sirupsen/logrus"
2424)
2525
26- const (
27- TestValue = 1234.56
28- TimeToSleep = 200
29- )
30-
3126var (
3227 keys []string
3328 keysExpiring []string
4136)
4237
4338const (
44- TestSetName = "test-set"
45- TestStreamName = "test-stream"
46- TestHllName = "test-hll"
39+ TestKeysSetName = "test-set"
40+ TestKeysStreamName = "test-stream"
41+ TestKeysHllName = "test-hll"
4742)
4843
4944func getTestExporter () * Exporter {
@@ -75,16 +70,17 @@ func setupKeys(t *testing.T, c redis.Conn, dbNumStr string) error {
7570 // not failing on this one - cluster doesn't allow for SELECT so we log and ignore the error
7671 }
7772
73+ testValue := 1234.56
7874 for _ , key := range keys {
79- if _ , err := c .Do ("SET" , key , TestValue ); err != nil {
75+ if _ , err := c .Do ("SET" , key , testValue ); err != nil {
8076 t .Errorf ("couldn't setup redis, err: %s " , err )
8177 return err
8278 }
8379 }
8480
8581 // set to expire in 300 seconds, should be plenty for a test run
8682 for _ , key := range keysExpiring {
87- if _ , err := c .Do ("SETEX" , key , "300" , TestValue ); err != nil {
83+ if _ , err := c .Do ("SETEX" , key , "300" , testValue ); err != nil {
8884 t .Errorf ("couldn't setup redis, err: %s " , err )
8985 return err
9086 }
@@ -99,25 +95,25 @@ func setupKeys(t *testing.T, c redis.Conn, dbNumStr string) error {
9995 }
10096 }
10197
102- c .Do ("PFADD" , TestHllName , "val1" )
103- c .Do ("PFADD" , TestHllName , "val22" )
104- c .Do ("PFADD" , TestHllName , "val333" )
98+ c .Do ("PFADD" , TestKeysHllName , "val1" )
99+ c .Do ("PFADD" , TestKeysHllName , "val22" )
100+ c .Do ("PFADD" , TestKeysHllName , "val333" )
105101
106- c .Do ("SADD" , TestSetName , "test-val-1" )
107- c .Do ("SADD" , TestSetName , "test-val-2" )
102+ c .Do ("SADD" , TestKeysSetName , "test-val-1" )
103+ c .Do ("SADD" , TestKeysSetName , "test-val-2" )
108104
109105 c .Do ("SET" , singleStringKey , "this-is-a-string" )
110106
111107 // Create test streams
112- c .Do ("XGROUP" , "CREATE" , TestStreamName , "test_group_1" , "$" , "MKSTREAM" )
113- c .Do ("XGROUP" , "CREATE" , TestStreamName , "test_group_2" , "$" , "MKSTREAM" )
114- c .Do ("XADD" , TestStreamName , TestStreamTimestamps [0 ], "field_1" , "str_1" )
115- c .Do ("XADD" , TestStreamName , TestStreamTimestamps [1 ], "field_2" , "str_2" )
108+ c .Do ("XGROUP" , "CREATE" , TestKeysStreamName , "test_group_1" , "$" , "MKSTREAM" )
109+ c .Do ("XGROUP" , "CREATE" , TestKeysStreamName , "test_group_2" , "$" , "MKSTREAM" )
110+ c .Do ("XADD" , TestKeysStreamName , TestStreamTimestamps [0 ], "field_1" , "str_1" )
111+ c .Do ("XADD" , TestKeysStreamName , TestStreamTimestamps [1 ], "field_2" , "str_2" )
116112
117113 // Process messages to assign Consumers to their groups
118- c .Do ("XREADGROUP" , "GROUP" , "test_group_1" , "test_consumer_1" , "COUNT" , "1" , "STREAMS" , TestStreamName , ">" )
119- c .Do ("XREADGROUP" , "GROUP" , "test_group_1" , "test_consumer_2" , "COUNT" , "1" , "STREAMS" , TestStreamName , ">" )
120- c .Do ("XREADGROUP" , "GROUP" , "test_group_2" , "test_consumer_1" , "COUNT" , "1" , "STREAMS" , TestStreamName , "0" )
114+ c .Do ("XREADGROUP" , "GROUP" , "test_group_1" , "test_consumer_1" , "COUNT" , "1" , "STREAMS" , TestKeysStreamName , ">" )
115+ c .Do ("XREADGROUP" , "GROUP" , "test_group_1" , "test_consumer_2" , "COUNT" , "1" , "STREAMS" , TestKeysStreamName , ">" )
116+ c .Do ("XREADGROUP" , "GROUP" , "test_group_2" , "test_consumer_1" , "COUNT" , "1" , "STREAMS" , TestKeysStreamName , "0" )
121117
122118 return nil
123119}
@@ -140,9 +136,9 @@ func deleteKeys(c redis.Conn, dbNumStr string) {
140136 c .Do ("DEL" , key )
141137 }
142138
143- c .Do ("DEL" , TestHllName )
144- c .Do ("DEL" , TestSetName )
145- c .Do ("DEL" , TestStreamName )
139+ c .Do ("DEL" , TestKeysHllName )
140+ c .Do ("DEL" , TestKeysSetName )
141+ c .Do ("DEL" , TestKeysStreamName )
146142 c .Do ("DEL" , singleStringKey )
147143}
148144
0 commit comments