Unverified Commit eacccd2a authored by Wen Hui's avatar Wen Hui Committed by GitHub
Browse files

fix sentinel tests error (#8422)

This commit fixes sentinel announces hostnames test error in certain linux environment
Before this commit, we only check localhost is resolved into 127.0.0.1, however in ubuntu
or some other linux environments "localhost" will be resolved into ::1 ipv6 address first if
the network stack is capable.
parent f0c5052a
...@@ -33,13 +33,18 @@ source "../tests/includes/init-tests.tcl" ...@@ -33,13 +33,18 @@ source "../tests/includes/init-tests.tcl"
proc verify_hostname_announced {hostname} { proc verify_hostname_announced {hostname} {
foreach_sentinel_id id { foreach_sentinel_id id {
# Master is reported with its hostname # Master is reported with its hostname
assert_equal [lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 0] $hostname if {![string equal [lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 0] $hostname]} {
return 0
}
# Replicas are reported with their hostnames # Replicas are reported with their hostnames
foreach replica [S $id SENTINEL REPLICAS mymaster] { foreach replica [S $id SENTINEL REPLICAS mymaster] {
assert_equal [dict get $replica ip] $hostname if {![string equal [dict get $replica ip] $hostname]} {
return 0
}
} }
} }
return 1
} }
test "Sentinel announces hostnames" { test "Sentinel announces hostnames" {
...@@ -48,7 +53,7 @@ test "Sentinel announces hostnames" { ...@@ -48,7 +53,7 @@ test "Sentinel announces hostnames" {
# Disable announce-hostnames and confirm IPs are used # Disable announce-hostnames and confirm IPs are used
set_sentinel_config announce-hostnames no set_sentinel_config announce-hostnames no
verify_hostname_announced "127.0.0.1" assert {[verify_hostname_announced "127.0.0.1"] || [verify_hostname_announced "::1"]}
} }
# We need to revert any special configuration because all tests currently # We need to revert any special configuration because all tests currently
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment