summaryrefslogtreecommitdiffstats
path: root/tests/cluster/tests/21-many-slot-migration.tcl
blob: 1ac73dc99753d594821567eeea4a7ae329a8f41d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Tests for many simultaneous migrations.

# TODO: Test is currently disabled until it is stabilized (fixing the test
# itself or real issues in Redis).

if {false} {

source "../tests/includes/init-tests.tcl"
source "../tests/includes/utils.tcl"

# TODO: This test currently runs without replicas, as failovers (which may
# happen on lower-end CI platforms) are still not handled properly by the
# cluster during slot migration (related to #6339).

test "Create a 10 nodes cluster" {
    create_cluster 10 0
    config_set_all_nodes cluster-allow-replica-migration no
}

test "Cluster is up" {
    assert_cluster_state ok
}

set cluster [redis_cluster 127.0.0.1:[get_instance_attrib redis 0 port]]
catch {unset nodefrom}
catch {unset nodeto}

$cluster refresh_nodes_map

test "Set many keys" {
    for {set i 0} {$i < 40000} {incr i} {
        $cluster set key:$i val:$i
    }
}

test "Keys are accessible" {
    for {set i 0} {$i < 40000} {incr i} {
        assert { [$cluster get key:$i] eq "val:$i" }
    }
}

test "Init migration of many slots" {
    for {set slot 0} {$slot < 1000} {incr slot} {
        array set nodefrom [$cluster masternode_for_slot $slot]
        array set nodeto [$cluster masternode_notfor_slot $slot]

        $nodefrom(link) cluster setslot $slot migrating $nodeto(id)
        $nodeto(link) cluster setslot $slot importing $nodefrom(id)
    }
}

test "Fix cluster" {
    wait_for_cluster_propagation
    fix_cluster $nodefrom(addr)
}

test "Keys are accessible" {
    for {set i 0} {$i < 40000} {incr i} {
        assert { [$cluster get key:$i] eq "val:$i" }
    }
}

config_set_all_nodes cluster-allow-replica-migration yes
}