ability to have a DEP-8 test run a test in a separate full system environment

Bug #1158391 reported by James Hunt
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Auto Package Testing
Fix Released
High
James Hunt

Bug Description

The auto-package-test currently creates a kvm instance and runs the DEP-8 tests for a package within it. This is perfectly fine for the majority of packages however, for boot-related packages this can be a problem since if any of the DEP-8 tests cause the auto-package-test environment to fail, the invoker (jenkins) has to detect that the kvm instance is dead after some (probably very long) timeout.

Ideally, there would be a way for a DEP-8 test to specify "run me in a container ('primary container'), but give me access to *another* container ('secondary container') to allow me to run my test(s) in. That way, if any of the tests in 'secondary container' fail (in other words kill 'secondary container'), the DEP-8 test in 'primary container' can handle that gracefully and return a normal failure exit code.

Note that 'secondary container' could either be a nested KVM instance or in fact an entirely separate KVM instance running alongside 'primary container'. LXC is an option but KVM would be preferable since it simulates a full system more fully than LXC which has slightly different semantics.

Examples of packages that could make use of such a facility:

- kernel
- initramfs-tools
- udev
- upstart
- mountall
- plymouth

An example of how this might work for Upstart:

- auto-package-test VM starts
- new version of Upstart package is installed (although not needed in this scenario).
- DEP-8 test runs some new command like:

  container-test --packages upstart --timeout 120 --test foo.py --user ubuntu --reboot --log /tmp/foo.log --console /tmp/console.log

- 'container-test' would:

  - start a secondary container
  - install latest upstart package
  - reboot the secondary container to simulate a full boot.
  - run foo.py as the named user.
  - wait for up to say 2 minutes for the container to shutdown.
    - if it fails to shutdown => TEST FAILED.
    - if it does shut down, the upstart test could check /tmp/foo.log for some expected output.
      - if output as expected => TEST PASSED.
        else => TEST FAILED.

Requirements:

- ability for the test in the primary container to:
  - have access to the secondary containers console log and or syslog.
  - run a program in the secondary container as a specified user from a specified directory.
  - boot the secondary container.
  - kill the secondary container.
  - shutdown the secondary container.
  - copy named files from the secondary container to the primary.

Related branches

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for your report.

autopkgtest supports 3 types of virtual server regimes:
- null: tests are executed directly on the host
- virt-chroot: use a chroot for isolation
- virt-xenlvm: uses Xen + LVM snapshots

The virt-xenlvm would provide most of the features you describe (I am not sure about reboot) but we have the constraint in the QA Lab to use KVM.

A possible solution would be to implement an additional driver for KVM.

Changed in auto-package-testing:
importance: Undecided → High
status: New → Confirmed
assignee: nobody → Jean-Baptiste Lallement (jibel)
Revision history for this message
James Hunt (jamesodhunt) wrote :

See this thread for details of work done by racb:

https://lists.ubuntu.com/archives/ubuntu-server/2013-July/006667.html

Revision history for this message
Martin Pitt (pitti) wrote :

With this patch you can do this relatively easily with run-adt-test. Apply it, then start the outer VM with "run-adt-test -sUl", and "sudo apt-get install qemu-kvm" in the VM. I don't want to install kvm by default into test VMs as it has quite a large dependency chain and isn't needed for most tests. So upstart or other tests which want to use this feature need to test-depend on qemu-kvm.

Then, create a writable overlay with

   qemu-img create -f qcow2 -o backing_file=/dev/pristine_vm overlay

start the nested VM with

  kvm -vnc localhost:11 -redir tcp:2222::22 -drive file=overlay,if=virtio -drive file=/dev/cloud_config,if=virtio,index=2,readonly

wait a bit, and ssh into the child VM with

  ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 2222 ubuntu@localhost

(no password necessary, it uses the run-adt-test ssh key). We can wrap those into a convenience script at some point, but James said he'll need some hooks in between, so let's do the first experiments with above raw commands and then see how we can generalize them.

Martin Pitt (pitti)
Changed in auto-package-testing:
assignee: Jean-Baptiste Lallement (jibel) → Martin Pitt (pitti)
status: Confirmed → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

The previous patch added the original pristine VM at the qemu command line. This had the effect that /dev/vda1 and /dev/vdc1 looked identical in terms of UUID and label, which confused initramfs and cloud-init. Thus this caused a hung boot at around half of the cases.

This updated patch avoids that by hot-adding the pristine VM image after the VM has already booted. I tested that some 10 times in a row successfully, and it still maintains the property that the pristine image does not need to be copied into the outer VM. Thanks to Robie for the idea!

I am happy with the patch now. Eyeballing appreciated, but otherwise I think it's ready to land.

Revision history for this message
Martin Pitt (pitti) wrote :

Landed in http://bazaar.launchpad.net/~auto-package-testing-dev/auto-package-testing/trunk/revision/217 and rolled out. Keeping the bug open as we might want more enhancements/convenience scripts based on James' experiments.

Changed in auto-package-testing:
status: In Progress → Confirmed
assignee: Martin Pitt (pitti) → James Hunt (jamesodhunt)
Revision history for this message
James Hunt (jamesodhunt) wrote :

For reference, we've been having issues running double-nested VM's with a 3.10 kernel. See bug 1208509.

Revision history for this message
Martin Pitt (pitti) wrote :

Closing for now. The nested VM functionality is still available, and any problems with nested KVM are qemu bugs, not auto-package-testing.

Changed in auto-package-testing:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.