# GENERAL # you must set the class STORAGE_TEST to make use of this software package additionally I recommend setting up a proper SSH-Login, so you can easily copy data to/from the fai-client (especially command output) - boot the designated fai-client - login as root a) perform every test - /var/lib/fai/config/tests/setup-storage_wrapper b) in case of trouble - export debug=1 - /var/lib/fai/config/tests/setup-storage_wrapper 2>&1 | tee /tmp/setup-storage.log c) you can also cherry-pick tests and add them to 'setup-storage_wrapper_stripped' - /var/lib/fai/config/tests/setup-storage_wrapper_stripped about "debug": I patched the function push_command in Init.pm so it 'carps' a stack trace for each command that is scheduled. This makes the log quite a bit longer but also much more useful. # OUTPUT # For each test a small header is printed, which shows a description and states the disk_config class that is used for this test. If everything is well then this is the only output you will see. If there is an error, then there may also be: - a notice describing the expected and actual return code for setup storage - a diff of setup-storage's output, highlighting the differences between the expected and the actual output and the full output Please note: It is possible to create tests which are expected to fail. If setup-storage fails with the correct exit code / output then this is also a success as far as this test wrapper is concerned. sample output for a clean test: [...] ====================================================================== simple root, swap, lvm (with partition table) [tss_05_root+swap+lvm_ptable] ====================================================================== [...] sample output for a failed test: [...] ====================================================================== brian - md+lvm (reinstall / no preserve) [tss_BK_md+lvm_nopreserve] ====================================================================== ---------------------------------------------------------------------- Expected return value 25, got 0 ---------------------------------------------------------------------- ---------------------------------------------------------------------- Expected a different output ---------------------------------------------------------------------- --- /var/lib/fai/config/disk_config/tss_BK_md+lvm_nopreserve.output 2012-09-01 23:38:26.685536474 +0200 +++ /tmp/tmp.EgKtAz2Wt5 2012-09-01 23:38:08.756853271 +0200 @@ -1,4 +1,4 @@ -Starting setup-storage 1.4 +Starting setup-storage 1.4+ami Using config file: /var/lib/fai/config/disk_config/tss_BK_md+lvm_nopreserve Executing: parted -s /dev/sda unit TiB print Executing: parted -s /dev/sda unit B print free @@ -31,6 +31,8 @@ Executing: mdadm -W --stop /dev/md0 Executing: wipefs -a /dev/vg/var Executing: lvremove -f vg/var +Executing: wipefs -a /dev/vg/swap +Executing: lvremove -f vg/swap Executing: wipefs -a /dev/vg/root Executing: lvremove -f vg/root Executing: wipefs -a /dev/vg/local.hd [...] ---------------------------------------------------------------------- Starting setup-storage 1.4+ami Using config file: /var/lib/fai/config/disk_config/tss_BK_md+lvm_nopreserve Executing: parted -s /dev/sda unit TiB print Executing: parted -s /dev/sda unit B print free Executing: parted -s /dev/sda unit chs print free Executing: parted -s /dev/sdb unit TiB print Executing: parted -s /dev/sdb unit B print free Executing: parted -s /dev/sdb unit chs print free [...] # REQUIREMENTS # these tests require a machine with 2 harddiscs (size: at least 40GB each) - tss_BK_md+lvm_initial - tss_BK_md+lvm_nopreserve - tss_BK_md+lvm_preserve # TODO # this tool is very much 'works-for-me'-grade - modify 'available disks' variable during testing - add more tests (some ideas present in setup-storage_wrapper) - implementing 'wipe disks', 'teardown lvm', etc. as re-useable functions would be nice, since they are a bit tricky - simplify test-preparation / -teardown # CUSTOMIZATION # The script should be pretty easy to understand. A typical configuration looks something like this: ---------------------------------------------------------------------------- test_name='simple root, swap, lvm (factory clean)' test_class='04_root+swap+lvm' expected_result='0' dd if=/dev/zero of=/dev/sda bs=1M count=10 >/dev/null 2>&1 dd if=/dev/zero of=/dev/sdb bs=1M count=10 >/dev/null 2>&1 exec_setup-storage # disable lvm again vgchange --available n >/dev/null vgremove --force vg_system >/dev/null ---------------------------------------------------------------------------- $test_name describes the current test $test_class defines the relevant disc configuration $test_class.output contains the expected output, a missing file results in skipping the check. $expected_result expected return code for setup-storage, this can be used to feed incorrect input and check proper error detection (typical values: 0, 2, 25) The ' ' indentation has no effect except to indicate some pre- and/or post-processing. This is mainly to (re)set the system to a 'known' state. Warning: Make sure your test-configuration has been properly de-configured. setup-storage expects a certain system state - improperly shutting down your test is likely to make later test cases fail! If a file .output is present in disk_config, then this testscript compares the actual and the desired output against each other and notifies if something has changed. (A special case is made for uuids and setup-storage's version number - these values / output lines are ignored during comparison.) Tip: Create an empty file to make the test script show the expected output. Warning: Some lines (e.g. Executing: yes | mdadm --create [...]) end with a space. So if the line is visually the same, but diff complains try `setup-storage_wrapper|cat -vet` Update: I've included a cosmetic fix which gets rid of the trailing blank.