Merge lp:~serge-hallyn/ubuntu-test-cases/server-lxc2 into lp:ubuntu-test-cases/server

Proposed by Serge Hallyn
Status: Merged
Merged at revision: 81
Proposed branch: lp:~serge-hallyn/ubuntu-test-cases/server-lxc2
Merge into: lp:ubuntu-test-cases/server
Diff against target: 253 lines (+57/-82)
6 files modified
testsuites/lxc/test_lxc_api/test.sh (+14/-12)
testsuites/lxc/test_lxc_apparmor/lxctest.py (+1/-1)
testsuites/lxc/test_lxc_reboot/test.sh (+1/-1)
testsuites/lxc/test_lxc_simple/lxctest.py (+37/-66)
testsuites/lxc/test_lxc_simple/test.sh (+1/-1)
testsuites/lxc/tsetup/setup.sh (+3/-1)
To merge this branch: bzr merge lp:~serge-hallyn/ubuntu-test-cases/server-lxc2
Reviewer Review Type Date Requested Status
Paul Larson (community) Approve
Review via email: mp+150491@code.launchpad.net

Description of the change

This commit will make debugging lxc testcase failures easier to debug, and *should* fix bug 1130029.

(Note - this replaces the mp for lp:~serge-hallyn/ubuntu-test-cases/server-lxc-fixapi)

To post a comment you must log in.
80. By Serge Hallyn

don't set config to a nonexisting file by default

(no effect, since we explicitly pass in NULL)

81. By Serge Hallyn

fix syntax error (double commas)

Revision history for this message
Stéphane Graber (stgraber) wrote :

I'm not seeing anything obviously wrong, just a few notes:
 - I just sent a patch upstream to drop the need for autoconf pre-processing of api_test.py which should let you drop the extra build from the test.
 - Might be worth running pyflakes and pep8 against all the python scripts, I noticed some things that aren't PEP-8 compliant.
 - When installing lxc in the container, you can easily avoid the policy-rc.d + rm by simply creating /etc/init/lxc.override with "manual" as content before installing lxc. This will prevent upstart from starting the lxc job and any job depending on it.

Revision history for this message
Paul Larson (pwlars) wrote :

+1

review: Approve
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Quoting Stéphane Graber (<email address hidden>):
> I'm not seeing anything obviously wrong, just a few notes:
> - I just sent a patch upstream to drop the need for autoconf pre-processing of api_test.py which should let you drop the extra build from the test.

Unfortunately that isn't yet in our package :) But I've left a comment
to remind us of that.

> - Might be worth running pyflakes and pep8 against all the python scripts, I noticed some things that aren't PEP-8 compliant.
> - When installing lxc in the container, you can easily avoid the policy-rc.d + rm by simply creating /etc/init/lxc.override with "manual" as content before installing lxc. This will prevent upstart from starting the lxc job and any job depending on it.

Awesome, that leaves PkgSetup() looking much nicer, thanks.

-serge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'testsuites/lxc/test_lxc_api/test.sh'
--- testsuites/lxc/test_lxc_api/test.sh 2012-09-14 13:40:31 +0000
+++ testsuites/lxc/test_lxc_api/test.sh 2013-02-26 15:22:51 +0000
@@ -22,20 +22,22 @@
2222
23set -e23set -e
2424
25echo "pwd" > /tmp/debug25echo "pwd"
26pwd >> /tmp/debug26pwd
27echo "id" >> /tmp/debug27echo "id"
28id >> /tmp/debug28id
29echo "/proc/self/status" >> /tmp/debug29echo "/proc/self/status"
30cat /proc/self/status >> /tmp/debug30cat /proc/self/status
31echo "ls /" >> /tmp/debug31echo "ls /"
32ls / >> /tmp/debug32ls /
33echo "ls /proc" >> /tmp/debug33echo "ls /proc"
34ls /proc >> /tmp/debug34ls /proc
35echo "I am $$" >> /tmp/debug35echo "I am $$"
3636
37rm -rf lxc37rm -rf lxc
38bzr branch ubuntu:lxc38bzr branch ubuntu:lxc
39python3 lxc/src/python-lxc/examples/api_test.py > /tmp/apiout 2>&139cd lxc
40debian/rules build
41python3 src/python-lxc/examples/api_test.py
4042
41exit 043exit 0
4244
=== modified file 'testsuites/lxc/test_lxc_apparmor/lxctest.py'
--- testsuites/lxc/test_lxc_apparmor/lxctest.py 2012-09-14 13:40:31 +0000
+++ testsuites/lxc/test_lxc_apparmor/lxctest.py 2013-02-26 15:22:51 +0000
@@ -7,7 +7,7 @@
7# sudo apt-get -y install lxc libvirt-bin make gcc7# sudo apt-get -y install lxc libvirt-bin make gcc
88
9class Lxc:9class Lxc:
10 def __init__(self, template="ubuntu", relnum = "12.04", release=None, config = "/etc/lxc-test.conf", name=None):10 def __init__(self, template="ubuntu", relnum = "12.04", release=None, config=None, name=None):
11 self.name = name11 self.name = name
12 if not name:12 if not name:
13 if release:13 if release:
1414
=== modified file 'testsuites/lxc/test_lxc_reboot/test.sh'
--- testsuites/lxc/test_lxc_reboot/test.sh 2012-09-14 13:40:31 +0000
+++ testsuites/lxc/test_lxc_reboot/test.sh 2013-02-26 15:22:51 +0000
@@ -23,6 +23,6 @@
23set -e23set -e
2424
25make reboot-test25make reboot-test
26./reboot-test > /tmp/rebootout 2>&126./reboot-test
2727
28exit 028exit 0
2929
=== modified file 'testsuites/lxc/test_lxc_simple/lxctest.py'
--- testsuites/lxc/test_lxc_simple/lxctest.py 2012-09-14 13:40:31 +0000
+++ testsuites/lxc/test_lxc_simple/lxctest.py 2013-02-26 15:22:51 +0000
@@ -1,3 +1,5 @@
1#!/usr/bin/python
2
1import unittest, subprocess, sys3import unittest, subprocess, sys
2import platform, os, shutil4import platform, os, shutil
3import time5import time
@@ -7,7 +9,7 @@
7# sudo apt-get -y install lxc libvirt-bin make gcc9# sudo apt-get -y install lxc libvirt-bin make gcc
810
9class Lxc:11class Lxc:
10 def __init__(self, template="ubuntu", relnum = "12.04", release=None, config = "/etc/lxc-test.conf", name=None):12 def __init__(self, template="ubuntu", relnum = "12.04", release=None, config=None, name=None):
11 self.name = name13 self.name = name
12 if not name:14 if not name:
13 if release:15 if release:
@@ -54,35 +56,31 @@
54 if ret != 0:56 if ret != 0:
55 raise ValueError, "Failed apt-get update in container %s" % (self.name)57 raise ValueError, "Failed apt-get update in container %s" % (self.name)
5658
57 cmd = ["chroot", rootpath, "apt-get", "-y", "install", "libcap2"]59 updatetxt='''#!/bin/sh
58 ret = subprocess.call(cmd, stdout=None, stderr=None)60exit 101
59 if ret != 0:61'''
60 raise ValueError, "Failed installing libcap2 in container %s" % (self.name)62 f=open("/var/lib/lxc/%s/rootfs/usr/sbin/policy-rc.d" % (self.name), "w")
61 cmd = ["chroot", rootpath, "apt-get", "-y", "install", "--download-only", "lxc"]63 f.write(updatetxt)
62 ret = subprocess.call(cmd, stdout=None, stderr=None)64 f.close()
63 if ret != 0:65 cmd = ["chmod", "+x", "/var/lib/lxc/%s/rootfs/usr/sbin/policy-rc.d" % (self.name)]
64 raise ValueError, "Failed downloading lxc in container %s" % (self.name)66 ret = subprocess.call(cmd, stdout=None, stderr=None)
6567 if ret != 0:
66 cmd = ["chroot", rootpath, "apt-get", "-y", "install", "libapparmor1"]68 raise ValueError, "Failed to make policy-rc.d +x in container %s" % (self.name)
67 ret = subprocess.call(cmd, stdout=None, stderr=None)69
68 if ret != 0:70 cmd = ["chroot", rootpath, "apt-get", "-y", "install", "--no-install-recommends", "lxc"]
69 raise ValueError, "Failed installing libapparmor1 in container %s" % (self.name)71 ret = subprocess.call(cmd, stdout=None, stderr=None)
7072 if ret != 0:
71 # extract lxc package into container's /tmp73 raise ValueError, "Failed installing lxc in container %s" % (self.name)
72 pkgpath = "%s/var/cache/apt/archives/lxc_*" % (rootpath)74
73 tmppath = "%s/tmp" % (rootpath)75 cmd = ["rm", "-f", "/var/lib/lxc/%s/rootfs/etc/init/lxc*" % (self.name)]
74 cmd = "dpkg -x %s %s" % (pkgpath, tmppath)76 ret = subprocess.call(cmd, stdout=None, stderr=None)
75 ret = subprocess.call(cmd, shell=True, stdout=None, stderr=None)77 if ret != 0:
76 if ret != 0:78 raise ValueError, "Failed removing /etc/init/lxc* in container %s" % (self.name)
77 raise ValueError, "Failed extracting lxc in container %s" % (self.name)79
7880 cmd = ["rm", "-f", "/var/lib/lxc/%s/rootfs/usr/sbin/policy-rc.d" % (self.name)]
79 # copying /usr/lib/lxc into container81 ret = subprocess.call(cmd, stdout=None, stderr=None)
80 srcpath = "%s/usr/lib/lxc" % (tmppath)82 if ret != 0:
81 destpath = "%s/usr/lib" % (rootpath)83 raise ValueError, "Failed removing policy-rc.d in container %s" % (self.name)
82 cmd = ["cp", "-a", srcpath, destpath]
83 ret = subprocess.call(cmd, stdout=None, stderr=None)
84 if ret != 0:
85 raise ValueError, "Failed copying lxc package contents in container %s" % (self.name)
8684
87 def Execute(self, program="/bin/true"):85 def Execute(self, program="/bin/true"):
88 cmd = ["lxc-execute", "-n", self.name, "--", program]86 cmd = ["lxc-execute", "-n", self.name, "--", program]
@@ -155,32 +153,17 @@
155 elif self.arch == "armv7l":153 elif self.arch == "armv7l":
156 self.arch="armel"154 self.arch="armel"
157155
158 if self.arch == "armel":156 if self.arch == "armel" or self.arch == "armhf":
159 self.tests = [["ubuntu", 11.10, "oneiric"],157 self.tests = [["ubuntu", 12.04, "precise"],
160 ["ubuntu", 12.04, "precise"]]158 ["ubuntu", 13.04, "raring"]]
161 elif self.arch == "armhf":
162 self.tests = [["ubuntu", 12.04, "precise"]]
163 else:159 else:
164 self.tests = [["ubuntu", 8.04, "lucid"],160 self.tests = [["ubuntu", 8.04, "lucid"],
165 ["ubuntu", 11.10, "oneiric"],
166 ["ubuntu", 12.04, "precise"],161 ["ubuntu", 12.04, "precise"],
167 ["ubuntu-cloud", 8.04, "lucid"],162 ["ubuntu", 13.04, "raring"],
168 ["ubuntu-cloud", 11.10, "oneiric"],163 #["ubuntu-cloud", 8.04, "lucid"],
169 ["ubuntu-cloud", 12.04, "precise"],164 #["ubuntu-cloud", 12.04, "precise"],
170 ]165 ]
171166
172 lxctestconf = '''
173lxc.network.type=veth
174lxc.network.link=virbr0
175lxc.network.flags=up
176'''
177 f = open("/etc/lxc-test.conf", "w")
178 f.write(lxctestconf)
179 f.close()
180
181 def tearDown(self):
182 os.remove("/etc/lxc-test.conf")
183
184 def runTest(self):167 def runTest(self):
185 for (t,relnum,r) in self.tests:168 for (t,relnum,r) in self.tests:
186 try:169 try:
@@ -280,8 +263,6 @@
280 self.assertTrue(False, "Failed at container autostart test %s\nError: %s" % (test, e))263 self.assertTrue(False, "Failed at container autostart test %s\nError: %s" % (test, e))
281264
282if __name__ == '__main__':265if __name__ == '__main__':
283 # set keepcache true if you're developing and want to save some time...
284 keepcache=False
285 # check for uid 0266 # check for uid 0
286 uid = os.getuid()267 uid = os.getuid()
287 if uid != 0:268 if uid != 0:
@@ -295,7 +276,7 @@
295 sys.exit(1)276 sys.exit(1)
296277
297 # make sure the needed prereqs are installed278 # make sure the needed prereqs are installed
298 cmd = ["sudo", "apt-get", "-y", "install", "lxc", "libvirt-bin", "make", "gcc"]279 cmd = ["sudo", "apt-get", "-y", "install", "lxc", "make", "gcc"]
299 if dist[1] >= 12.10:280 if dist[1] >= 12.10:
300 cmd += [ "bzr", "python3-lxc" ]281 cmd += [ "bzr", "python3-lxc" ]
301282
@@ -305,23 +286,13 @@
305 sys.exit(1)286 sys.exit(1)
306287
307 # apt-get install -y cgroup-lite libvirt-bin lxc lsb-release make gcc288 # apt-get install -y cgroup-lite libvirt-bin lxc lsb-release make gcc
308 if dist[1] < 11.10:289 if dist[1] < 12.04:
309 print >>sys.stderr, "testsuite only supported on oneiric and precise"290 print >>sys.stderr, "testsuite only supported on precise and later"
310 sys.exit(1)291 sys.exit(1)
311292
312 suite = unittest.TestSuite()293 suite = unittest.TestSuite()
313294
314 suite.addTest(SimpleLxcTests())295 suite.addTest(SimpleLxcTests())
315 if not keepcache:
316 suite.addTest(SimpleLxcTests())
317
318 # clear the caches for the first run. we'll do two runs
319 if not keepcache:
320 try:
321 shutil.rmtree("/var/cache/lxc")
322 os.mkdir("/var/cache/lxc", 0755)
323 except:
324 pass
325296
326 rc = unittest.TextTestRunner(verbosity=2).run(suite)297 rc = unittest.TextTestRunner(verbosity=2).run(suite)
327298
328299
=== modified file 'testsuites/lxc/test_lxc_simple/test.sh'
--- testsuites/lxc/test_lxc_simple/test.sh 2012-09-14 17:50:59 +0000
+++ testsuites/lxc/test_lxc_simple/test.sh 2013-02-26 15:22:51 +0000
@@ -2,6 +2,6 @@
22
3set -e3set -e
44
5python lxctest.py > /tmp/simpleout 2>&15python lxctest.py
66
7exit 07exit 0
88
=== modified file 'testsuites/lxc/tsetup/setup.sh'
--- testsuites/lxc/tsetup/setup.sh 2012-09-14 13:40:31 +0000
+++ testsuites/lxc/tsetup/setup.sh 2013-02-26 15:22:51 +0000
@@ -19,7 +19,9 @@
19# <http://www.gnu.org/licenses/>.19# <http://www.gnu.org/licenses/>.
20# 20#
2121
22bzr branch lp:~serge-hallyn/+junk/lxc-test22# not needed - that suite is copied here in parts.
23#bzr branch lp:~serge-hallyn/+junk/lxc-test
23sudo apt-get -y --force-yes install lxc make gcc bzr python3-lxc24sudo apt-get -y --force-yes install lxc make gcc bzr python3-lxc
25sudo apt-get -y build-dep lxc
24rm -rf /var/cache/lxc || true26rm -rf /var/cache/lxc || true
25mkdir -p /var/cache/lxc27mkdir -p /var/cache/lxc

Subscribers

People subscribed via source and target branches

to all changes: