Skip to content

Adds new unit tests based on scenarios for Basic02#1447

Merged
matsduf merged 18 commits into
zonemaster:developfrom
matsduf:add-scenarios-basic02
May 20, 2025
Merged

Adds new unit tests based on scenarios for Basic02#1447
matsduf merged 18 commits into
zonemaster:developfrom
matsduf:add-scenarios-basic02

Conversation

@matsduf

@matsduf matsduf commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

Purpose

This PR adds new unit tests for Basic02. They are based on the defined scenarios in zonemaster/zonemaster#1380.

Old unit tests are removed in this PR, and data file rerecorded.

The TestUtil.pm Perl module for unit tests is also updated. The update is backward compatible. The update adds flexibility to make it possible to test multiple, selected scenarios during development.

To resolve the issue in #1448, TestUtil.pm is updated. The "fill_in_empty_oob_glue" flag to add_fake_delegation() is changed from false to true.

All data files that belong to unit tests that use TestUtil.pm have been updated after the change, except for the data file for t/Test-zone11.t. The source data for those unit tests are on a private network not available for the creator of this PR.

Context

zonemaster/zonemaster#1380

How to test this PR

The unit tests must pass.

@matsduf matsduf added the A-TestCase Area: Test case specification or implementation of test case label Apr 14, 2025
@matsduf matsduf added this to the 2024.2.2 milestone Apr 14, 2025

@marc-vanderwal marc-vanderwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks fine.

Comment thread t/TestUtil.pm Outdated
Comment thread t/TestUtil.pm Outdated
matsduf and others added 3 commits April 25, 2025 15:52
Co-authored-by: Marc van der Wal <103426270+marc-vanderwal@users.noreply.github.com>
@matsduf matsduf requested a review from marc-vanderwal April 25, 2025 15:55
Comment thread t/Test-basic.t
my $zone;

%res = map { $_->tag => 1 } Zonemaster::Engine->test_module( q{basic}, q{nic.tf} );
ok( $res{B02_AUTH_RESPONSE_SOA}, q{B02_AUTH_RESPONSE_SOA} );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could have been kept, no? Since it tests the entire Basic module.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It could, but the new unit tests does much more, and I think we should clean out old unit tests when we add new ones based on scenarios.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Testing a test case and a test module are two different things. In particular, calling Zonemaster::Engine->test_module() (as opposed to Zonemaster::Engine->test_method() for a single test case which is what TestUtil->perform_testcase_testing() does) will run the all() method in that module (which takes care of any test case dependencies). So it remains important to have those unit tests, we should keep them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can keep it. It will do no harm until we need to re-record and it does not work. A better approach wold be to design tests unsing Zonemaster::Engine->test_module() in the test framework, if that really adds something.

Please note that the tests on Basic01 have already been removed when new Basic01 tests were created.

Comment thread t/Test-basic02.t Outdated
Comment thread t/Test-basic02.t Outdated
Comment thread t/Test-basic02.t
Comment thread t/Test-basic02.t Outdated
Comment thread t/Test-basic02.t Outdated
Comment thread t/TestUtil.pm
matsduf and others added 4 commits May 1, 2025 17:38
Co-authored-by: tgreenx <96772376+tgreenx@users.noreply.github.com>
Co-authored-by: tgreenx <96772376+tgreenx@users.noreply.github.com>
Updates from "single_scenario" to "selected_scenario" and from "disable_scenario" to
"disabled_scenarios" to better match the function. No change of logic.
@matsduf matsduf requested a review from tgreenx May 5, 2025 20:12
@matsduf

matsduf commented May 6, 2025

Copy link
Copy Markdown
Contributor Author

@tgreenx and @marc-vanderwal, please review.

@tgreenx tgreenx removed this from the 2024.2.2 milestone May 6, 2025
@tgreenx tgreenx added this to the v2025.1 milestone May 6, 2025
marc-vanderwal
marc-vanderwal previously approved these changes May 7, 2025
Comment thread t/Test-basic.t
my $zone;

%res = map { $_->tag => 1 } Zonemaster::Engine->test_module( q{basic}, q{nic.tf} );
ok( $res{B02_AUTH_RESPONSE_SOA}, q{B02_AUTH_RESPONSE_SOA} );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Testing a test case and a test module are two different things. In particular, calling Zonemaster::Engine->test_module() (as opposed to Zonemaster::Engine->test_method() for a single test case which is what TestUtil->perform_testcase_testing() does) will run the all() method in that module (which takes care of any test case dependencies). So it remains important to have those unit tests, we should keep them.

Comment thread t/TestUtil.pm Outdated
Comment thread t/methodsv2.t Outdated
Comment thread t/TestUtil.pm Outdated
Comment thread t/TestUtil.pm Outdated
Comment thread t/methodsv2.t Outdated
Co-authored-by: tgreenx <96772376+tgreenx@users.noreply.github.com>
@matsduf matsduf requested review from marc-vanderwal and tgreenx May 14, 2025 10:07
Comment thread t/Test-basic02.t
# - One of MANDATORY_MESSAGE_TAGS and FORBIDDEN_MESSAGE_TAGS may be undefined.
# See documentation for the meaning of that.

my %subtests = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation of this block is still looking weird imho (compare with e.g. Test-basic01.t), but I could live with it.

@tgreenx tgreenx added the V-Patch Versioning: The change gives an update of patch in version. label May 14, 2025
@matsduf matsduf merged commit 9842647 into zonemaster:develop May 20, 2025
3 checks passed
@matsduf matsduf deleted the add-scenarios-basic02 branch May 20, 2025 11:49
marc-vanderwal added a commit to marc-vanderwal/zonemaster-engine that referenced this pull request May 20, 2025
The pull request zonemaster#1447 renamed ZONEMASTER_SINGLE_SCENARIO to
ZONEMASTER_SELECTED_SCENARIOS and ZONEMASTER_DISABLE_SCENARIO to
ZONEMASTER_DISABLED_SCENARIOS. This PR has already been merged, so this
instance needs to be updated as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-TestCase Area: Test case specification or implementation of test case V-Patch Versioning: The change gives an update of patch in version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants