10. 01. 2020 Damiano Chini Unified Monitoring

PHP Unit Test Execution Redesign in NetEye 4

The R&D team makes extensive use of PHP unit tests in order to ensure functional correctness in all the icingaweb2 modules integrated into NetEye 4. In fact, for each icingaweb2 module we developed a PHPUnit component that allows us to perform unit tests on all PHP classes and functions present in the module. These PHP unit tests are included in the devel package of the module, which contains all the tests developed for the module.

These kinds of tests are of course part of the continuous automated testing process performed in our continuous integration pipeline.

Until now each icingaweb2 module shipped a dedicated script php_run_tests.sh for executing all the PHPUnit tests of the module, whose aim was to:

  • Download the third-party libraries needed to execute the unit tests contained in the module
  • Execute all the unit tests present in the module
  • Remove all the libraries just downloaded

This approach had two main downsides:

  1. There was a significant time overhead for unit test execution of each icingaweb2 module (as well as network overhead) caused by downloading the third-party libraries
  2. Code was duplicated due to the replication of the script php_run_tests.sh in each icingaweb2 module

To solve these two issues, we decided to create a new rpm package called php-neteye-devel, which is now a required dependency for each icingaweb2 devel package.

We solved the first issue by shipping within the php-neteye-devel package all the third-party libraries needed for running PHP unit tests. All devel packages for Icingaweb2 modules now have to simply declare a dependency on php-neteye-devel. In this way all the third party libraries needed for PHP unit tests will be pre-installed whenever a devel package for icingaweb2 is installed.

The second issue was solved by generalizing the script that executes the PHP unit tests of a single icingaweb2 module. The devel packages in each icingaweb2 module will now only have to create a symbolic link to the new, generalized script.

Damiano Chini

Damiano Chini

Author

Damiano Chini

Leave a Reply

Your email address will not be published. Required fields are marked *

Archive