autotest/virt-test — pull request #1330 by chuanchang (2014-01-08 10:09:55+00:00)
Title: Refactoring codes and support complex virt-sandbox options testing

The current test framework doesn't support complex options testing of virt-sandbox, for example,

1. virt-sandbox -c lxc:/// -n foo -N "dhcp,source=default" -N "dhcp,mac=00:44:33:22:11:55" -N "address=192.168.122.100/24,route=0.0.0.0/24%192.168.122.1" -- /usr/sbin/ip link show

2. virt-sandbox -c lxc:/// -n foo -m "host-bind:/tmp=/var/lib" -i "/tmp -m "ram:/tmp=500M"

The patch is used for solving above issues, and can get a expected result, BTW, the patch 2 can be dropped, it just verifies whether the patch 1 works well, and then we should have a unit test testing sandbox framework later.

$ ./run -t lvsb --test type_specific.lvsb_complex_options.positive_testing --no-download --keep-image
SETUP: PASS (0.10 s)
DATA DIR: /var/lib/virt_test
DEBUG LOG: /home/ajia/Workspace/virt-test/logs/run-2014-01-08-18.05.02/debug.log
TESTS: 2
(1/2) type_specific.lvsb_complex_options.positive_testing.complex1: PASS (0.80 s)
(2/2) type_specific.lvsb_complex_options.positive_testing.complex2: PASS (0.71 s)
TOTAL TIME: 1.61 s
TESTS PASSED: 2
TESTS FAILED: 0
SUCCESS RATE: 100.00 %

$ grep "Launching" /home/ajia/Workspace/virt-test/logs/run-2014-01-08-18.05.02/debug.log
18:05:02 DEBUG| Launching /usr/bin/virt-sandbox -c lxc:/// -n SCB_1 -N dhcp,source=default -N dhcp,mac=00:44:33:22:11:55 -N address=192.168.122.100/24,route=0.0.0.0/24%192.168.122.1 -- /usr/sbin/ip link show
18:05:03 DEBUG| Launching /usr/bin/virt-sandbox -c lxc:/// -n SCB_2 -m host-bind:/tmp=/var/lib -i /tmp -m ram:/tmp=500M -- /usr/bin/mount

$ cat lvsb/tests/cfg/lvsb_complex_options.cfg
- lvsb_complex_options:
type = lvsb_complex_options
virt_test_type = lvsb
variants:
- positive_testing:
status_error = "no"
# Allows iterating times for the same option
lvsb_opts_count = 2
# The options look like lvsb_$name_options$num, the $num is an integer,
# for $name, please refer to options naming convention in virttest/lvsb_base.py
variants:
- complex1:
# Allows iterating times for the same option
lvsb_opts_count = 3
# e.g. -N "dhcp,source=default" -N "dhcp,mac=00:44:33:22:11:55" -N "address=192.168.122.100/24,route=0.0.0.0/24%192.168.122.1"
lvsb_network_options1 = "dhcp,source=default"
lvsb_network_options2 = "dhcp,mac=00:44:33:22:11:55"
lvsb_network_options3 = "address=192.168.122.100/24,route=0.0.0.0/24%192.168.122.1"
lvsb_command = "/usr/sbin/ip link show"
- complex2:
# The final options look like -m "host-bind:/tmp=/var/lib" -m "ram:/tmp=500M" -i "/tmp"
lvsb_mount_options1 = "host-bind:/tmp=/var/lib"
lvsb_mount_options2 = "ram:/tmp=500M"
lvsb_include_options1 = "/tmp"
lvsb_command ="/usr/bin/mount"