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

Subscribers

People subscribed via source and target branches

to all changes: