Path: blob/main/sys/contrib/openzfs/tests/README.md
48262 views
ZFS Test Suite README
1) Building and installing the ZFS Test Suite
The ZFS Test Suite runs under the test-runner framework. This framework is built along side the standard ZFS utilities and is included as part of zfs-test package. The zfs-test package can be built from source as follows:
The resulting packages can be installed using the rpm or dpkg command as appropriate for your distributions. Alternately, if you have installed ZFS from a distributions repository (not from source) the zfs-test package may be provided for your distribution.
2) Running the ZFS Test Suite
The pre-requisites for running the ZFS Test Suite are:
Three scratch disks
Specify the disks you wish to use in the $DISKS variable, as a space delimited list like this: DISKS='vdb vdc vdd'. By default the zfs-tests.sh script will construct three loopback devices to be used for testing: DISKS='loop0 loop1 loop2'.
A non-root user with a full set of basic privileges and the ability to sudo(8) to root without a password to run the test.
Specify any pools you wish to preserve as a space delimited list in the $KEEP variable. All pools detected at the start of testing are added automatically.
The ZFS Test Suite will add users and groups to test machine to verify functionality. Therefore it is strongly advised that a dedicated test machine, which can be a VM, be used for testing.
On FreeBSD, mountd(8) must use
/etc/zfs/exportsas one of its export files – by default this can be done by settingzfs_enable=yesin/etc/rc.conf.
Once the pre-requisites are satisfied simply run the zfs-tests.sh script:
Alternately, the zfs-tests.sh script can be run from the source tree to allow developers to rapidly validate their work. In this mode the ZFS utilities and modules from the source tree will be used (rather than those installed on the system). In order to avoid certain types of failures you will need to ensure the ZFS udev rules are installed. This can be done manually or by ensuring some version of ZFS is installed on the system.
The following zfs-tests.sh options are supported:
The ZFS Test Suite allows the user to specify a subset of the tests via a runfile or list of tags.
The format of the runfile is explained in test-runner(1), and the files that zfs-tests.sh uses are available for reference under /usr/share/zfs/runfiles. To specify a custom runfile, use the -r option:
Otherwise user can set needed tags to run only specific tests.
3) Test results
While the ZFS Test Suite is running, one informational line is printed at the end of each test, and a results summary is printed at the end of the run. The results summary includes the location of the complete logs, which is logged in the form /var/tmp/test_results/[ISO 8601 date]. A normal test run launched with the zfs-tests.sh wrapper script will look something like this:
4) Example of adding and running test-case (zpool_example)
This broadly boils down to 5 steps
Create/Set password-less sudo for user running test case.
Edit configure.ac, Makefile.am appropriately
Create/Modify .run files
Create actual test-scripts
Run Test case
Will look at each of them in depth.
Set password-less sudo for 'Test' user as test script cannot be run as root
Edit file configure.ac and include line under AC_CONFIG_FILES section
Edit file tests/runfiles/Makefile.am and add line zpool_example.
Create file tests/runfiles/zpool_example.run. This defines the most common properties when run with test-runner.py or zfs-tests.sh.
If adding test-case to an already existing suite the runfile would already be present and it needs to be only updated. For example, adding zpool_example_002_pos to the above runfile only update the "tests =" section of the runfile as shown below
Edit tests/zfs-tests/tests/functional/cli_root/Makefile.am and add line under SUBDIRS.
Create new file tests/zfs-tests/tests/functional/cli_root/zpool_example/Makefile.am the contents of the file could be as below. What it says it that now we have a test case zpool_example_001_pos.ksh
We can now create our test-case zpool_example_001_pos.ksh under tests/zfs-tests/tests/functional/cli_root/zpool_example/.
Run Test case, which can be done in two ways. Described in detail above in section 2.
test-runner.py (This takes run file as input. See zpool_example.run)
zfs-tests.sh. Can execute the run file or individual tests