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
1=== modified file 'testsuites/lxc/test_lxc_api/test.sh'
2--- testsuites/lxc/test_lxc_api/test.sh 2012-09-14 13:40:31 +0000
3+++ testsuites/lxc/test_lxc_api/test.sh 2013-02-26 15:22:51 +0000
4@@ -22,20 +22,22 @@
5
6 set -e
7
8-echo "pwd" > /tmp/debug
9-pwd >> /tmp/debug
10-echo "id" >> /tmp/debug
11-id >> /tmp/debug
12-echo "/proc/self/status" >> /tmp/debug
13-cat /proc/self/status >> /tmp/debug
14-echo "ls /" >> /tmp/debug
15-ls / >> /tmp/debug
16-echo "ls /proc" >> /tmp/debug
17-ls /proc >> /tmp/debug
18-echo "I am $$" >> /tmp/debug
19+echo "pwd"
20+pwd
21+echo "id"
22+id
23+echo "/proc/self/status"
24+cat /proc/self/status
25+echo "ls /"
26+ls /
27+echo "ls /proc"
28+ls /proc
29+echo "I am $$"
30
31 rm -rf lxc
32 bzr branch ubuntu:lxc
33-python3 lxc/src/python-lxc/examples/api_test.py > /tmp/apiout 2>&1
34+cd lxc
35+debian/rules build
36+python3 src/python-lxc/examples/api_test.py
37
38 exit 0
39
40=== modified file 'testsuites/lxc/test_lxc_apparmor/lxctest.py'
41--- testsuites/lxc/test_lxc_apparmor/lxctest.py 2012-09-14 13:40:31 +0000
42+++ testsuites/lxc/test_lxc_apparmor/lxctest.py 2013-02-26 15:22:51 +0000
43@@ -7,7 +7,7 @@
44 # sudo apt-get -y install lxc libvirt-bin make gcc
45
46 class Lxc:
47- def __init__(self, template="ubuntu", relnum = "12.04", release=None, config = "/etc/lxc-test.conf", name=None):
48+ def __init__(self, template="ubuntu", relnum = "12.04", release=None, config=None, name=None):
49 self.name = name
50 if not name:
51 if release:
52
53=== modified file 'testsuites/lxc/test_lxc_reboot/test.sh'
54--- testsuites/lxc/test_lxc_reboot/test.sh 2012-09-14 13:40:31 +0000
55+++ testsuites/lxc/test_lxc_reboot/test.sh 2013-02-26 15:22:51 +0000
56@@ -23,6 +23,6 @@
57 set -e
58
59 make reboot-test
60-./reboot-test > /tmp/rebootout 2>&1
61+./reboot-test
62
63 exit 0
64
65=== modified file 'testsuites/lxc/test_lxc_simple/lxctest.py'
66--- testsuites/lxc/test_lxc_simple/lxctest.py 2012-09-14 13:40:31 +0000
67+++ testsuites/lxc/test_lxc_simple/lxctest.py 2013-02-26 15:22:51 +0000
68@@ -1,3 +1,5 @@
69+#!/usr/bin/python
70+
71 import unittest, subprocess, sys
72 import platform, os, shutil
73 import time
74@@ -7,7 +9,7 @@
75 # sudo apt-get -y install lxc libvirt-bin make gcc
76
77 class Lxc:
78- def __init__(self, template="ubuntu", relnum = "12.04", release=None, config = "/etc/lxc-test.conf", name=None):
79+ def __init__(self, template="ubuntu", relnum = "12.04", release=None, config=None, name=None):
80 self.name = name
81 if not name:
82 if release:
83@@ -54,35 +56,31 @@
84 if ret != 0:
85 raise ValueError, "Failed apt-get update in container %s" % (self.name)
86
87- cmd = ["chroot", rootpath, "apt-get", "-y", "install", "libcap2"]
88- ret = subprocess.call(cmd, stdout=None, stderr=None)
89- if ret != 0:
90- raise ValueError, "Failed installing libcap2 in container %s" % (self.name)
91- cmd = ["chroot", rootpath, "apt-get", "-y", "install", "--download-only", "lxc"]
92- ret = subprocess.call(cmd, stdout=None, stderr=None)
93- if ret != 0:
94- raise ValueError, "Failed downloading lxc in container %s" % (self.name)
95-
96- cmd = ["chroot", rootpath, "apt-get", "-y", "install", "libapparmor1"]
97- ret = subprocess.call(cmd, stdout=None, stderr=None)
98- if ret != 0:
99- raise ValueError, "Failed installing libapparmor1 in container %s" % (self.name)
100-
101- # extract lxc package into container's /tmp
102- pkgpath = "%s/var/cache/apt/archives/lxc_*" % (rootpath)
103- tmppath = "%s/tmp" % (rootpath)
104- cmd = "dpkg -x %s %s" % (pkgpath, tmppath)
105- ret = subprocess.call(cmd, shell=True, stdout=None, stderr=None)
106- if ret != 0:
107- raise ValueError, "Failed extracting lxc in container %s" % (self.name)
108-
109- # copying /usr/lib/lxc into container
110- srcpath = "%s/usr/lib/lxc" % (tmppath)
111- destpath = "%s/usr/lib" % (rootpath)
112- cmd = ["cp", "-a", srcpath, destpath]
113- ret = subprocess.call(cmd, stdout=None, stderr=None)
114- if ret != 0:
115- raise ValueError, "Failed copying lxc package contents in container %s" % (self.name)
116+ updatetxt='''#!/bin/sh
117+exit 101
118+'''
119+ f=open("/var/lib/lxc/%s/rootfs/usr/sbin/policy-rc.d" % (self.name), "w")
120+ f.write(updatetxt)
121+ f.close()
122+ cmd = ["chmod", "+x", "/var/lib/lxc/%s/rootfs/usr/sbin/policy-rc.d" % (self.name)]
123+ ret = subprocess.call(cmd, stdout=None, stderr=None)
124+ if ret != 0:
125+ raise ValueError, "Failed to make policy-rc.d +x in container %s" % (self.name)
126+
127+ cmd = ["chroot", rootpath, "apt-get", "-y", "install", "--no-install-recommends", "lxc"]
128+ ret = subprocess.call(cmd, stdout=None, stderr=None)
129+ if ret != 0:
130+ raise ValueError, "Failed installing lxc in container %s" % (self.name)
131+
132+ cmd = ["rm", "-f", "/var/lib/lxc/%s/rootfs/etc/init/lxc*" % (self.name)]
133+ ret = subprocess.call(cmd, stdout=None, stderr=None)
134+ if ret != 0:
135+ raise ValueError, "Failed removing /etc/init/lxc* in container %s" % (self.name)
136+
137+ cmd = ["rm", "-f", "/var/lib/lxc/%s/rootfs/usr/sbin/policy-rc.d" % (self.name)]
138+ ret = subprocess.call(cmd, stdout=None, stderr=None)
139+ if ret != 0:
140+ raise ValueError, "Failed removing policy-rc.d in container %s" % (self.name)
141
142 def Execute(self, program="/bin/true"):
143 cmd = ["lxc-execute", "-n", self.name, "--", program]
144@@ -155,32 +153,17 @@
145 elif self.arch == "armv7l":
146 self.arch="armel"
147
148- if self.arch == "armel":
149- self.tests = [["ubuntu", 11.10, "oneiric"],
150- ["ubuntu", 12.04, "precise"]]
151- elif self.arch == "armhf":
152- self.tests = [["ubuntu", 12.04, "precise"]]
153+ if self.arch == "armel" or self.arch == "armhf":
154+ self.tests = [["ubuntu", 12.04, "precise"],
155+ ["ubuntu", 13.04, "raring"]]
156 else:
157 self.tests = [["ubuntu", 8.04, "lucid"],
158- ["ubuntu", 11.10, "oneiric"],
159 ["ubuntu", 12.04, "precise"],
160- ["ubuntu-cloud", 8.04, "lucid"],
161- ["ubuntu-cloud", 11.10, "oneiric"],
162- ["ubuntu-cloud", 12.04, "precise"],
163+ ["ubuntu", 13.04, "raring"],
164+ #["ubuntu-cloud", 8.04, "lucid"],
165+ #["ubuntu-cloud", 12.04, "precise"],
166 ]
167
168- lxctestconf = '''
169-lxc.network.type=veth
170-lxc.network.link=virbr0
171-lxc.network.flags=up
172-'''
173- f = open("/etc/lxc-test.conf", "w")
174- f.write(lxctestconf)
175- f.close()
176-
177- def tearDown(self):
178- os.remove("/etc/lxc-test.conf")
179-
180 def runTest(self):
181 for (t,relnum,r) in self.tests:
182 try:
183@@ -280,8 +263,6 @@
184 self.assertTrue(False, "Failed at container autostart test %s\nError: %s" % (test, e))
185
186 if __name__ == '__main__':
187- # set keepcache true if you're developing and want to save some time...
188- keepcache=False
189 # check for uid 0
190 uid = os.getuid()
191 if uid != 0:
192@@ -295,7 +276,7 @@
193 sys.exit(1)
194
195 # make sure the needed prereqs are installed
196- cmd = ["sudo", "apt-get", "-y", "install", "lxc", "libvirt-bin", "make", "gcc"]
197+ cmd = ["sudo", "apt-get", "-y", "install", "lxc", "make", "gcc"]
198 if dist[1] >= 12.10:
199 cmd += [ "bzr", "python3-lxc" ]
200
201@@ -305,23 +286,13 @@
202 sys.exit(1)
203
204 # apt-get install -y cgroup-lite libvirt-bin lxc lsb-release make gcc
205- if dist[1] < 11.10:
206- print >>sys.stderr, "testsuite only supported on oneiric and precise"
207+ if dist[1] < 12.04:
208+ print >>sys.stderr, "testsuite only supported on precise and later"
209 sys.exit(1)
210
211 suite = unittest.TestSuite()
212
213 suite.addTest(SimpleLxcTests())
214- if not keepcache:
215- suite.addTest(SimpleLxcTests())
216-
217- # clear the caches for the first run. we'll do two runs
218- if not keepcache:
219- try:
220- shutil.rmtree("/var/cache/lxc")
221- os.mkdir("/var/cache/lxc", 0755)
222- except:
223- pass
224
225 rc = unittest.TextTestRunner(verbosity=2).run(suite)
226
227
228=== modified file 'testsuites/lxc/test_lxc_simple/test.sh'
229--- testsuites/lxc/test_lxc_simple/test.sh 2012-09-14 17:50:59 +0000
230+++ testsuites/lxc/test_lxc_simple/test.sh 2013-02-26 15:22:51 +0000
231@@ -2,6 +2,6 @@
232
233 set -e
234
235-python lxctest.py > /tmp/simpleout 2>&1
236+python lxctest.py
237
238 exit 0
239
240=== modified file 'testsuites/lxc/tsetup/setup.sh'
241--- testsuites/lxc/tsetup/setup.sh 2012-09-14 13:40:31 +0000
242+++ testsuites/lxc/tsetup/setup.sh 2013-02-26 15:22:51 +0000
243@@ -19,7 +19,9 @@
244 # <http://www.gnu.org/licenses/>.
245 #
246
247-bzr branch lp:~serge-hallyn/+junk/lxc-test
248+# not needed - that suite is copied here in parts.
249+#bzr branch lp:~serge-hallyn/+junk/lxc-test
250 sudo apt-get -y --force-yes install lxc make gcc bzr python3-lxc
251+sudo apt-get -y build-dep lxc
252 rm -rf /var/cache/lxc || true
253 mkdir -p /var/cache/lxc

Subscribers

People subscribed via source and target branches

to all changes: