Package: lxc
Version: 0.8.0~rc1-4
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu raring ubuntu-patch

Dear Maintainer,

The attached debdiff adds a basic DEP-8 autopkgtest for lxc. See:

- https://code.launchpad.net/~jamesodhunt/ubuntu/raring/lxc/dep-8-tests
-
https://code.launchpad.net/~jamesodhunt/ubuntu/raring/lxc/dep-8-tests/+merge/157938

In Ubuntu, the attached patch was generated to achieve the following:

* Ensure a container can be created, started, stopped and cloned.

This is a very basic test, but I plan to add further checks soon.

Thanks for considering the patch.


-- System Information:
Debian Release: wheezy/sid
  APT prefers raring-updates
  APT policy: (500, 'raring-updates'), (500, 'raring-security'), (500, 'raring')
Architecture: i386 (i686)

Kernel: Linux 3.8.0-19-generic (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Kind regards,

James.
--
James Hunt
____________________________________
#upstart on freenode
http://upstart.ubuntu.com/cookbook
https://lists.ubuntu.com/mailman/listinfo/upstart-devel
=== modified file 'debian/changelog'

=== modified file 'debian/control'
--- debian/control      2013-02-18 22:12:13 +0000
+++ debian/control      2013-04-12 13:31:57 +0000
@@ -16,6 +16,7 @@
 Standards-Version: 3.9.4
 Homepage: http://lxc.sourceforge.net/
 X-Python3-Version: >= 3.2
+XS-Testsuite: autopkgtest
 
 Package: lxc
 Architecture: linux-any

=== added directory 'debian/tests'
=== added file 'debian/tests/control'
--- debian/tests/control        1970-01-01 00:00:00 +0000
+++ debian/tests/control        2013-04-12 13:32:11 +0000
@@ -0,0 +1,3 @@
+Tests: exercise
+Depends: @, cgroup-lite
+Restrictions: needs-root

=== added file 'debian/tests/exercise'
--- debian/tests/exercise       1970-01-01 00:00:00 +0000
+++ debian/tests/exercise       2013-04-22 13:22:33 +0000
@@ -0,0 +1,80 @@
+#!/bin/sh
+#---------------------------------------------------------------------
+# Some very basic tests to run in a DEP-8 environment.
+#---------------------------------------------------------------------
+
+template_dir=/usr/share/lxc/templates
+
+# Exit with error message.
+#
+# @msg: message to display.
+die()
+{
+    msg="$*"
+    echo "ERROR: $msg" >&2
+    exit 1
+}
+
+# seconds to wait for container to be running/stopped
+boot_secs=10
+shutdown_secs=10
+
+distro=$(lsb_release --id|cut -d: -f2-|awk '{print $1}'|tr '[A-Z]' '[a-z]')
+[ -z "$distro" ] && die "failed to determine distro"
+
+[ ! -d "$template_dir" ] && die "template directory does not exist"
+
+file=$(ls "${template_dir}/lxc-${distro}" 2>/dev/null)
+[ -z "$file" ] && die "template does not exist for distro '$distro'"
+template="$distro"
+
+release=$(lsb_release -c|awk '{print $2}')
+[ -z "$release" ] && die "failed to establish release"
+
+orig_name="${release}-dep8"
+new_name="${orig_name}-clone"
+
+name="$orig_name"
+
+# flush cache to ensure we always get the latest bootstrap image
+lxc-create -n "$name" -t "$template" -- "$release" --flush-cache || \
+    die "failed to create container '$name' using template '$template' for 
release '$release'"
+
+lxc-ls -1 | grep -q "^${name}$" || \
+    die "container not known"
+
+lxc-start -n "$name" --daemon || die "failed to initiate container start"
+
+lxc-wait -n "$name" -s RUNNING -t $boot_secs || \
+    die "container $name: did not start after $boot_secs seconds"
+
+lxc-stop -n "$name" || die "container $name: failed to initiate shutdown"
+
+lxc-wait -n "$name" -s STOPPED -t $shutdown_secs || \
+    die "container $name: did not stop within $shutdown_secs seconds"
+
+lxc-clone -o "$orig_name" -n "$new_name" || \
+    die "failed to clone container '$orig_name' to '$new_name'"
+
+# switch attention to the clone
+name="$new_name"
+
+lxc-start -n "$name" --daemon || die "container $name: failed to initiate 
start"
+
+lxc-wait -n "$name" -s RUNNING -t $boot_secs || \
+    die "container $name: did not start after $boot_secs seconds"
+
+lxc-stop -n "$name" || die "container $new_nam: failed to initiate shutdown"
+
+lxc-wait -n "$name" -s STOPPED -t $shutdown_secs || \
+    die "container $name: did not stop within $shutdown_secs seconds"
+
+# clean up
+for name in "$orig_name" "$new_name"
+do
+    lxc-destroy -n "$name" || die "container: $name: cannot delete"
+done
+
+echo SUCCESS
+
+exit 0

Reply via email to