diff options
author | Wen Hui <wen.hui.ware@gmail.com> | 2021-01-30 04:18:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-30 11:18:58 +0200 |
commit | eacccd2acbbebde3e50e14a4d0ade5b1ccc2bc07 (patch) | |
tree | a37243476b941478cbb492ea04a91197a14c141a /tests/sentinel/tests | |
parent | f0c5052aa8de084f54b3eda7848f17b122907509 (diff) | |
download | redis-eacccd2acbbebde3e50e14a4d0ade5b1ccc2bc07.tar.gz |
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.
Diffstat (limited to 'tests/sentinel/tests')
-rw-r--r-- | tests/sentinel/tests/08-hostname-conf.tcl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/sentinel/tests/08-hostname-conf.tcl b/tests/sentinel/tests/08-hostname-conf.tcl index 45bb56687..be6e42cb0 100644 --- a/tests/sentinel/tests/08-hostname-conf.tcl +++ b/tests/sentinel/tests/08-hostname-conf.tcl @@ -33,13 +33,18 @@ source "../tests/includes/init-tests.tcl" proc verify_hostname_announced {hostname} { foreach_sentinel_id id { # 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 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" { @@ -48,7 +53,7 @@ test "Sentinel announces hostnames" { # Disable announce-hostnames and confirm IPs are used 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 |