Skip to content

Commit 37f5699

Browse files
authored
Add valkey (standalone and cluster) to integration tests (#460)
1 parent a8d9577 commit 37f5699

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

broker_redis_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func getUniquePrefix() string {
2626

2727
func newTestRedisBroker(tb testing.TB, n *Node, useStreams bool, useCluster bool, port int) *RedisBroker {
2828
if useCluster {
29-
return NewTestRedisBrokerCluster(tb, n, getUniquePrefix(), useStreams)
29+
return NewTestRedisBrokerCluster(tb, n, getUniquePrefix(), useStreams, port)
3030
}
3131
return NewTestRedisBroker(tb, n, getUniquePrefix(), useStreams, port)
3232
}
@@ -77,7 +77,7 @@ func NewTestRedisBroker(tb testing.TB, n *Node, prefix string, useStreams bool,
7777
return e
7878
}
7979

80-
func NewTestRedisBrokerCluster(tb testing.TB, n *Node, prefix string, useStreams bool) *RedisBroker {
80+
func NewTestRedisBrokerCluster(tb testing.TB, n *Node, prefix string, useStreams bool, port int) *RedisBroker {
8181
tb.Helper()
8282

8383
numClusterNodes := 3
@@ -91,7 +91,7 @@ func NewTestRedisBrokerCluster(tb testing.TB, n *Node, prefix string, useStreams
9191
var clusterAddresses []string
9292

9393
for i := 0; i < numClusterNodes; i++ {
94-
clusterAddresses = append(clusterAddresses, net.JoinHostPort("127.0.0.1", strconv.Itoa(7000+i)))
94+
clusterAddresses = append(clusterAddresses, net.JoinHostPort("127.0.0.1", strconv.Itoa(port+i)))
9595
}
9696

9797
redisConf := RedisShardConfig{
@@ -179,11 +179,14 @@ type historyRedisTest struct {
179179

180180
var historyRedisTests = []historyRedisTest{
181181
{"rd_single_list", false, false, 6379},
182+
{"vk_single_list", false, false, 8379},
182183
{"rd_single_strm", true, false, 6379},
184+
{"vk_single_strm", true, false, 8379},
183185
{"df_single_list", false, false, 7379},
184186
{"df_single_strm", true, false, 7379},
185-
{"rd_cluster_list", false, true, 0},
186-
{"rd_cluster_strm", true, true, 0},
187+
{"rd_cluster_list", false, true, 7000},
188+
{"rd_cluster_strm", true, true, 7000},
189+
{"vk_cluster_strm", true, true, 8000},
187190
}
188191

189192
type noHistoryRedisTest struct {
@@ -195,6 +198,7 @@ type noHistoryRedisTest struct {
195198
var noHistoryRedisTests = []noHistoryRedisTest{
196199
{"rd_single", false, 6379},
197200
{"df_single", false, 7379},
201+
{"vk_single", false, 8379},
198202
{"rd_cluster", false, 0},
199203
}
200204

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ services:
55
image: redis:${REDIS_VERSION:-7}-alpine
66
ports:
77
- "6379:6379"
8+
valkey:
9+
image: valkey/valkey:${VALKEY_VERSION:-8}-alpine
10+
ports:
11+
- "8379:6379"
812
dragonflydb:
913
image: docker.dragonflydb.io/dragonflydb/dragonfly:v1.19.0
1014
ports:
@@ -36,3 +40,18 @@ services:
3640
- "7000:7000"
3741
- "7001:7001"
3842
- "7002:7002"
43+
valkey-cluster:
44+
image: valkey/valkey:${VALKEY_VERSION:-8}-alpine
45+
entrypoint:
46+
- /bin/sh
47+
- -c
48+
- |
49+
valkey-server --port 8000 --save "" --appendonly no --cluster-enabled yes --cluster-config-file 8000.conf &
50+
valkey-server --port 8001 --save "" --appendonly no --cluster-enabled yes --cluster-config-file 8001.conf &
51+
valkey-server --port 8002 --save "" --appendonly no --cluster-enabled yes --cluster-config-file 8002.conf &
52+
while ! valkey-cli --cluster create 127.0.0.1:8000 127.0.0.1:8001 127.0.0.1:8002 --cluster-yes; do sleep 1; done
53+
wait
54+
ports:
55+
- "8000:8000"
56+
- "8001:8001"
57+
- "8002:8002"

presence_redis_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
func newTestRedisPresenceManager(tb testing.TB, n *Node, useCluster bool, userMapping, hashFieldTTL bool, port int) *RedisPresenceManager {
1818
if useCluster {
19-
return NewTestRedisPresenceManagerClusterWithPrefix(tb, n, getUniquePrefix(), userMapping)
19+
return NewTestRedisPresenceManagerClusterWithPrefix(tb, n, getUniquePrefix(), userMapping, port)
2020
}
2121
return NewTestRedisPresenceManagerWithPrefix(tb, n, getUniquePrefix(), userMapping, hashFieldTTL, port)
2222
}
@@ -50,9 +50,9 @@ func NewTestRedisPresenceManagerWithPrefix(tb testing.TB, n *Node, prefix string
5050
return pm
5151
}
5252

53-
func NewTestRedisPresenceManagerClusterWithPrefix(tb testing.TB, n *Node, prefix string, userMapping bool) *RedisPresenceManager {
53+
func NewTestRedisPresenceManagerClusterWithPrefix(tb testing.TB, n *Node, prefix string, userMapping bool, port int) *RedisPresenceManager {
5454
redisConf := RedisShardConfig{
55-
ClusterAddresses: []string{"localhost:7000", "localhost:7001", "localhost:7002"},
55+
ClusterAddresses: []string{"localhost:" + strconv.Itoa(port), "localhost:" + strconv.Itoa(port+1), "localhost:" + strconv.Itoa(port+2)},
5656
IOTimeout: 10 * time.Second,
5757
}
5858
s, err := NewRedisShard(n, redisConf)
@@ -84,7 +84,9 @@ type redisPresenceTest struct {
8484
var redisPresenceTests = []redisPresenceTest{
8585
{"rd_single", false, 6379},
8686
{"df_single", false, 7379},
87-
{"rd_cluster", true, 0},
87+
{"vk_single", false, 8379},
88+
{"rd_cluster", true, 7000},
89+
{"vk_cluster", true, 8000},
8890
}
8991

9092
func excludeClusterPresenceTests(tests []redisPresenceTest) []redisPresenceTest {

0 commit comments

Comments
 (0)