From 7b6f640c9bd52987fcf19fd498c01534d4d9609d Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 11 Jul 2024 00:13:30 -0400 Subject: [PATCH 1/5] ci: Remove Red Hat UBI 7 UBI 7 is at end of maintenance and can't run newer versions of node used by some workflows. --- .github/workflows/ci.yml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b40407..8ad8ff9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,21 +64,11 @@ jobs: - fedora:rawhide - almalinux:8 - almalinux:latest - # RedHat UBI is mostly garbage due to a profound lack of basic - # packages. It is tested anyway because it's the closest available - # approximation of RHEL, aside from AlmaLinux. Some of the packages - # needed for some tests aren't available, so those tests will be - # skipped. I guess it's still better than nothing. - - registry.access.redhat.com/ubi7/ubi:latest runs-on: ubuntu-latest container: image: ${{ matrix.image }} steps: - - if: ${{ matrix.image != 'registry.access.redhat.com/ubi7/ubi:latest' }} - uses: actions/checkout@v4 - # ubi7 is too old for checkout@v4. - - if: ${{ matrix.image == 'registry.access.redhat.com/ubi7/ubi:latest' }} - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: enable repositories (AlmaLinux 8) if: ${{ matrix.image == 'almalinux:8' }} run: | @@ -93,12 +83,7 @@ jobs: # The --skip-broken argument works around RedHat UBI's missing packages. # (They're only used for testing, so it's OK to not install them.) run: | - inst="dnf --refresh --skip-broken install -y" - case '${{ matrix.image }}' in - # RedHat UBI 7 (RHEL 7) doesn't have dnf. - *ubi7*) inst="yum --skip-broken install -y";; - esac - ${inst} \ + dnf --refresh --skip-broken install -y \ automake \ findutils \ iproute \ From 6e7a4fb460a75cd7620ee66c9b9feab5c9708f20 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 10 Jul 2024 20:07:03 -0400 Subject: [PATCH 2/5] Split subtest into two subtests This makes it easier to debug failures. --- t/get_ip_from_if.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/t/get_ip_from_if.pl b/t/get_ip_from_if.pl index 6f08e5d..1b1cd35 100644 --- a/t/get_ip_from_if.pl +++ b/t/get_ip_from_if.pl @@ -39,7 +39,7 @@ subtest "get_ip_from_interface tests" => sub { } }; -subtest "Get default interface and IP for test system" => sub { +subtest "Get default interface and IP for test system (IPv4)" => sub { my $interface = ddclient::get_default_interface(4); if ($interface) { isnt($interface, "lo", "Check for loopback 'lo'"); @@ -49,7 +49,10 @@ subtest "Get default interface and IP for test system" => sub { is($ip1, $ip2, "Check IPv4 from default interface"); ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)"); } - $interface = ddclient::get_default_interface(6); +}; + +subtest "Get default interface and IP for test system (IPv6)" => sub { + my $interface = ddclient::get_default_interface(6); if ($interface) { isnt($interface, "lo", "Check for loopback 'lo'"); isnt($interface, "lo0", "Check for loopback 'lo0'"); From 01d2db06c1fc7003adf584a8849ac75f065a302c Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 10 Jul 2024 20:11:02 -0400 Subject: [PATCH 3/5] Invert conditions for readability --- t/get_ip_from_if.pl | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/t/get_ip_from_if.pl b/t/get_ip_from_if.pl index 1b1cd35..f49baed 100644 --- a/t/get_ip_from_if.pl +++ b/t/get_ip_from_if.pl @@ -41,26 +41,24 @@ subtest "get_ip_from_interface tests" => sub { subtest "Get default interface and IP for test system (IPv4)" => sub { my $interface = ddclient::get_default_interface(4); - if ($interface) { - isnt($interface, "lo", "Check for loopback 'lo'"); - isnt($interface, "lo0", "Check for loopback 'lo0'"); - my $ip1 = ddclient::get_ip_from_interface("default", 4); - my $ip2 = ddclient::get_ip_from_interface($interface, 4); - is($ip1, $ip2, "Check IPv4 from default interface"); - ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)"); - } + return if !$interface; + isnt($interface, "lo", "Check for loopback 'lo'"); + isnt($interface, "lo0", "Check for loopback 'lo0'"); + my $ip1 = ddclient::get_ip_from_interface("default", 4); + my $ip2 = ddclient::get_ip_from_interface($interface, 4); + is($ip1, $ip2, "Check IPv4 from default interface"); + ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)"); }; subtest "Get default interface and IP for test system (IPv6)" => sub { my $interface = ddclient::get_default_interface(6); - if ($interface) { - isnt($interface, "lo", "Check for loopback 'lo'"); - isnt($interface, "lo0", "Check for loopback 'lo0'"); - my $ip1 = ddclient::get_ip_from_interface("default", 6); - my $ip2 = ddclient::get_ip_from_interface($interface, 6); - is($ip1, $ip2, "Check IPv6 from default interface"); - ok(ddclient::is_ipv6($ip1), "Valid IPv6 from get_ip_from_interface($interface)"); - } + return if !$interface; + isnt($interface, "lo", "Check for loopback 'lo'"); + isnt($interface, "lo0", "Check for loopback 'lo0'"); + my $ip1 = ddclient::get_ip_from_interface("default", 6); + my $ip2 = ddclient::get_ip_from_interface($interface, 6); + is($ip1, $ip2, "Check IPv6 from default interface"); + ok(ddclient::is_ipv6($ip1), "Valid IPv6 from get_ip_from_interface($interface)"); }; done_testing(); From 6af76afde9231079136dfaef58c1944494782dd0 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 10 Jul 2024 20:12:18 -0400 Subject: [PATCH 4/5] Use `skip_all` if test precondition is not met Subtests can't have zero checks. --- t/get_ip_from_if.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/get_ip_from_if.pl b/t/get_ip_from_if.pl index f49baed..61943c2 100644 --- a/t/get_ip_from_if.pl +++ b/t/get_ip_from_if.pl @@ -41,7 +41,7 @@ subtest "get_ip_from_interface tests" => sub { subtest "Get default interface and IP for test system (IPv4)" => sub { my $interface = ddclient::get_default_interface(4); - return if !$interface; + plan(skip_all => 'no IPv4 interface') if !$interface; isnt($interface, "lo", "Check for loopback 'lo'"); isnt($interface, "lo0", "Check for loopback 'lo0'"); my $ip1 = ddclient::get_ip_from_interface("default", 4); @@ -52,7 +52,7 @@ subtest "Get default interface and IP for test system (IPv4)" => sub { subtest "Get default interface and IP for test system (IPv6)" => sub { my $interface = ddclient::get_default_interface(6); - return if !$interface; + plan(skip_all => 'no IPv6 interface') if !$interface; isnt($interface, "lo", "Check for loopback 'lo'"); isnt($interface, "lo0", "Check for loopback 'lo0'"); my $ip1 = ddclient::get_ip_from_interface("default", 6); From fa0bfde3cb2e4972b68060760facd88e975896dc Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 10 Jul 2024 22:39:33 -0400 Subject: [PATCH 5/5] Don't assume the default interface has a globally routable IP --- t/get_ip_from_if.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/get_ip_from_if.pl b/t/get_ip_from_if.pl index 61943c2..15c66a1 100644 --- a/t/get_ip_from_if.pl +++ b/t/get_ip_from_if.pl @@ -47,7 +47,10 @@ subtest "Get default interface and IP for test system (IPv4)" => sub { my $ip1 = ddclient::get_ip_from_interface("default", 4); my $ip2 = ddclient::get_ip_from_interface($interface, 4); is($ip1, $ip2, "Check IPv4 from default interface"); - ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)"); + SKIP: { + skip('default interface does not have an appropriate IPv4 addresses') if !$ip1; + ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)"); + } }; subtest "Get default interface and IP for test system (IPv6)" => sub { @@ -58,7 +61,10 @@ subtest "Get default interface and IP for test system (IPv6)" => sub { my $ip1 = ddclient::get_ip_from_interface("default", 6); my $ip2 = ddclient::get_ip_from_interface($interface, 6); is($ip1, $ip2, "Check IPv6 from default interface"); - ok(ddclient::is_ipv6($ip1), "Valid IPv6 from get_ip_from_interface($interface)"); + SKIP: { + skip('default interface does not have an appropriate IPv6 addresses') if !$ip1; + ok(ddclient::is_ipv6($ip1), "Valid IPv6 from get_ip_from_interface($interface)"); + } }; done_testing();