Skip to content

Commit e381182

Browse files
Add IPv6 availability check to skip tests when unavailable (#2674)
Skip IPv6 tests automatically when IPv6 is not available. This fixes the problem that tests fail when IPv6 is not available on the system, which can worry users when they run `make test`. IPv6 availibility is detected by opening a dummy server socket and trying to connect to it using a client socket over IPv6. Fixes #2643 --------- Signed-off-by: diego-ciciani01 <[email protected]> Signed-off-by: Viktor Söderqvist <[email protected]> Co-authored-by: Viktor Söderqvist <[email protected]>
1 parent 10281be commit e381182

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

tests/support/server.tcl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ proc tags_acceptable {tags err_return} {
268268
return 0
269269
}
270270

271+
if {[lsearch $tags "ipv6"] >= 0 && ![is_ipv6_available]} {
272+
set err "IPv6 not available on this system"
273+
return 0
274+
}
275+
271276
return 1
272277
}
273278

tests/test_helper.tcl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,21 @@ proc close_replication_stream {s} {
10021002
return
10031003
}
10041004

1005+
# IPv6 detection utilities
1006+
# for this detection: the socket connection on ::1 address
1007+
proc is_ipv6_available {} {
1008+
if {[catch {
1009+
set server [socket -server dummy -myaddr ::1 0]
1010+
set port [lindex [chan configure $server -sockname] 2]
1011+
set client [socket ::1 $port]
1012+
close $server
1013+
close $client
1014+
}] == 0} {
1015+
return 1
1016+
}
1017+
return 0
1018+
}
1019+
10051020
# With the parallel test running multiple server instances at the same time
10061021
# we need a fast enough computer, otherwise a lot of tests may generate
10071022
# false positives.

tests/unit/introspection.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ start_server {tags {"introspection"}} {
265265
} {}
266266

267267
start_server {tags {"ipv6"} overrides {bind {127.0.0.1 ::1}}} {
268-
test {CLIENT LIST with IPv6 filter} {
268+
test {CLIENT KILL with IPv6 filter} {
269269
set c [valkey ::1 [srv 0 port] 0 $::tls]
270270
$c client setname "client-ipv6"
271271

0 commit comments

Comments
 (0)