MySQL 8.0: New mysql-test-run option to minimize skipped tests in regression test runs
Mysql 12-Jun-2017

MySQL 8.0: New mysql-test-run option to minimize skipped tests in regression test runs

Anybody who has run the MySQL MTR test suite must have seen a statement like “x tests were skipped, y by the test itself. ” at the end of test runs. Why are some tests being skipped? Are the skipped tests affecting test coverage? If you are interested to know, read on …

Background

The MTR test suite is run regularly on multiple platforms and with various values for MySQL system variables. Not all MTR tests can run on all environments making it necessary to skip tests in some cases. MTR supports this with the command called skip. It is used to check if the prerequisites needed to run a test are satisfied . If not satisfied, the test is skipped with an informative message defined by the test author. For example, tests that can run only on windows have to be skipped on other platforms.

However, wrong usage of ‘skip’ can lead to a situation where some tests are never run in the regression test environment. This leads to reduced test coverage and hence bug escape. An example is “Bug#80288 missing innodb_numa_interleave” which escaped our regression tests, but was caught by community.  There was an error in the build script due to which server was built without NUMA support, even though the machine had NUMA libraries installed.

Solution

To resolve this, we have introduced a new MTR option called ‘no-skip‘. When a test or a test-suite is run with no-skip option, it ignores all the skip commands used within the test and forces the test to run . In case of a missing prerequisite, the test will fail and will be noticed in the regression test environment. This is a better behavior than silently skipping tests. Note that by default this variable is OFF.

However, during the course of this work-log we discovered that skip cannot be avoided in all situations. For example a test that can only run on Windows has to be skipped on other platforms. To handle these special cases we have introduced a file ‘excludenoskip.list’. It will contain a list of tests which should continue to skip even if MTR is run with –no-skip option.

To help understand what the excludenoskip.list does, refer the listed example below.

Let’s run the below MTR test on a Linux machine:

./mtr main.shm

We currently have shared memory(shm) support only on Windows. This test will have an OS dependency check (windows.inc). If the check fails, the test will skip.

Now, let’s run it using no-skip option on the same Linux machine:

./mtr main.shm –no-skip

This time, even though we have an OS dependency check, the skip command will be ignored and the test will continue to run and will eventually fail. This will be an unwanted failure and to handle such cases we have introduced a file called excludenoskip.list. This has a list of inc files that should continue to be skipped even if –no-skip option is passed to MTR. So to handle the example above we have added windows.inc in excludenoskip.list. This ensures that test skips on non windows platforms even when run with –no-skip option.

Other Improvements

This project not only added –no-skip option, but also identified scenarios where skip could be avoided,

  • Tests modified to set required mysqld system variables(WL#9027 )– We identified few tests that used to skip if a mysqld system variable is not set to a required value. Tests have the ability to set system variables to any value and hence this skip was unnecessary . It is good to have the mysqld option set in the test itself because this will always allow the test to run. If instead, a skip check is used, the test will be skipped if the option is not passed while running the test. For instance – Test main.flush2 needs this option replay_log_info_repository to be set to ‘FILE’ for execution. Instead of creating a dependency check (eg- include/not_relay_log_info_table.inc), this dynamic server variable was set within the test.
  • rpl and binlog test suites split based on required GTID_MODE setting( WL#9249WL#9394 ): The rpl and binlog suites had 3 types of tests. Tests that can run only with GTID_MODE ON, tests that can run only with GTID_MODE OFF and tests that are GTID_MODE agnostic. In order to run all tests one had to run the suites with both GTID_MODE ON and OFF. The default value of the variable is OFF and hence tests that need ON were not run if one does not explicitly pass GTID_MODE=ON in MTR command line. We improved this situation by splitting the tests into rpl, rpl_gtid and rpl_nogtid, binlog, binlog_gtid and binlog_nogtid depending on whether they need gtid ON or OFF.
  • Redundant skips removed (WL#9170 ) – Some skips were redundant because of changes in the product. For ex- In MySQL 8.0.0, we can no longer compile out charsets from the server. This implies charsets will always be available and we no longer need to check for its existence. All checks for charsets were removed from tests.

Conclusion

Running tests with –no-skip option will certainly reduce the number of skipped tests. It will also ensure that there are no tests getting skipped accidentally.

The no-skip option is now used for all MySQL internal testing. We recommend community to use it for improving test coverage.

In case of any questions, please drop a comment below and we would be glad to address them.

Thank you for using MySQL!