2021-03-29 13:52:02 +03:00
|
|
|
# Tests for fixing migrating slot at all stages:
|
|
|
|
# 1. when migration is half inited on "migrating" node
|
|
|
|
# 2. when migration is half inited on "importing" node
|
|
|
|
# 3. migration inited, but not finished
|
|
|
|
# 4. migration is half finished on "migrating" node
|
|
|
|
# 5. migration is half finished on "importing" node
|
2021-04-18 20:51:08 +03:00
|
|
|
|
2024-05-09 10:14:47 +08:00
|
|
|
source tests/support/cluster_util.tcl
|
2021-03-29 13:52:02 +03:00
|
|
|
|
2024-05-09 10:14:47 +08:00
|
|
|
start_cluster 2 0 {tags {external:skip cluster}} {
|
|
|
|
|
|
|
|
config_set_all_nodes cluster-allow-replica-migration no
|
2021-03-29 13:52:02 +03:00
|
|
|
|
|
|
|
test "Cluster is up" {
|
2024-05-09 10:14:47 +08:00
|
|
|
wait_for_cluster_state ok
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
|
|
|
|
2024-05-09 10:14:47 +08:00
|
|
|
set cluster [valkey_cluster 127.0.0.1:[srv 0 port]]
|
2021-03-29 13:52:02 +03:00
|
|
|
catch {unset nodefrom}
|
|
|
|
catch {unset nodeto}
|
|
|
|
|
|
|
|
proc reset_cluster {} {
|
|
|
|
uplevel 1 {
|
|
|
|
$cluster refresh_nodes_map
|
|
|
|
array set nodefrom [$cluster masternode_for_slot 609]
|
|
|
|
array set nodeto [$cluster masternode_notfor_slot 609]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
reset_cluster
|
|
|
|
|
|
|
|
$cluster set aga xyz
|
|
|
|
|
|
|
|
test "Half init migration in 'migrating' is fixable" {
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
|
2021-03-29 13:52:02 +03:00
|
|
|
fix_cluster $nodefrom(addr)
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Half init migration in 'importing' is fixable" {
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
|
2021-03-29 13:52:02 +03:00
|
|
|
fix_cluster $nodefrom(addr)
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Init migration and move key" {
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
|
|
|
|
assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
|
|
|
|
assert_equal {OK} [$nodefrom(link) migrate $nodeto(host) $nodeto(port) aga 0 10000]
|
|
|
|
wait_for_cluster_propagation
|
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
fix_cluster $nodefrom(addr)
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
reset_cluster
|
|
|
|
|
|
|
|
test "Move key again" {
|
2021-04-06 11:57:57 +03:00
|
|
|
wait_for_cluster_propagation
|
|
|
|
assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
|
|
|
|
assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
|
|
|
|
assert_equal {OK} [$nodefrom(link) migrate $nodeto(host) $nodeto(port) aga 0 10000]
|
|
|
|
wait_for_cluster_propagation
|
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Half-finish migration" {
|
|
|
|
# half finish migration on 'migrating' node
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal {OK} [$nodefrom(link) cluster setslot 609 node $nodeto(id)]
|
2021-03-29 13:52:02 +03:00
|
|
|
fix_cluster $nodefrom(addr)
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
reset_cluster
|
|
|
|
|
|
|
|
test "Move key back" {
|
|
|
|
# 'aga' key is in 609 slot
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
|
|
|
|
assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
|
|
|
|
assert_equal {OK} [$nodefrom(link) migrate $nodeto(host) $nodeto(port) aga 0 10000]
|
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Half-finish importing" {
|
|
|
|
# Now we half finish 'importing' node
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal {OK} [$nodeto(link) cluster setslot 609 node $nodeto(id)]
|
2021-03-29 13:52:02 +03:00
|
|
|
fix_cluster $nodefrom(addr)
|
2021-04-06 11:57:57 +03:00
|
|
|
assert_equal "xyz" [$cluster get aga]
|
2021-03-29 13:52:02 +03:00
|
|
|
}
|
2021-04-13 00:00:57 +03:00
|
|
|
|
|
|
|
config_set_all_nodes cluster-allow-replica-migration yes
|
2024-05-09 10:14:47 +08:00
|
|
|
|
|
|
|
} ;# start_cluster
|