tags |
---|
open-iscsi |
This is how you can run the open-iscsi tests more piecemeal
Much of this is taken from the 'testing manually' section in debian/tests/README-boot-test.md
Running in a uvt-kvm guest isn't necessary, but it may help to reproduce an environment closer to what the dep8 test runners have. There, the system is running in qemu guest, so boot is slower.
Note that by default, the test disables kvm if it detects it is already in qemu. This was just to avoid flakeyness of nested kvm.
Note we start with 2G memory, as the test case launches a 512M guest so uvt-kvm's default 512M guest is not going to cut it.
host$ uvt-kvm create --memory=2048 sm-test1 release=bionic
host$ uvt-kvm wait sm-test1
host$ uvt-kvm ssh sm-test1
I use git-ubuntu only because I think it is awesome. Get the source code however you'd like.
uvt-guest$ sudo snap install git-ubuntu --classic
# this is only to avoid a prompt for lp user name.
uvt-guest$ git config --global gitubuntu.lpuser do-not-pester-me
uvt-guest$ git-ubuntu clone open-iscsi
uvt-guest$ cd open-iscsi
The dependencies are listed in debian/tests/control. I've just copied them out. If something doesn't seem right, consult debian/tests/control.
uvt-guest$ sudo apt-get update -q
uvt-guest$ pkgs="open-iscsi python tgt qemu-system ubuntu-cloudimage-keyring simplestreams python-netifaces distro-info cloud-image-utils dctrl-tools rsync"
uvt-guest$ sudo eatmydata apt-get install -qy $pkgs
We don't bother updating packages here, but use patch-image
to get the kernel and initramfs out of the image.
uvt-guest$ export PATH=$PWD/debian/tests:$PATH
uvt-guest$ get-image cosmic.d/ cosmic
uvt-guest$ sudo ./debian/tests/patch-image cosmic.d/disk.img \
--kernel=cosmic.d/kernel --initrd=cosmic.d/initrd
using kernel /boot/vmlinuz-4.15.0-23-generic
using initrd /boot/initrd.img-4.15.0-23-generic
It appears that 'timeout' that is used in xkvm
behaves oddly/badly
when outout is a terminal. It can be fixed in one of 2 ways
-
just don't use timeout at all
$ sed 's, timeout,# timeout,' debian/tests/tgt-boot-test
-
change timeout to use '--foreground'
$ sed 's, timeout --kill-after, timeout --foreground,' debian/tests/tgt-boot-test
Second, it might be useful to throw a '-v' on the xkvm invocation inside
of tgt-boot-test
to get more verbose output of xkvm. At very least that will make it output the 'should_try_kvm' info like:
should_try_kvm = no. virt=kvm (nested kvm is finicky). set _USE_KVM=1 to force.
Running tgt-boot-test
launches qemu-system-x86_64 in nographic
mode with escape character set to ctrl-e (-e 0x05)
.
So to exit qemu, do: ctrl-e
which will then show a (qemu)
prompt. There type quit
and hit enter.
Run the test like:
$ tgt-boot-test -v cosmic.d/disk.img cosmic.d/kernel cosmic.d/initrd
...
<you shoud see normal kernel boot output soon>
When run like this, the system will not automatically power off. You can log in as 'ubuntu:passw0rd' and look around.
When the test harness executes tgt-boot-test it passes --disk=MYDISK.img,serial=output-disk
and --user-data-add=MY_USER_DATA_FILE
.
MYDISK is just raw disk image (qemu-image create -f raw MYDISK.img
) that is used for collecting information to via commands run in the guest.
The content of MY_USER_DATA_FILE is in the COLLECT_USER_DATA
variable in debian/tests/test-pen-iscsi.py.
If you want to just have the system power off, you can use a user-data file like below. See cloud-init doc for more info on the power_state section.
$ cat poweroff.yaml
#cloud-config
power_state:
mode: poweroff
message: cloud-init finished. Shutting down.
timeout: 60
$ tgt-boot-test -vv --user-data-add=poweroff.yaml cosmic.d/disk.img cosmic.d/kernel cosmic.d/initrd