Skip to content

Instantly share code, notes, and snippets.

@smoser
Last active July 20, 2018 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoser/ffb519d00bafd2105abbc180c3410e76 to your computer and use it in GitHub Desktop.
Save smoser/ffb519d00bafd2105abbc180c3410e76 to your computer and use it in GitHub Desktop.
open-iscsi package test debug information
tags
open-iscsi

open-iscsi package test debug

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

Start a uvt-kvm guest to do your test in

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

Get the open-iscsi source

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

Get dependencies installed

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

Download image, get kernel and initramfs from inside it.

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

Twidle some things for interactive use

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.

Boot system

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.

boot and automatically power off.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment