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
Use uniform accessors #752
Use uniform accessors #752
Conversation
664d9e2
to
3b43e50
Compare
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 great ! Thanks
I have few remarks and questions to make it even greater ;)
docs/Configuration.md
Outdated
How old (in seconds) a previous test of the same zone name and parameters can be | ||
when it is reused instead of starting a new test. |
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.
Not sure if can
conveys the right meaning. From my understanding if the time limit is reached, then a new test is run, otherwise the old test's results are displayed. And the usage of can here make it sounds like there is a possibility to run the test even if the time limit is not reached.
I understand that there might be something unclear with the current sentence.
If you feel we need to rewrite this sentence, I tried to formulate it another way (but I'm still not satisfied)
-> Time (in seconds) to wait before running a new test instead of reusing the results of a previous test of the same zone name and parameter.
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.
When I tried to look for a real life analogy to what we're trying to express and the closes I came was "shelf life". I'll come up with a new wording based on that.
lib/Zonemaster/Backend/Config.pm
Outdated
|
||
'max_zonemaster_execution_time' from [ZONEMASTER] section in ini file. See | ||
L<https://github.com/zonemaster/zonemaster-backend/blob/master/docs/Configuration.md#max_zonemaster_execution_time>. | ||
=head2 DB_engine |
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.
Can you move all these POD (DB_engine ... ZONEMASTER_age_reuse_previous_test) above line 266 with the other ones ? I think it will make more sense to have them all together (however I should say that I don't know much on POD, so if there is a reason to keep them here, I can live with 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.
POD doesn't care about order. There are coverage tools for verifying that every named subroutine has a corresponding POD heading but otherwise you may do as you please.
For this PR I've mainly tried to do something at least half-way reasonable regarding the placement of the POD while also keeping down the size of the diff. But I'll take another look.
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 was just to have the POD close to the code (if you prefer reading the code file directly). Thanks for the update
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 completely agree. The only reason I didn't make it so in the first place was a practical one. I had a large set of changes that I was trying to rebase into a series of PRs, so having smaller diffs made a big difference at the time. But I'm glad I got to set it straight.
lib/Zonemaster/Backend/Config.pm
Outdated
|
||
'number_of_processes_for_frontend_testing' from [ZONEMASTER] section in ini file. See | ||
L<https://github.com/zonemaster/zonemaster-backend/blob/master/docs/Configuration.md#number_of_processes_for_frontend_testing>. | ||
Returns an integer (number of seconds). |
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.
Why specifying what kind of value is returned here and not for all the other one ?
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 remove it for consistency.
AND progress > 0 | ||
AND progress < 100 | ||
AND queue = ".$self->config->lock_on_queue(); | ||
AND queue = ?" ); | ||
$sth->execute( # |
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.
Is the trailing empty comment mandatory ?
(this question applies to all following execute()
calls)
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 put it there to coax perltidy into doing something reasonable. If I leave it out perltidy just pulls all the arguments up on the same line making it harder to read :)
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 see. Thanks for the explanation. And I do agree that it is better to have them on several lines.
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 a trick! I will remember that.
Of course! Great is great but greater is greater :) |
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.
Thanks for all the updates. Sadly a small mistake slipped in ^^'
docs/Configuration.md
Outdated
Default value: `600`. | ||
|
||
The shelf life of a test in seconds after its creation. | ||
If a new test is requested for the same zone name and parameters within the | ||
shelf life of a previous test result, that test result is reused. | ||
Otherwise a new test request is enqueued. |
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 you removed the default value line by mistake.
(I like the rewording btw)
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.
Good spotting! I added it back.
I also also made a small edit to make age_reuse_previous_test to make its formatting more like the other simple properties.
(I like the rewording btw)
I'm glad to hear that :)
@pnax Thanks for reviewing. @matsduf Could you review this too? |
lib/Zonemaster/Backend/Config.pm
Outdated
|
||
=head2 DB_engine | ||
|
||
Get the value of L<DB.engine|https://github.com/zonemaster/zonemaster-backend/blob/master/docs/Configuration.md#polling_interval>. |
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 should not be "polling_interval" here.
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.
Good catch! I fixed it.
AND progress > 0 | ||
AND progress < 100 | ||
AND queue = ".$self->config->lock_on_queue(); | ||
AND queue = ?" ); | ||
$sth->execute( # |
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 a trick! I will remember that.
Just one small change. |
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.
While going through the code, I realize that the way some deprecated values are handled is not right. I am referring to number_of_processes_for_frontend_testing
and number_of_processes_for_batch_testing
. The code on line 183 and 192 of Config.pm will never be used because we set a default value to 20. So the value is always defined at this stage and will never be overridden by the config value.
If we care about stability for deprecated values, I think this needs to be reworked.
And to see the problem, you can update t/config.t
with number_of_professes_for_frontend_testing
instead of number_of_processes_for_frontend_testing
and see the test fail.
Thanks for your reviews! I must say I didn't see the default value problem coming. Getting the order right in this kind of code is surprisingly tricky. Unfortunately I can't fix it the way I want to without conflicting with #753, and I'd rather merge that one first. After #753 is merged I'll rebase this one and fix the problems you guys found. I'll also add the unit tests I for |
Yes I agree that this looks tricky. I discovered this while trying to look how to properly deprecate the |
I.e. ZONEMASTER_max_zonemaster_execution_time, ZONEMASTER_lock_on_queue and ZONEMASTER_maximal_number_of_retries.
0e487bc
to
7f9c6fe
Compare
Yeah, having test coverage of all the cases is key, though. Once you get the tests to pass you also want to make it look easy. It's so much more satisfying when the tricky stuff shows up in more glamorous places. Configuration file validation just doesn't get enough hype these days. But I rebased the commits and fixed the problems. I ended up assigning the private fields multiple times going from least to most prioritized source instead of going the other way around and using guards. I think it turned out pretty good. I just hope I didn't forget more tests. |
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 large and complex PR. It looks fine, but will have to test it thoroughly.
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.
Well done ! You came up with a very nice solution :)
Context
This PR is a follow-up to #749.
Scope
Included:
Excluded:
Changes
Security:
Documentation:
Clean-up:
How to test this PR
This PR contains no functional changes. It should be enough that the automatic tests pass.