Skip to content

Commit 6f2ed24

Browse files
committed
fix(tests): slow down cluster migration test for fast hardware
The TestClusterReset test was failing on macOS ARM because the slot migration completed before the test could observe the "start" state. Reduce migrate-speed from 128 to 64 and increase data size from 1024 to 2048 elements to ensure the migration takes long enough to observe intermediate states on fast hardware (~32 seconds vs ~8 seconds).
1 parent 76a9dad commit 6f2ed24

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

tests/gocase/integration/cluster/cluster_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,10 @@ func TestClusterReset(t *testing.T) {
574574

575575
t.Run("cannot reset cluster if the db is migrating the slot", func(t *testing.T) {
576576
slotNum := 2
577-
// slow down the migration speed to avoid breaking other test cases
578-
require.NoError(t, rdb0.ConfigSet(ctx, "migrate-speed", "128").Err())
579-
for i := 0; i < 1024; i++ {
577+
// slow down the migration speed to ensure we can observe the "start" state
578+
// before migration completes (especially on fast hardware like macOS ARM)
579+
require.NoError(t, rdb0.ConfigSet(ctx, "migrate-speed", "64").Err())
580+
for i := 0; i < 2048; i++ {
580581
require.NoError(t, rdb0.RPush(ctx, "my-list", fmt.Sprintf("element%d", i)).Err())
581582
}
582583

tests/gocase/integration/replication/slow_consumer_bug_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func TestSlowConsumerBlocksIndefinitely(t *testing.T) {
175175
//
176176
// For this test, we use low values to see the fix in action quickly
177177
master := util.StartServer(t, map[string]string{
178-
"max-replication-lag": "50", // Very low: disconnect when lag > 50 sequences
178+
"max-replication-lag": "50", // Very low: disconnect when lag > 50 sequences
179179
"replication-send-timeout-ms": "3000", // 3 second timeout
180180
})
181181
defer master.Close()

tests/gocase/util/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func PausableTCPProxy(ctx context.Context, t testing.TB, to string, pauseCh <-ch
202202

203203
// Set read deadline to allow checking pause state periodically
204204
if conn, ok := src.(net.Conn); ok {
205-
conn.SetReadDeadline(time.Now().Add(200 * time.Millisecond))
205+
_ = conn.SetReadDeadline(time.Now().Add(200 * time.Millisecond))
206206
}
207207

208208
n, err := src.Read(buffer)
@@ -237,7 +237,7 @@ func PausableTCPProxy(ctx context.Context, t testing.TB, to string, pauseCh <-ch
237237
break LISTEN_LOOP
238238

239239
default:
240-
listener.(*net.TCPListener).SetDeadline(time.Now().Add(100 * time.Millisecond))
240+
_ = listener.(*net.TCPListener).SetDeadline(time.Now().Add(100 * time.Millisecond))
241241
conn, err := listener.Accept()
242242
if err != nil {
243243
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
@@ -259,7 +259,7 @@ func PausableTCPProxy(ctx context.Context, t testing.TB, to string, pauseCh <-ch
259259
// "to_master" = reading from slave (conn), writing to master (dest)
260260
errGrp.Go(copyBytes(dest, conn, "to_slave"))
261261
errGrp.Go(copyBytes(conn, dest, "to_master"))
262-
errGrp.Wait()
262+
_ = errGrp.Wait()
263263
conn.Close()
264264
dest.Close()
265265
}()

0 commit comments

Comments
 (0)