diff options
author | Wen Hui <wen.hui.ware@gmail.com> | 2022-07-04 11:31:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-04 10:31:12 -0500 |
commit | f620e6ac739191690fcd48dbbc8164ea256a95fc (patch) | |
tree | 658fce9037e7e328fc683b5e8a111315791e6484 /tests | |
parent | a3704d4e87b65a9c071b9dd1ead04cc338d3bc18 (diff) | |
download | redis-f620e6ac739191690fcd48dbbc8164ea256a95fc.tar.gz |
Add tests for error messages during slot migrations (#10449)
* Add tests for error messages during slot migrations
Co-authored-by: Ubuntu <lucas.guang.yang1@huawei.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cluster/tests/29-slot-migration-response.tcl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/cluster/tests/29-slot-migration-response.tcl b/tests/cluster/tests/29-slot-migration-response.tcl new file mode 100644 index 000000000..060cc8d4e --- /dev/null +++ b/tests/cluster/tests/29-slot-migration-response.tcl @@ -0,0 +1,50 @@ +# Tests for the response of slot migrations. + +source "../tests/includes/init-tests.tcl" +source "../tests/includes/utils.tcl" + +test "Create a 2 nodes cluster" { + create_cluster 2 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 in the cluster" { + for {set i 0} {$i < 5000} {incr i} { + $cluster set $i $i + assert { [$cluster get $i] eq $i } + } +} + +test "Test cluster responses during migration of slot x" { + + set slot 10 + array set nodefrom [$cluster masternode_for_slot $slot] + array set nodeto [$cluster masternode_notfor_slot $slot] + + $nodeto(link) cluster setslot $slot importing $nodefrom(id) + $nodefrom(link) cluster setslot $slot migrating $nodeto(id) + + # Get a key from that slot + set key [$nodefrom(link) cluster GETKEYSINSLOT $slot "1"] + + # MOVED REPLY + assert_error "*MOVED*" {$nodeto(link) set $key "newVal"} + + # ASK REPLY + assert_error "*ASK*" {$nodefrom(link) set "abc{$key}" "newVal"} + + # UNSTABLE REPLY + assert_error "*TRYAGAIN*" {$nodefrom(link) mset "a{$key}" "newVal" $key "newVal2"} +} + +config_set_all_nodes cluster-allow-replica-migration yes |