zonemaster / zonemaster-backend

The Zonemaster Backend - part of the Zonemaster project
Other
14 stars 23 forks source link

Ensure Backend’s messages stay translated #1166

Closed marc-vanderwal closed 5 months ago

marc-vanderwal commented 6 months ago

Purpose

This PR adds unit tests for Zonemaster::Backend::Translator and addresses an oversight in Backend caused by storing the module’s names as mixed case instead of uppercase.

Context

Submitting PR https://github.com/zonemaster/zonemaster-engine/pull/1346 made it clear that Zonemaster::Backend::Translator lacked appropriate unit tests. When adding them, I found more bugs, now addressed in the same PR. I also noticed that all Backend-generated messages suddenly became untranslated.

Changes

How to test this PR

Prerequisite: PR https://github.com/zonemaster/zonemaster-engine/pull/1346 must be merged beforehand in Zonemaster-Engine. Alternatively, install a local copy Zonemaster-Engine from a local development branch with this PR merged. If not, one of the newly-added unit tests will fail.

Before merging this PR locally: run a test on a domain name that causes Zonemaster to time out, such as pool.ntp.org, using zmtest. Note the test ID. Wait for the test to time out. Notice that the UNABLE_TO_FINISH_TEST message is untranslated (i.e., only the message tag is visible).

After merging this PR locally: run the unit tests. Ideally, make sure that the tests in t/translator.t have been executed.

Run the database migration script. Then use zmb get_test_results --test-id $TEST_ID where $TEST_ID is the test ID of pool.ntp.org that was run before merging the PR locally. Expect the UNABLE_TO_FINISH_TEST message to be translated.

Run the same test again on pool.ntp.org using zmtest; wait for it to time out. Expect the UNABLE_TO_FINISH_TEST message to be translated as well.

matsduf commented 4 months ago

@marc-vanderwal, translator.t fails in Travis. See #1170.

MichaelTimbert commented 4 months ago

Tested and working on Ubuntu 20.04.6 and 22.04.4.

Bug:

on Ubuntu 20.04 the migration script in cat /usr/local/share/perl/5.30.0/auto/share/dist/Zonemaster-Backend/patch/patch_db_zonemaster_backend_ver_11.2.0.pl fail due to the line use List::MoreUtils qw(zip_unflatten); Error:

Could not find sub 'zip_unflatten' exported by List::MoreUtils at /usr/local/share/perl/5.30.0/auto/share/dist/Zonemaster-Backend/patch/patch_db_zonemaster_backend_ver_11.2.0.pl line 4.
BEGIN failed--compilation aborted at /usr/local/share/perl/5.30.0/auto/share/dist/Zonemaster-Backend/patch/patch_db_zonemaster_backend_ver_11.2.0.pl line 4.

zip_unflatten is not present in List::MoreUtils version 0.416.

$ perl -MList::MoreUtils -le 'print $List::MoreUtils::VERSION'
0.416

Commenting the line make the migration script work.

Test Procedure:

marc-vanderwal commented 4 months ago

Oh, I see. We don’t need List::MoreUtils in this script, so that’s something that should be fixed before the release.

matsduf commented 4 months ago

Changes tagging of this from V-Patch to V-Minor to motivate the minor version upgrade.