Skip to content

Commit

Permalink
Add valkey (standalone and cluster) to integration tests (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia authored Feb 14, 2025
1 parent a8d9577 commit 37f5699
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
14 changes: 9 additions & 5 deletions broker_redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func getUniquePrefix() string {

func newTestRedisBroker(tb testing.TB, n *Node, useStreams bool, useCluster bool, port int) *RedisBroker {
if useCluster {
return NewTestRedisBrokerCluster(tb, n, getUniquePrefix(), useStreams)
return NewTestRedisBrokerCluster(tb, n, getUniquePrefix(), useStreams, port)
}
return NewTestRedisBroker(tb, n, getUniquePrefix(), useStreams, port)
}
Expand Down Expand Up @@ -77,7 +77,7 @@ func NewTestRedisBroker(tb testing.TB, n *Node, prefix string, useStreams bool,
return e
}

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

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

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

redisConf := RedisShardConfig{
Expand Down Expand Up @@ -179,11 +179,14 @@ type historyRedisTest struct {

var historyRedisTests = []historyRedisTest{
{"rd_single_list", false, false, 6379},
{"vk_single_list", false, false, 8379},
{"rd_single_strm", true, false, 6379},
{"vk_single_strm", true, false, 8379},
{"df_single_list", false, false, 7379},
{"df_single_strm", true, false, 7379},
{"rd_cluster_list", false, true, 0},
{"rd_cluster_strm", true, true, 0},
{"rd_cluster_list", false, true, 7000},
{"rd_cluster_strm", true, true, 7000},
{"vk_cluster_strm", true, true, 8000},
}

type noHistoryRedisTest struct {
Expand All @@ -195,6 +198,7 @@ type noHistoryRedisTest struct {
var noHistoryRedisTests = []noHistoryRedisTest{
{"rd_single", false, 6379},
{"df_single", false, 7379},
{"vk_single", false, 8379},
{"rd_cluster", false, 0},
}

Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ services:
image: redis:${REDIS_VERSION:-7}-alpine
ports:
- "6379:6379"
valkey:
image: valkey/valkey:${VALKEY_VERSION:-8}-alpine
ports:
- "8379:6379"
dragonflydb:
image: docker.dragonflydb.io/dragonflydb/dragonfly:v1.19.0
ports:
Expand Down Expand Up @@ -36,3 +40,18 @@ services:
- "7000:7000"
- "7001:7001"
- "7002:7002"
valkey-cluster:
image: valkey/valkey:${VALKEY_VERSION:-8}-alpine
entrypoint:
- /bin/sh
- -c
- |
valkey-server --port 8000 --save "" --appendonly no --cluster-enabled yes --cluster-config-file 8000.conf &
valkey-server --port 8001 --save "" --appendonly no --cluster-enabled yes --cluster-config-file 8001.conf &
valkey-server --port 8002 --save "" --appendonly no --cluster-enabled yes --cluster-config-file 8002.conf &
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
wait
ports:
- "8000:8000"
- "8001:8001"
- "8002:8002"
10 changes: 6 additions & 4 deletions presence_redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

func newTestRedisPresenceManager(tb testing.TB, n *Node, useCluster bool, userMapping, hashFieldTTL bool, port int) *RedisPresenceManager {
if useCluster {
return NewTestRedisPresenceManagerClusterWithPrefix(tb, n, getUniquePrefix(), userMapping)
return NewTestRedisPresenceManagerClusterWithPrefix(tb, n, getUniquePrefix(), userMapping, port)
}
return NewTestRedisPresenceManagerWithPrefix(tb, n, getUniquePrefix(), userMapping, hashFieldTTL, port)
}
Expand Down Expand Up @@ -50,9 +50,9 @@ func NewTestRedisPresenceManagerWithPrefix(tb testing.TB, n *Node, prefix string
return pm
}

func NewTestRedisPresenceManagerClusterWithPrefix(tb testing.TB, n *Node, prefix string, userMapping bool) *RedisPresenceManager {
func NewTestRedisPresenceManagerClusterWithPrefix(tb testing.TB, n *Node, prefix string, userMapping bool, port int) *RedisPresenceManager {
redisConf := RedisShardConfig{
ClusterAddresses: []string{"localhost:7000", "localhost:7001", "localhost:7002"},
ClusterAddresses: []string{"localhost:" + strconv.Itoa(port), "localhost:" + strconv.Itoa(port+1), "localhost:" + strconv.Itoa(port+2)},
IOTimeout: 10 * time.Second,
}
s, err := NewRedisShard(n, redisConf)
Expand Down Expand Up @@ -84,7 +84,9 @@ type redisPresenceTest struct {
var redisPresenceTests = []redisPresenceTest{
{"rd_single", false, 6379},
{"df_single", false, 7379},
{"rd_cluster", true, 0},
{"vk_single", false, 8379},
{"rd_cluster", true, 7000},
{"vk_cluster", true, 8000},
}

func excludeClusterPresenceTests(tests []redisPresenceTest) []redisPresenceTest {
Expand Down

0 comments on commit 37f5699

Please sign in to comment.