From: Nick Porter Date: Tue, 31 Jan 2023 15:47:24 +0000 (+0000) Subject: Tidy and correct redis_ippool test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84b0153b9c7e3993c91b64ee7645a34bcf927ede;p=thirdparty%2Ffreeradius-server.git Tidy and correct redis_ippool test --- diff --git a/src/tests/modules/redis_ippool/release.unlang b/src/tests/modules/redis_ippool/release.unlang index edf7851b326..04482434b1f 100644 --- a/src/tests/modules/redis_ippool/release.unlang +++ b/src/tests/modules/redis_ippool/release.unlang @@ -16,15 +16,11 @@ $INCLUDE cluster_reset.inc redis_ippool { invalid = 1 } -if (updated) { - test_pass -} else { +if (!(updated)) { test_fail } -if (&reply.Framed-IP-Address == 192.168.0.1) { - test_pass -} else { +if (!(&reply.Framed-IP-Address == 192.168.0.1)) { test_fail } @@ -37,54 +33,40 @@ if (&reply.Framed-IP-Address == 192.168.0.1) { redis_ippool { invalid = 1 } -if (updated) { - test_pass -} else { +if (!(updated)) { test_fail } # # Verify the association with the device has been removed # -if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') { - test_pass -} else { +if (!("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0')) { test_fail } # # Verify the hash information is retained # -if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} device)" == '00:11:22:33:44:55') { - test_pass -} else { +if (!("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} device)" == '00:11:22:33:44:55')) { test_fail } -if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') { - test_pass -} else { +if (!("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1')) { test_fail } -if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') { - test_pass -} else { +if (!("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0')) { test_fail } -# Check the ZSCORE -&Tmp-Date-0 := "%l" +# Check the ZSCORE - releasing an address sets the ZSCORE to now - 1 +&Tmp-Date-0 := "%c" -if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 0) { - test_pass -} else { +if (%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) > %(integer:%{Tmp-Date-0})) { test_fail } -if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 10) { - test_pass -} else { +if (%(integer:%{Tmp-Date-0}) - %(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) > 10) { test_fail }