00-base.tcl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Check the basic monitoring and failover capabilities.
  2. source "../tests/includes/init-tests.tcl"
  3. if {$::simulate_error} {
  4. test "This test will fail" {
  5. fail "Simulated error"
  6. }
  7. }
  8. test "Different nodes have different IDs" {
  9. set ids {}
  10. set numnodes 0
  11. foreach_redis_id id {
  12. incr numnodes
  13. # Every node should just know itself.
  14. set nodeid [dict get [get_myself $id] id]
  15. assert {$nodeid ne {}}
  16. lappend ids $nodeid
  17. }
  18. set numids [llength [lsort -unique $ids]]
  19. assert {$numids == $numnodes}
  20. }
  21. test "It is possible to perform slot allocation" {
  22. cluster_allocate_slots 5
  23. }
  24. test "After the join, every node gets a different config epoch" {
  25. set trynum 60
  26. while {[incr trynum -1] != 0} {
  27. # We check that this condition is true for *all* the nodes.
  28. set ok 1 ; # Will be set to 0 every time a node is not ok.
  29. foreach_redis_id id {
  30. set epochs {}
  31. foreach n [get_cluster_nodes $id] {
  32. lappend epochs [dict get $n config_epoch]
  33. }
  34. if {[lsort $epochs] != [lsort -unique $epochs]} {
  35. set ok 0 ; # At least one collision!
  36. }
  37. }
  38. if {$ok} break
  39. after 1000
  40. puts -nonewline .
  41. flush stdout
  42. }
  43. if {$trynum == 0} {
  44. fail "Config epoch conflict resolution is not working."
  45. }
  46. }
  47. test "Nodes should report cluster_state is ok now" {
  48. assert_cluster_state ok
  49. }
  50. test "It is possible to write and read from the cluster" {
  51. cluster_write_test 0
  52. }