Fixes broken unit tests#1192
Conversation
marc-vanderwal
left a comment
There was a problem hiding this comment.
Looks fine, except for one teeny tiny little thing.
Co-authored-by: Marc van der Wal <103426270+marc-vanderwal@users.noreply.github.com>
There was a problem hiding this comment.
After investigating, I would suggest an alternative fix:
Firstly, the need for making new queries is due to zonemaster/zonemaster-engine#1397, which requires all DNSSEC queries to be re-recorded. I forgot to do it here, sorry. The unit tests do call Zonemaster::Backend::RPCAPI::get_data_from_parent_zone() which does indeed make a DNSSEC query.
While creating and using distinct profiles can also solve the issue, I think the issue can be better addressed in Zonemaster::Backend::Config. When loading profiles, currently Backend will start with an entirely new profile and disregard any values from the effective profile. So a simple one-line fix would be:
$ git diff
diff --git a/lib/Zonemaster/Backend/Config.pm b/lib/Zonemaster/Backend/Config.pm
index 78eba7b..6b59c62 100644
--- a/lib/Zonemaster/Backend/Config.pm
+++ b/lib/Zonemaster/Backend/Config.pm
@@ -93,7 +93,7 @@ sub load_profiles {
foreach my $name ( keys %profile_paths ) {
my $path = $profile_paths{$name};
- my $full_profile = Zonemaster::Engine::Profile->default;
+ my $full_profile = Zonemaster::Engine::Profile->effective;
if ( defined $path ) {
my $json = eval { read_file( $path, err_mode => 'croak' ) } #
// die "Error loading profile '$name': $@";
Regarding the unexpected making of new queries without ZONEMASTER_RECORD=1, this can be explained by the following: in the t/test01.t unit test file, method TestUtil::restore_datafile() is called and sets profile parameter no_network to 1 so it should prevent the sending of new queries. But this is rendered useless as Zonemaster::Backend::TestAgent::run() is called afterwards, which will override the settings in the effective profile with a profile that has been instantiated with default values instead of effective values.
I suggest that you create a new PR instead. |
Done, see #1193. |
|
It's a bit awkward, but it looks right to me. Not saying it's your fault that it's awkward. |
Purpose
Unit test file
t/test01.tleaks queries when network is set to off. A change in .fr NS and DS triggered the tests to break. This PR:t/test01.twith correct expectations on .fr.t/test01.tso that it does not leak queries.t/test01.datato match updates on .fr and updatedtfile.t/idn.tso that it does not leak queries.Context
Issue #1191
How to test this PR