-
Notifications
You must be signed in to change notification settings - Fork 22
Retain the possibility to start a Test Case disabled in the profile #361
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
Conversation
zonemaster/zonemaster-engine#1294 removes the possibility for Zonemaster-Engine to start a Test Case which is explicitly disabled in its profile. This commit retains the possibility by letting Zonemaster-CLI directly modify the profile, and notifying the user with a notice message.
675557c to
a66d559
Compare
|
@mattias-p After the merging of #333, conflicts have arised and are now fixed. I also provided a small refactoring which considers the changes in zonemaster/zonemaster-engine#1294. |
matsduf
left a comment
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.
With this PR on top of zonemaster/zonemaster-engine#1294 I get no output of messages when using --raw:
# zonemaster-cli --profile ~/.zonemaster/profile-zone09-only.json --show-testcase --level info iis.se --test Zone/Zone01 --raw
Loading profile from /home/matsd/.zonemaster/profile-zone09-only.json.
Notice: Engine does not have test case 'zone01' enabled in the profile. Forcing...
It does not help to remove --profile and --test.
When going back to current develop (Engine and CLI) it works as it should.
Without --raw I get the following:
# zonemaster-cli --profile ~/.zonemaster/profile-zone09-only.json --show-testcase --level info iis.se --test Zone/Zone01
Loading profile from /home/matsd/.zonemaster/profile-zone09-only.json.
Seconds Level Testcase Message
======= ======== ============== =======
Notice: Engine does not have test case 'zone01' enabled in the profile. Forcing...
0.00 INFO UNSPECIFIED Using version v4.7.3 of the Zonemaster engine.
0.66 INFO ZONE01 SOA MNAME name server "ns.nic.se" is not listed as NS record for the zone.
I do not think there is any need of the "notice", but if it should be there, it should be above the headline or below all messages, not between the headline and the messages.
lib/Zonemaster/CLI.pm
Outdated
| ( ($method, $module) = $t =~ m#^ ( ( [a-z]+ ) [0-9]{2} ) $#ix ) ) | ||
| { | ||
| if ( not grep( /^$method$/, @{ Zonemaster::Engine::Profile->effective->get( 'test_cases' ) } ) ) { | ||
| say $fh_diag __x( "Notice: Engine does not have test case '$method' enabled in the profile. Forcing..."); |
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 do not see the purpose of this warning message, and especially where it is put.
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.
Updated to display it earlier in the code
matsduf
left a comment
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 still dislike where the "Notice: Engine does not have test case 'zone01' enabled in the profile. Forcing..." message comes in the response. I do not see the purpose of it.
--raw is also meant to be machine-readable output. Now something can come in. Does that make it a V-Major change?
The new line is also added to the JSON output, but before JSON comes. At least jq seems to ignore it.
2b00c6c to
a762c8d
Compare
I have just provided an update to display the message earlier in the code. See commit 08c2a77.
I'm not sure. This is no different that other already present messages such as when loading a custom profile. |
Move input checks earlier in the code Add input check for multiple slash characters Refactoring
a762c8d to
08c2a77
Compare
Nice. |
I know, but this is a new line that you have to ignore. But now I see that they go to |
mattias-p
left a comment
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 had another look at this and I believe I found a couple of misbehaviors. And I have proposals for how to fix them.
Add input validation, based on the content of 'Zonemaster::Engine->all_methods' Construct the 'test_cases' profile property from the combination of all --test switches Refactoring
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.
@mattias-p All your comments have been addressed. See commit 5c68764. Now:
$ cat ../zonemaster-engine/share/custom.json
{
"test_cases": [
"address01"
]
}
$ git log -1 --oneline
5c68764 (HEAD -> retains-single_test) Update after review - more refactoring of --test
$ zonemaster-cli --test DnssEc/dNsseC03 --test bAsIc --test adDress03 zonemaster.net --no-ipv6 --level=info --show-testcase --profile ../zonemaster-engine/share/custom.json
Loading profile from ../zonemaster-engine/share/custom.json.
Notice: Engine does not have test case 'dnssec03' enabled in the profile. Forcing...
Notice: Engine does not have test case 'address03' enabled in the profile. Forcing...
Seconds Level Testcase Message
======= ======== ============== =======
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
1.33 INFO DNSSEC03 The zone does not use NSEC3. Testing for NSEC3 has been skipped. Fetched from name servers "ns2.nic.fr/192.93.0.4;nsa.dnsnode.net/194.58.192.46;nsp.dnsnode.net/194.58.198.32;nsu.dnsnode.net/185.42.137.98".
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
2.66 INFO Basic01 The parent zone is "net" as returned from name servers "a.gtld-servers.net/192.5.6.30;b.gtld-servers.net/192.33.14.30;c.gtld-servers.net/192.26.92.30;d.gtld-servers.net/192.31.80.30;e.gtld-servers.net/192.12.94.30;f.gtld-servers.net/192.35.51.30;g.gtld-servers.net/192.42.93.30;h.gtld-servers.net/192.54.112.30;i.gtld-servers.net/192.43.172.30;j.gtld-servers.net/192.48.79.30;k.gtld-servers.net/192.52.178.30;l.gtld-servers.net/192.41.162.30;m.gtld-servers.net/192.55.83.30".
2.66 INFO Basic01 The zone "zonemaster.net" is found.
3.02 INFO Basic02 Authoritative answer on SOA query for "zonemaster.net" is returned by name servers "ns2.nic.fr/192.93.0.4;nsa.dnsnode.net/194.58.192.46;nsp.dnsnode.net/194.58.198.32;nsu.dnsnode.net/185.42.137.98".
3.02 INFO Unspecified Functional nameserver found. "A" query for www.zonemaster.net test skipped.
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
2.56 INFO Address03 Every reverse DNS entry matches name server name.
|
@mattias-p I realize now that there is still one remaining case that I overlooked: that is when running a module (e.g. |
mattias-p
left a comment
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 looks good to me. I just have one last quibble.
lib/Zonemaster/CLI.pm
Outdated
| else { | ||
| # Get the test module with the right case | ||
| ( $module ) = grep { lc( $module ) eq lc( $_ ) } @existing_test_modules; | ||
| push @actual_test_cases, @{ $existing_tests{$module} }; |
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.
In current develop if you specify --profile file --test dnssec and the given profile contains a strict subset of all dnssec test cases, only that subset will be run. With this implementation all dnssec test cases will be run. I believe you agree the behavior in current develop is more reasonable. So after expanding the module name to a list of test case names but before pushing onto @actual_test_cases we should grep the list to only keep those test cases that are currently included in the test_cases profile property. I'm sorry I wasn't clear on this last time around.
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.
Oh, you already spotted it. I didn't see your comment before.
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.
Done.
$ git log -1 --oneline
d640b9c (HEAD -> retains-single_test, origin/retains-single_test) Respect profile configuration when there are already test cases of a requested module in the profile
$ zonemaster-cli --show-testcase --no-ipv6 zonemaster.net --test addRess --test bAsic --test baSic02 --test basIc --test adDress01 --test adDress/addrEss02 --level=info --profile ../zonemaster-engine/share/custom.json
Loading profile from ../zonemaster-engine/share/custom.json.
Notice: Engine does not have test case 'address02' enabled in the profile. Forcing...
Seconds Level Testcase Message
======= ======== ============== =======
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
0.85 INFO Address01 All Nameserver addresses are in the routable public addressing space.
3.37 INFO Address02 Reverse DNS entry exists for each Nameserver IP address.
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
12.73 INFO Basic01 The parent zone is "net" as returned from name servers "a.gtld-servers.net/192.5.6.30;b.gtld-servers.net/192.33.14.30;c.gtld-servers.net/192.26.92.30;d.gtld-servers.net/192.31.80.30;e.gtld-servers.net/192.12.94.30;f.gtld-servers.net/192.35.51.30;g.gtld-servers.net/192.42.93.30;h.gtld-servers.net/192.54.112.30;i.gtld-servers.net/192.43.172.30;j.gtld-servers.net/192.48.79.30;k.gtld-servers.net/192.52.178.30;l.gtld-servers.net/192.41.162.30;m.gtld-servers.net/192.55.83.30".
12.73 INFO Basic01 The zone "zonemaster.net" is found.
13.04 INFO Basic02 Authoritative answer on SOA query for "zonemaster.net" is returned by name servers "ns2.nic.fr/192.93.0.4;nsa.dnsnode.net/194.58.192.46;nsp.dnsnode.net/194.58.198.32;nsu.dnsnode.net/185.42.137.98".
13.04 INFO Unspecified Functional nameserver found. "A" query for www.zonemaster.net test skipped.
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
0.07 INFO Basic02 Authoritative answer on SOA query for "zonemaster.net" is returned by name servers "ns2.nic.fr/192.93.0.4;nsa.dnsnode.net/194.58.192.46;nsp.dnsnode.net/194.58.198.32;nsu.dnsnode.net/185.42.137.98".
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
0.07 INFO Basic01 The parent zone is "net" as returned from name servers "a.gtld-servers.net/192.5.6.30;b.gtld-servers.net/192.33.14.30;c.gtld-servers.net/192.26.92.30;d.gtld-servers.net/192.31.80.30;e.gtld-servers.net/192.12.94.30;f.gtld-servers.net/192.35.51.30;g.gtld-servers.net/192.42.93.30;h.gtld-servers.net/192.54.112.30;i.gtld-servers.net/192.43.172.30;j.gtld-servers.net/192.48.79.30;k.gtld-servers.net/192.52.178.30;l.gtld-servers.net/192.41.162.30;m.gtld-servers.net/192.55.83.30".
0.07 INFO Basic01 The zone "zonemaster.net" is found.
0.15 INFO Basic02 Authoritative answer on SOA query for "zonemaster.net" is returned by name servers "ns2.nic.fr/192.93.0.4;nsa.dnsnode.net/194.58.192.46;nsp.dnsnode.net/194.58.198.32;nsu.dnsnode.net/185.42.137.98".
0.15 INFO Unspecified Functional nameserver found. "A" query for www.zonemaster.net test skipped.
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
0.09 INFO Address01 All Nameserver addresses are in the routable public addressing space.
0.00 INFO Unspecified Using version v4.7.3 of the Zonemaster engine.
0.10 INFO Address02 Reverse DNS entry exists for each Nameserver IP address.
…requested module in the profile
|
@mattias-p @matsduf please re-review. |
| if ( not grep( /^$module$/, keys %actual_test_modules ) ) { | ||
| # Get the test module with the right case | ||
| ( $module ) = grep { lc( $module ) eq lc( $_ ) } @existing_test_modules; | ||
| # No need to bother to check for duplicates here | ||
| push @actual_test_cases, @{ $existing_tests{$module} }; | ||
| } |
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 a new feature, right? It's nice though.
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 is not fully consistent, but maybe good enough for now? The most common use case for --test is probably when all test cases are listed in the profile, and for that is seems to work as it should.
The inconsistency is when the profile only lists some test cases.
My profile has only Zone09 listed.
$ cat ~/.zonemaster/profile-zone09-only.json | jq .test_cases
[
"zone09"
]
When no --test is given the behavior is as expected:
$ zonemaster-cli --profile ~/.zonemaster/profile-zone09-only.json --show-testcase --level info iis.se --raw
Loading profile from /home/matsd/.zonemaster/profile-zone09-only.json.
0.00 INFO Unspecified GLOBAL_VERSION version=v4.7.3
2.14 INFO Basic01 B01_PARENT_FOUND domain=se; ns_ip_list=a.ns.se/192.36.144.107;a.ns.se/2a01:3f0:0:301::53;b.ns.se/192.36.133.107;b.ns.se/2001:67c:254c:301::53;c.ns.se/192.36.135.107;c.ns.se/2001:67c:2554:301::53;f.ns.se/192.71.53.53;f.ns.se/2a01:3f0:0:305::53;g.ns.se/130.239.5.114;g.ns.se/2001:6b0:e:3::1;i.ns.se/194.146.106.22;i.ns.se/2001:67c:1010:5::53;m.ns.se/194.0.11.112;m.ns.se/2001:678:e:112::53;x.ns.se/2001:67c:124c:e000::4;x.ns.se/213.108.25.4;y.ns.se/185.159.197.150;y.ns.se/2620:10a:80aa::150;z.ns.se/185.159.198.150;z.ns.se/2620:10a:80ab::150
2.14 INFO Basic01 B01_CHILD_FOUND domain=iis.se
2.59 INFO Basic02 B02_AUTH_RESPONSE_SOA domain="iis.se"; ns_list=nsa.dnsnode.net/194.58.192.46;nsa.dnsnode.net/2a01:3f1:46::53;nsp.dnsnode.net/194.58.198.32;nsp.dnsnode.net/2a01:3f1:3032::53;nsu.dnsnode.net/185.42.137.98;nsu.dnsnode.net/2a01:3f0:400::32
2.59 INFO Unspecified HAS_NAMESERVER_NO_WWW_A_TEST zname="iis.se"
2.68 INFO Zone09 Z09_MX_DATA mailtarget_list=mx1.iis.se.;mx2.iis.se.; ns_ip_list=194.58.198.32;185.42.137.98;2a01:3f1:3032::53;2a01:3f1:46::53;194.58.192.46;2a01:3f0:400::32
If --test Address is selcted, then all Address test cases are run and unexpectedly no warning that they are not listed in the profile:
$ zonemaster-cli --profile ~/.zonemaster/profile-zone09-only.json --show-testcase --level info iis.se --test Address --raw
Loading profile from /home/matsd/.zonemaster/profile-zone09-only.json.
0.00 INFO Unspecified GLOBAL_VERSION version=v4.7.3
0.51 INFO Address01 NO_IP_PRIVATE_NETWORK
2.23 INFO Address02 NAMESERVERS_IP_WITH_REVERSE
2.24 INFO Address03 NAMESERVER_IP_PTR_MATCH
If --test Zone01 is selected only that test case is run with a warning that it is not listed in the profile:
$ zonemaster-cli --profile ~/.zonemaster/profile-zone09-only.json --show-testcase --level info iis.se --raw --test Zone01
Loading profile from /home/matsd/.zonemaster/profile-zone09-only.json.
Notice: Engine does not have test case 'zone01' enabled in the profile. Forcing...
0.00 INFO Unspecified GLOBAL_VERSION version=v4.7.3
0.59 INFO Zone01 Z01_MNAME_NOT_IN_NS_LIST nsname=ns.nic.se
If --test Zone is selected unexpectedly only Zone09 is run:
$ zonemaster-cli --profile ~/.zonemaster/profile-zone09-only.json --show-testcase --level info iis.se --raw --test Zone
Loading profile from /home/matsd/.zonemaster/profile-zone09-only.json.
0.00 INFO Unspecified GLOBAL_VERSION version=v4.7.3
0.58 INFO Zone09 Z09_MX_DATA mailtarget_list=mx2.iis.se.;mx1.iis.se.; ns_ip_list=185.42.137.98;2a01:3f1:3032::53;2a01:3f0:400::32;2a01:3f1:46::53;194.58.198.32;194.58.192.46
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 am ready to approve if the behavior above is accepted.
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 is not fully consistent, but maybe good enough for now? The most common use case for --test is probably when all test cases are listed in the profile, and for that is seems to work as it should.
The inconsistency is when the profile only lists some test cases.
All of the scenarios that you mention are expected behaviors. The warning was supposed to appear only when wanting to run a single test case that is not in the profile (i.e. using Zonemaster::Engine::test_method()). Running a test module (i.e. using Zonemaster::Engine::test_module()) will either only run the test cases of that module if any are specified in the profile, else all of them.
This is a new feature, right? It's nice though.
It is not, this is to keep the behavior of current develop (i.e. see your comment).
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.
Running a test module (i.e. using
Zonemaster::Engine::test_module()) will either only run the test cases of that module if any are specified in the profile, else all of them.
Well, I find it strange that all Addresses are run when none of them are included in the profile, but only one Zone test case because that single test case is included in the profile. That is inconsistent.
The behavior is not bad enough to block it, but I think it should be straighten out in next release.
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 guess it is debatable. We can look at it for next release yes.
v2023.2 release testingTested following the "How to test" section, works as expected. |
Purpose
This PR retains the possibility of starting a Test Case disabled in the profile by letting Zonemaster-CLI directly modify the profile, and notifying the user with a message.
This behavior was previously possible due to an inconsistency in Zonemaster-Engine which is being removed by zonemaster/zonemaster-engine#1294.
Context
zonemaster/zonemaster-engine#1294 (and comment zonemaster/zonemaster-engine#1294 (comment))
How to test this PR
i)
ii)
i)
ii)