Skip to content

Conversation

@matsduf
Copy link
Contributor

@matsduf matsduf commented Jan 4, 2021

When creating a new test through RPCAPI it will first check if there is a recent test with the same test parameters. If so, and that test is not too old, a new test will not be created, instead the test result for that recent test will be reused.

As it is now, "not too old" is hard-coded to 10 minutes. That is probably a good choice in most cases, but sometimes that is too short and sometimes too long. This PR makes that configurable.

As a side effect, this PR sorts the methods in the "[ZONEMASTER]" section from the ini file in lib/Zonemaster/Backend/Config.pm and also adds POD documentation to those methods.

Updated 2021-05-17:

How to test this PR

  1. update the value for age_reuse_test in backend_config.ini
  2. restart daemons
  3. test a domain
  4. redo the test before the new time value (it should give the previous results, check the date)
  5. redo the test after the time limit (a new test should be created, check the dates)

* Rearranges all methods connected to the [ZONEMASTER] section in
  the ini file so that they come after each other.
* Adds POD documentation to all methods connected to the
  [ZONEMASTER] section.
* No changes in code or logic.
Adds a new key, "age_reuse_previous_test", to the ini file that
sets the time before a new test is executed, instead of reusing the
previous test (of the same domain and with the same parameters). It
replaces a hard coded value.
@matsduf matsduf added the A-Code label Jan 4, 2021
@matsduf matsduf added this to the v2021.1 milestone Jan 4, 2021
@matsduf matsduf requested review from a user and mattias-p January 4, 2021 17:20
Comment on lines +212 to +215
Positiv integer (in seconds) for how old a previous test of the same
zone name and parameters must be before we start a new test. Internally
the value is converted to whole minutes. If the conversion results in
zero minutes, then the default value (600 seconds) is used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the unit seconds here, rather than minutes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt that seconds was a better unit, especially since other keys take seconds. I would rather turn it around and make it seconds all the way through. In the MySQL adapter it is converted to seconds before use.

If this is merged I will create a second PR where the time unit is seconds all the way through.

But I will not insist. If minutes is better I can take that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Uniform units sure is a nice feature. Seconds it is. If we could also get rid of the rounding, that would be great!

=head3 INPUT
'max_zonemaster_execution_time' from [ZONEMASTER] section in ini file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe link to the property in Configuration.md?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, but those links will be broken until the updated Configuration.pm has been merged to master branch. I guess that is OK.

@matsduf matsduf requested a review from mattias-p January 5, 2021 14:25
@matsduf
Copy link
Contributor Author

matsduf commented Mar 3, 2021

@mattias-p and @PNAX, can you review?

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments.
I also ran some tests, and this seems to work.

my $val = $self->{cfg}->val( 'ZONEMASTER', 'age_reuse_previous_test' );
$val = ($val > 0) ? $val : 0;
$val = int ( ($val / 60) + 0.5); # in minutes
return ($val)? $val : 10;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A style remark: there is a missing space before the ?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Some other PR can make it consistent in the module.

number_of_processes_for_batch_testing = 20

#age_reuse_previous_test=600
#
Copy link

@ghost ghost Mar 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the line 23 should be blank to make a clear separation with the following WARNING clause that is related to maximal_number_of_retries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and made the warning clearer. For how long should maximal_number_of_retries be considered to be experimental?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea... I found PR #544 where this parameter has been added. I understand that this option has not been fully tested (as the warning says) and that there might be issues with parallelism.

@matsduf matsduf requested a review from a user March 3, 2021 22:11
@matsduf
Copy link
Contributor Author

matsduf commented Mar 3, 2021

@PNAX, please re-review.

ghost
ghost previously approved these changes Mar 4, 2021
=head3 RETURNS
Integer (number of seconds)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you consider validation to be out of scope for this PR? Otherwise it would make sense to add validation for this to the load_config method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is out of scope for this PR to add validation for anything execept age_reuse_previous_test, but that is a good suggestion. For age_reuse_previous_test the validation is done such as if the value is not numeric and positive, it will be ignored. Should it croak instead?

I do not understand how to used load_config method for validation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought it's probably better to leave the validation out for now and deal with it in #685.

=head3 RETURNS
Positive integer (default 600).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default doesn't look right. Maybe you meant to add it to MaxZonemasterExecutionTime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I will fix.

@matsduf matsduf dismissed ghost ’s stale review via 93b37f6 March 4, 2021 10:50
@matsduf matsduf added the T-Feature Type: New feature in software or test case description label Mar 4, 2021
@matsduf matsduf merged commit c2a2608 into zonemaster:develop Mar 4, 2021
@matsduf matsduf deleted the add-reuse-test-configuration branch March 4, 2021 13:25
@ghost ghost mentioned this pull request Mar 16, 2021
@mattias-p
Copy link
Member

Release testing for v2021.1

I verified this using the commands below on CentOS 7 and CentOS 8.

sudo sed -i '/\bage_reuse_previous_test\b/ s/=.*/= 20/' /etc/zonemaster/backend_config.ini
sudo systemctl restart zm-rpcapi
sudo systemctl restart zm-testagent
zmtest example > /dev/null
sleep 10
zmtest example > /dev/null
sleep 20
zmtest example > /dev/null
# Verify that the two first zmtest commands report the same testid, but the third one reports a different one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Feature Type: New feature in software or test case description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants