-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove some unintended network dependencies from the unit tests #1045
Conversation
* Make unit tests not rely on fake glue for out-of-bailiwick nameservers being autocompleted. * Make unit tests add fake delegation information using a method that never attempts to autocomplete glue.
If a "fake delegation" is something like
then the IP address or addresses of ns1.nic.fr and ns.nic.se should be looked up on a resolver (built-in or external). As I read it add_fake_delegation_raw() will instead output 'FAKE_DELEGATION_NO_IP'. Do I read it wrong? |
In a second inspection, I think the idea is to use add_fake_delegation_raw() for unit tests and add_fake_delegation() else. Is that correct? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a Zonemaster::Engine::Nameserver::add_fake_delegation() but I cannot see that it is used.
lib/Zonemaster/Engine.pm
Outdated
if ( $incomplete_delegation ) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this test? Does not add_fake_delegation_raw doing that job?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the differences between add_fake_delegation()
and add_fake_delegation_raw()
. The former has a boolean return type and the latter has a void return type. I kept the return value semantics of add_fake_delegation()
unchanged for compatibility reasons. However I can't see any use cases for the return value. Maybe it would be better to just remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two methods, add_fake_delegation_raw() and add_fake_delegation(), have very much overlap in logic. Why not have just one method and a input variable, say $raw, and if that is set it does not do any lookups for IP addresses? I think that would simplify the code and the understanding of the code.
Good point. I'll change it to use some kind of flag instead. |
lib/Zonemaster/Engine.pm
Outdated
The only recognized flag is C<fill_in_empty_ib>. | ||
This flag is boolean and defaults to true. | ||
If this flag is true, this method updates the given C<$data> by looking up and | ||
filling in some glue addresses. | ||
Specifically the glue addresses for any nameserver name that are out of | ||
bailiwick of the given C<$domain> and that comes with an empty list of | ||
addresses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the name sever name is an strict in-bailiwick then a missing address should never be looked up. What is "ib" in the flag name? Wouldn't "fill_in_empty_ob_glue" be better?
I suggest that the terms in-bailiwick and out-of-bailiwick (hyphened) are used (https://datatracker.ietf.org/doc/html/rfc8499)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make updates.
lib/Zonemaster/Engine.pm
Outdated
Returns `1` if all name servers in C<$data> have non-empty lists of | ||
glue (after they've been filled in) or if `fill_in_empty_ib` is false. | ||
Otherwise it returns `undef`. | ||
|
||
Examples: | ||
|
||
Zonemaster::Engine->add_fake_delegation( | ||
'lysator.liu.se' => { | ||
'ns1.nic.fr' => [ ], | ||
'ns.nic.se' => [ '212.247.7.228', '2a00:801:f0:53::53' ], | ||
'i.ns.se' => [ '194.146.106.22', '2001:67c:1010:5::53' ], | ||
'ns3.nic.se' => [ '212.247.8.152', '2a00:801:f0:211::152' ] | ||
} | ||
}, | ||
); | ||
|
||
will return 1. | ||
returns 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the specification says that undef should be returned, depending on what you mean by glue. The se zone should never include glue for ns1.nic.fr in this case, but I am not sure that add_fake_delegation
judge that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't think the return value is meaningful at all. I only kept it out of the principle to minimize API changes. And I only documented it out of a sense of duty. I was thinking I'd remove the return value entirely in a follow-up PR, but I might as well do it in this one. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I guess fail and success are the possible outcome, if anything is missing should be determined by the testing.
Fail: The data does not match the API for this method and cannot be loaded.
Success: The data matches the API for this method and can be loaded.
Data can be with or without IP address. I guess data can be with our without name server too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if we have other breaking changes in Engine? I looked but I couldn't see anything obvious. I'd rather not force a major version number bump just for this.
lib/Zonemaster/Engine.pm
Outdated
if ( $fill_in_empty_ib ) { | ||
foreach my $name ( keys %{$href} ) { | ||
if ( !@{ $href->{$name} } ) { | ||
if ( !$class->zone( $domain )->is_in_zone( $name ) ) { | ||
my @ips = Zonemaster::LDNS->new->name2addr($name); | ||
push @{ $href->{$name} }, @ips; | ||
} | ||
if ( !@{ $href->{$name} } ) { | ||
$incomplete_delegation = 1; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this fill in a strict in-bailiwick name server's IP address? It should not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not. However misnamed the flag. I'll fix that.
The milestone is till set to v2022.2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments else lgtm, ready to approve afterwards
Purpose
This PR makes the unit tests don't autocomplete fake glue by sending out DNS requests.
Context
Fixes #888.
Changes
A new method Zonemaster::Engine->add_fake_delegation_raw() is factored out from Zonemaster::Engine->add_fake_delegation(). The new method performs the meat of things but without the bells and whistles like autocompleting fake glue and returning a boolean. (I don't think the return value is ever used and it's kind of nonsense anyway. Maybe I should have removed it altogether.)
How to test this PR
sudo tcpdump -nn port 53
and keep it open.make test
and wait for it to complete.