Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions adapter/redis_bullmq_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ func TestRedis_BullMQDirectCommands(t *testing.T) {
streamCh := make(chan []redis.XStream, 1)
streamErrCh := make(chan error, 1)
go func() {
// Block: 5s (not 1s) so the XRead does not time out before the
// XAdd below completes its Raft round-trip on slow CI runners.
streams, err := reader.XRead(ctx, &redis.XReadArgs{
Streams: []string{"bull:test:events", "$"},
Count: 10,
Block: time.Second,
Block: 5 * time.Second,
}).Result()
if err != nil {
streamErrCh <- err
Expand Down Expand Up @@ -78,7 +80,7 @@ func TestRedis_BullMQDirectCommands(t *testing.T) {
require.Len(t, streams[0].Messages, 1)
require.Equal(t, "1000-0", streams[0].Messages[0].ID)
require.Equal(t, map[string]any{"event": "waiting", "jobId": "job-1"}, streams[0].Messages[0].Values)
case <-time.After(2 * time.Second):
case <-time.After(6 * time.Second):
t.Fatal("timed out waiting for XREAD result")
}

Expand All @@ -100,7 +102,9 @@ func TestRedis_BullMQDirectCommands(t *testing.T) {
popCh := make(chan *redis.ZWithKey, 1)
popErrCh := make(chan error, 1)
go func() {
res, err := reader.BZPopMin(ctx, time.Second, "bull:test:marker").Result()
// 5s (not 1s) for the same reason as the XRead block above:
// the ZAdd's Raft commit can take longer than 1s on slow CI.
res, err := reader.BZPopMin(ctx, 5*time.Second, "bull:test:marker").Result()
if err != nil {
popErrCh <- err
return
Expand All @@ -123,7 +127,7 @@ func TestRedis_BullMQDirectCommands(t *testing.T) {
require.Equal(t, "bull:test:marker", popped.Key)
require.Equal(t, "10", popped.Member)
require.Equal(t, 10.0, popped.Score)
case <-time.After(2 * time.Second):
case <-time.After(6 * time.Second):
t.Fatal("timed out waiting for BZPOPMIN result")
}

Expand Down
7 changes: 5 additions & 2 deletions adapter/redis_misskey_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ func TestRedis_MisskeyConnectionCompatibility(t *testing.T) {
require.Equal(t, "OK", rdb.Do(ctx, "CLIENT", "SETINFO", "LIB-VER", "5.10.0").Val())
require.Equal(t, "OK", rdb.Do(ctx, "SELECT", "0").Val())

res := rdb.Do(ctx, "SET", "lock:ap-object", "v1", "PX", "200", "NX")
// PX 2000 (not 200) so the NX assertion at the next SET cannot race
// the TTL expiry on slow CI runners where ~200ms easily slips between
// two consecutive Raft-replicated SET commands.
res := rdb.Do(ctx, "SET", "lock:ap-object", "v1", "PX", "2000", "NX")
require.NoError(t, res.Err())
require.Equal(t, "OK", res.Val())

res = rdb.Do(ctx, "SET", "lock:ap-object", "v2", "PX", "200", "NX")
res = rdb.Do(ctx, "SET", "lock:ap-object", "v2", "PX", "2000", "NX")
require.ErrorIs(t, res.Err(), redis.Nil)

getRes := rdb.Do(ctx, "SET", "lock:ap-object", "v3", "EX", "1", "GET")
Expand Down
Loading