Merge lp:~jamesodhunt/ubuntu/raring/lxc/dep-8-tests into lp:ubuntu/raring/lxc

Proposed by James Hunt
Status: Merged
Merge reported by: Martin Pitt
Merged at revision: not available
Proposed branch: lp:~jamesodhunt/ubuntu/raring/lxc/dep-8-tests
Merge into: lp:ubuntu/raring/lxc
Diff against target: 120 lines (+91/-0)
4 files modified
debian/changelog (+7/-0)
debian/control (+1/-0)
debian/tests/control (+3/-0)
debian/tests/exercise (+80/-0)
To merge this branch: bzr merge lp:~jamesodhunt/ubuntu/raring/lxc/dep-8-tests
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement (community) Approve
Stéphane Graber Pending
Ubuntu branches Pending
Review via email: mp+157938@code.launchpad.net

Description of the change

Basic DEP-8 tests for lxc.

Requires the fix for bug 1166870 before the tests will pass.

To post a comment you must log in.
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for your work on this test.

There is a missing test dependency on cgroup-lite which is not installed in a minimal testing environment. With this package added the test pass.

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

Oh, also, you should enable auto-discovery of the package by the test environment by adding:

   XS-Testsuite: autopkgtest

to the Sources paragraph in debian/control

242. By James Hunt

* debian/control: Added XS-Testsuite.
* debian/tests/control: Added missing cgroup-lite dependency.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Thanks Jibel - branch updated.

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

I tried latest commit and it works fine. Thanks for the fix!

review: Approve
243. By James Hunt

* debian/tests/exercise:
  - wait_for_state(): Remove and use lxc-wait!
  - Specify a distro template explicitly.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Further updates and now submitted to Debian too: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=705934

Revision history for this message
James Hunt (jamesodhunt) wrote :

Early feedback on bug above suggests this patch is not yet ready for Debian so please consider adding to Ubuntu until we have a version that is compatible with both debian+ubuntu so we have atleast some test coverage for the time being.

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

This was uploaded a while ago already:

lxc (0.9.0-0ubuntu8) saucy; urgency=low

  [ James Hunt ]
  * Add basic DEP-8 tests to ensure a container can be created, started,
    stopped and cloned.

 -- James Hunt <email address hidden> Tue, 21 May 2013 14:44:12 +0100

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-04-08 16:20:57 +0000
+++ debian/changelog 2013-04-22 13:30:49 +0000
@@ -1,3 +1,10 @@
1lxc (0.9.0-0ubuntu2) UNRELEASED; urgency=low
2
3 * Add basic DEP-8 tests to ensure a container can be created, started,
4 stopped and cloned.
5
6 -- James Hunt <james.hunt@ubuntu.com> Mon, 22 Apr 2013 14:24:15 +0100
7
1lxc (0.9.0-0ubuntu1) raring; urgency=low8lxc (0.9.0-0ubuntu1) raring; urgency=low
29
3 * New upstream release (0.9.0) (LP: #1166286)10 * New upstream release (0.9.0) (LP: #1166286)
411
=== modified file 'debian/control'
--- debian/control 2013-02-18 22:12:13 +0000
+++ debian/control 2013-04-22 13:30:49 +0000
@@ -16,6 +16,7 @@
16Standards-Version: 3.9.416Standards-Version: 3.9.4
17Homepage: http://lxc.sourceforge.net/17Homepage: http://lxc.sourceforge.net/
18X-Python3-Version: >= 3.218X-Python3-Version: >= 3.2
19XS-Testsuite: autopkgtest
1920
20Package: lxc21Package: lxc
21Architecture: linux-any22Architecture: linux-any
2223
=== added directory 'debian/tests'
=== added file 'debian/tests/control'
--- debian/tests/control 1970-01-01 00:00:00 +0000
+++ debian/tests/control 2013-04-22 13:30:49 +0000
@@ -0,0 +1,3 @@
1Tests: exercise
2Depends: @, cgroup-lite
3Restrictions: needs-root
04
=== added file 'debian/tests/exercise'
--- debian/tests/exercise 1970-01-01 00:00:00 +0000
+++ debian/tests/exercise 2013-04-22 13:30:49 +0000
@@ -0,0 +1,80 @@
1#!/bin/sh
2#---------------------------------------------------------------------
3# Some very basic tests to run in a DEP-8 environment.
4#---------------------------------------------------------------------
5
6template_dir=/usr/share/lxc/templates
7
8# Exit with error message.
9#
10# @msg: message to display.
11die()
12{
13 msg="$*"
14 echo "ERROR: $msg" >&2
15 exit 1
16}
17
18# seconds to wait for container to be running/stopped
19boot_secs=10
20shutdown_secs=10
21
22distro=$(lsb_release --id|cut -d: -f2-|awk '{print $1}'|tr '[A-Z]' '[a-z]')
23[ -z "$distro" ] && die "failed to determine distro"
24
25[ ! -d "$template_dir" ] && die "template directory does not exist"
26
27file=$(ls "${template_dir}/lxc-${distro}" 2>/dev/null)
28[ -z "$file" ] && die "template does not exist for distro '$distro'"
29template="$distro"
30
31release=$(lsb_release -c|awk '{print $2}')
32[ -z "$release" ] && die "failed to establish release"
33
34orig_name="${release}-dep8"
35new_name="${orig_name}-clone"
36
37name="$orig_name"
38
39# flush cache to ensure we always get the latest bootstrap image
40lxc-create -n "$name" -t "$template" -- "$release" --flush-cache || \
41 die "failed to create container '$name' using template '$template' for release '$release'"
42
43lxc-ls -1 | grep -q "^${name}$" || \
44 die "container not known"
45
46lxc-start -n "$name" --daemon || die "failed to initiate container start"
47
48lxc-wait -n "$name" -s RUNNING -t $boot_secs || \
49 die "container $name: did not start after $boot_secs seconds"
50
51lxc-stop -n "$name" || die "container $name: failed to initiate shutdown"
52
53lxc-wait -n "$name" -s STOPPED -t $shutdown_secs || \
54 die "container $name: did not stop within $shutdown_secs seconds"
55
56lxc-clone -o "$orig_name" -n "$new_name" || \
57 die "failed to clone container '$orig_name' to '$new_name'"
58
59# switch attention to the clone
60name="$new_name"
61
62lxc-start -n "$name" --daemon || die "container $name: failed to initiate start"
63
64lxc-wait -n "$name" -s RUNNING -t $boot_secs || \
65 die "container $name: did not start after $boot_secs seconds"
66
67lxc-stop -n "$name" || die "container $new_nam: failed to initiate shutdown"
68
69lxc-wait -n "$name" -s STOPPED -t $shutdown_secs || \
70 die "container $name: did not stop within $shutdown_secs seconds"
71
72# clean up
73for name in "$orig_name" "$new_name"
74do
75 lxc-destroy -n "$name" || die "container: $name: cannot delete"
76done
77
78echo SUCCESS
79
80exit 0

Subscribers

People subscribed via source and target branches

to all changes: