20-half-migrated-slot.tcl 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # Tests for fixing migrating slot at all stages:
  2. # 1. when migration is half inited on "migrating" node
  3. # 2. when migration is half inited on "importing" node
  4. # 3. migration inited, but not finished
  5. # 4. migration is half finished on "migrating" node
  6. # 5. migration is half finished on "importing" node
  7. # TODO: Test is currently disabled until it is stabilized (fixing the test
  8. # itself or real issues in Redis).
  9. if {false} {
  10. source "../tests/includes/init-tests.tcl"
  11. source "../tests/includes/utils.tcl"
  12. test "Create a 2 nodes cluster" {
  13. create_cluster 2 0
  14. config_set_all_nodes cluster-allow-replica-migration no
  15. }
  16. test "Cluster is up" {
  17. assert_cluster_state ok
  18. }
  19. set cluster [redis_cluster 127.0.0.1:[get_instance_attrib redis 0 port]]
  20. catch {unset nodefrom}
  21. catch {unset nodeto}
  22. proc reset_cluster {} {
  23. uplevel 1 {
  24. $cluster refresh_nodes_map
  25. array set nodefrom [$cluster masternode_for_slot 609]
  26. array set nodeto [$cluster masternode_notfor_slot 609]
  27. }
  28. }
  29. reset_cluster
  30. $cluster set aga xyz
  31. test "Half init migration in 'migrating' is fixable" {
  32. assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
  33. fix_cluster $nodefrom(addr)
  34. assert_equal "xyz" [$cluster get aga]
  35. }
  36. test "Half init migration in 'importing' is fixable" {
  37. assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
  38. fix_cluster $nodefrom(addr)
  39. assert_equal "xyz" [$cluster get aga]
  40. }
  41. test "Init migration and move key" {
  42. assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
  43. assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
  44. assert_equal {OK} [$nodefrom(link) migrate $nodeto(host) $nodeto(port) aga 0 10000]
  45. wait_for_cluster_propagation
  46. assert_equal "xyz" [$cluster get aga]
  47. fix_cluster $nodefrom(addr)
  48. assert_equal "xyz" [$cluster get aga]
  49. }
  50. reset_cluster
  51. test "Move key again" {
  52. wait_for_cluster_propagation
  53. assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
  54. assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
  55. assert_equal {OK} [$nodefrom(link) migrate $nodeto(host) $nodeto(port) aga 0 10000]
  56. wait_for_cluster_propagation
  57. assert_equal "xyz" [$cluster get aga]
  58. }
  59. test "Half-finish migration" {
  60. # half finish migration on 'migrating' node
  61. assert_equal {OK} [$nodefrom(link) cluster setslot 609 node $nodeto(id)]
  62. fix_cluster $nodefrom(addr)
  63. assert_equal "xyz" [$cluster get aga]
  64. }
  65. reset_cluster
  66. test "Move key back" {
  67. # 'aga' key is in 609 slot
  68. assert_equal {OK} [$nodefrom(link) cluster setslot 609 migrating $nodeto(id)]
  69. assert_equal {OK} [$nodeto(link) cluster setslot 609 importing $nodefrom(id)]
  70. assert_equal {OK} [$nodefrom(link) migrate $nodeto(host) $nodeto(port) aga 0 10000]
  71. assert_equal "xyz" [$cluster get aga]
  72. }
  73. test "Half-finish importing" {
  74. # Now we half finish 'importing' node
  75. assert_equal {OK} [$nodeto(link) cluster setslot 609 node $nodeto(id)]
  76. fix_cluster $nodefrom(addr)
  77. assert_equal "xyz" [$cluster get aga]
  78. }
  79. config_set_all_nodes cluster-allow-replica-migration yes
  80. }