Skip to content

Commit 73ddfdd

Browse files
committed
cluster test for getKeyInfo for hll
1 parent 201c69f commit 73ddfdd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

exporter/exporter_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ var (
3333
keysExpiring []string
3434
listKeys []string
3535
singleStringKey string
36-
ts = int32(time.Now().Unix())
3736

3837
dbNumStr = "11"
3938
altDBNumStr = "12"
@@ -457,15 +456,17 @@ func init() {
457456
log.SetLevel(log.InfoLevel)
458457
}
459458

459+
testTimestamp := time.Now().Unix()
460+
460461
for _, n := range []string{"john", "paul", "ringo", "george"} {
461-
keys = append(keys, fmt.Sprintf("key_%s_%d", n, ts))
462+
keys = append(keys, fmt.Sprintf("key_%s_%d", n, testTimestamp))
462463
}
463464

464-
singleStringKey = fmt.Sprintf("key_string_%d", ts)
465+
singleStringKey = fmt.Sprintf("key_string_%d", testTimestamp)
465466

466467
listKeys = append(listKeys, "beatles_list")
467468

468469
for _, n := range []string{"A.J.", "Howie", "Nick", "Kevin", "Brian"} {
469-
keysExpiring = append(keysExpiring, fmt.Sprintf("key_exp_%s_%d", n, ts))
470+
keysExpiring = append(keysExpiring, fmt.Sprintf("key_exp_%s_%d", n, testTimestamp))
470471
}
471472
}

exporter/keys_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ func TestClusterKeyValuesAndSizes(t *testing.T) {
102102
CheckSingleKeys: dbNumStrFull + "=" + url.QueryEscape(keys[0]),
103103
IsCluster: true},
104104
)
105+
ts := httptest.NewServer(e)
106+
defer ts.Close()
105107

106108
uri := os.Getenv("TEST_REDIS_CLUSTER_MASTER_URI")
107109

@@ -134,6 +136,11 @@ func TestClusterKeyValuesAndSizes(t *testing.T) {
134136
t.Errorf("didn't find %s", k)
135137
}
136138
}
139+
140+
body := downloadURL(t, ts.URL+"/metrics")
141+
if !strings.Contains(body, `redis_key_value{db="db0",key="`+TestHllName+`"} 3`) {
142+
t.Errorf("Expected metric `redis_key_value` with value 2 but got:\n%s", body)
143+
}
137144
}
138145
}
139146

0 commit comments

Comments
 (0)