Merge lp:~javier.collado/ubuntu-test-cases/desktop-minconfig into lp:~javier.collado/ubuntu-test-cases/desktop

Proposed by Javier Collado
Status: Merged
Merged at revision: 34
Proposed branch: lp:~javier.collado/ubuntu-test-cases/desktop-minconfig
Merge into: lp:~javier.collado/ubuntu-test-cases/desktop
Diff against target: 651 lines (+339/-48)
22 files modified
configs/oem.conf (+2/-2)
runlists/min_config.run (+11/-0)
scripts/min_config.sh (+12/-0)
testsuites/usit/dbus_machine_id/test.py (+3/-3)
testsuites/usit/desktop_shortcut_exists/test.py (+3/-3)
testsuites/usit/disk_not_full/tc_control (+9/-0)
testsuites/usit/disk_not_full/test.py (+58/-0)
testsuites/usit/empty_startup_app/setup.py (+3/-3)
testsuites/usit/empty_startup_app/test.py (+3/-3)
testsuites/usit/encrypted_home_content/test.py (+13/-10)
testsuites/usit/encrypted_home_permissions/test.py (+11/-9)
testsuites/usit/no_rofs_machine_id/test.py (+3/-3)
testsuites/usit/oem_pkg_installed/test.py (+3/-3)
testsuites/usit/out_of_memory/tc_control (+11/-0)
testsuites/usit/out_of_memory/test.py (+49/-0)
testsuites/usit/read_write/test.py (+3/-3)
testsuites/usit/total_disk/tc_control (+9/-0)
testsuites/usit/total_disk/test.py (+54/-0)
testsuites/usit/total_mem/tc_control (+9/-0)
testsuites/usit/total_mem/test.py (+62/-0)
testsuites/usit/tslist.run (+4/-0)
testsuites/usit/ubiquity/test.py (+4/-6)
To merge this branch: bzr merge lp:~javier.collado/ubuntu-test-cases/desktop-minconfig
Reviewer Review Type Date Requested Status
Javier Collado Approve
Paul Larson Pending
Review via email: mp+141864@code.launchpad.net

Description of the change

This branch contains the migration of the minimal configuration test cases that
can be found in:
lp:~pwlars/ubuntu-test-cases/desktop-minconfig

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

@Paul

I'm creating this merge request to keep a record of the changes to get the
minimal config scenario working in Launchpad just in case you want to take a
look at it in the future.

Anyway, I'm merging this now and marking also your branch:
lp:~pwlars/ubuntu-test-cases/desktop-minconfig

as merged since the work here is based on the test cases there. Also, I'll
create the jobs needed for this scenario and give it a try to see how it works
in a jenkins instance.

Revision history for this message
Javier Collado (javier.collado) wrote :

As explained above, I'm approving this merge request myself, but I'm open to
any comment or feedback.

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

Thanks for doing this, I just got back from vacation today, sorry for not seeing it sooner. Does this completely replace my previous branch? Is there anything in here continues to depend on my previous code, or can it be removed now?

Revision history for this message
Javier Collado (javier.collado) wrote :

Yes, your branch should be replaced by the changes in this branch.

There are a couple of jobs created based on these changes:
raring-desktop-i386-smoke-min_config
raring-desktop-amd64-smoke-min_config

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configs/oem.conf'
2--- configs/oem.conf 2012-12-07 21:45:35 +0000
3+++ configs/oem.conf 2013-01-04 08:39:19 +0000
4@@ -1,4 +1,4 @@
5 {
6- "sshprivatekey": "~/.ssh/utah",
7- "user": "oem"
8+ "sshprivatekey": "~/.ssh/utah",
9+ "user": "oem"
10 }
11
12=== added symlink 'preseeds/min_config.cfg'
13=== target is u'default.cfg'
14=== added file 'runlists/min_config.run'
15--- runlists/min_config.run 1970-01-01 00:00:00 +0000
16+++ runlists/min_config.run 2013-01-04 08:39:19 +0000
17@@ -0,0 +1,11 @@
18+testsuites:
19+ - name: usit
20+ fetch_method: bzr-export
21+ fetch_location: lp:~javier.collado/ubuntu-test-cases/desktop/testsuites/usit
22+ include_tests:
23+ - read_write
24+ - dbus_machine_id
25+ - total_mem
26+ - total_disk
27+ - disk_not_full
28+ - out_of_memory
29
30=== added file 'scripts/min_config.sh'
31--- scripts/min_config.sh 1970-01-01 00:00:00 +0000
32+++ scripts/min_config.sh 2013-01-04 08:39:19 +0000
33@@ -0,0 +1,12 @@
34+#!/bin/sh
35+# Run default scenario
36+SCRIPT_DIR=$(readlink -e $(dirname $0))
37+SCRIPT=$(basename $0)
38+SCRIPT_NAME=${SCRIPT%.*}
39+BRANCH_DIR=${BRANCH_DIR:-lp:~javier.collado/ubuntu-test-cases/desktop}
40+PRESEED=$BRANCH_DIR/preseeds/$SCRIPT_NAME.cfg
41+RUNLIST=$BRANCH_DIR/runlists/$SCRIPT_NAME.run
42+
43+. $SCRIPT_DIR/base.sh
44+parse_args "$@"
45+echo $CMD --gigabytes 5
46
47=== modified file 'testsuites/usit/dbus_machine_id/test.py'
48--- testsuites/usit/dbus_machine_id/test.py 2012-08-27 16:00:12 +0000
49+++ testsuites/usit/dbus_machine_id/test.py 2013-01-04 08:39:19 +0000
50@@ -18,6 +18,8 @@
51 # along with ubuntu-test-cases. If not, see
52 # <http://www.gnu.org/licenses/>.
53
54+"""Machine ID file exists and it was created recently."""
55+
56 import logging
57 import os.path
58 import unittest
59@@ -32,9 +34,7 @@
60 EXPECTED_AGE = 300
61
62 def test_machine_id(self):
63- """
64- Machine Id is there and log content and age
65- """
66+ """Machine Id is there and log content and age."""
67 logging.info('Checking that machine id file {!r} exists...'
68 .format(self.MACHINE_ID_FILE))
69 self.assertTrue(os.path.exists(self.MACHINE_ID_FILE))
70
71=== modified file 'testsuites/usit/desktop_shortcut_exists/test.py'
72--- testsuites/usit/desktop_shortcut_exists/test.py 2012-08-27 16:00:12 +0000
73+++ testsuites/usit/desktop_shortcut_exists/test.py 2013-01-04 08:39:19 +0000
74@@ -18,6 +18,8 @@
75 # along with ubuntu-test-cases. If not, see
76 # <http://www.gnu.org/licenses/>.
77
78+"""Desktop shortcut exists."""
79+
80 import logging
81 import unittest
82 import os
83@@ -28,9 +30,7 @@
84 DESKTOP_SHORTCUT_PATH = '/home/oem/Desktop/oem-config-prepare-gtk.desktop'
85
86 def test_desktop_shortcut_exists(self):
87- """
88- Test if the desktop shortcut has been created successfully
89- """
90+ """Test if the desktop shortcut has been created successfully."""
91 logging.info('Checking if desktop shortcut ({}) exists'
92 .format(self.DESKTOP_SHORTCUT_PATH))
93 self.assertTrue(os.path.exists(self.DESKTOP_SHORTCUT_PATH),
94
95=== added directory 'testsuites/usit/disk_not_full'
96=== added file 'testsuites/usit/disk_not_full/tc_control'
97--- testsuites/usit/disk_not_full/tc_control 1970-01-01 00:00:00 +0000
98+++ testsuites/usit/disk_not_full/tc_control 2013-01-04 08:39:19 +0000
99@@ -0,0 +1,9 @@
100+description: Check that root partition isn't completely full
101+dependencies: coreutils
102+action: |
103+ 1. Get root partition usage
104+expected_results: |
105+ 1. Current usage is less than 100%
106+type: userland
107+command: ./test.py
108+run_as: utah
109
110=== added file 'testsuites/usit/disk_not_full/test.py'
111--- testsuites/usit/disk_not_full/test.py 1970-01-01 00:00:00 +0000
112+++ testsuites/usit/disk_not_full/test.py 2013-01-04 08:39:19 +0000
113@@ -0,0 +1,58 @@
114+#!/usr/bin/python
115+#
116+# Copyright (C) 2012, Canonical Ltd (http://www.canonical.com/)
117+#
118+# This file is part of ubuntu-test-cases.
119+#
120+# ubuntu-test-cases is free software: you can redistribute it
121+# and/or modify it under the terms of the GNU General Public License
122+# as published by the Free Software Foundation, either version 3 of
123+# the License, or (at your option) any later version.
124+#
125+# ubuntu-test-cases is distributed in the hope that it will
126+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
127+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128+# GNU General Public License for more details.
129+#
130+# You should have received a copy of the GNU General Public License
131+# along with ubuntu-test-cases. If not, see
132+# <http://www.gnu.org/licenses/>.
133+
134+"""Check that root partition isn't completely full.
135+
136+Note: There isn't any threshold defined, any value below 100% usage would be
137+considered as a pass.
138+
139+"""
140+
141+import logging
142+import unittest
143+import subprocess
144+import re
145+
146+
147+class DiskNotFullTest(unittest.TestCase):
148+
149+ def test_disk_not_full(self):
150+ """Check that root partition isn't completely full."""
151+ logging.info('Getting disk usage...')
152+ process = subprocess.Popen('df', stdout=subprocess.PIPE)
153+ stdout, _stderr = process.communicate()
154+ logging.info('Disk usage:\n{}'.format(stdout))
155+ logging.info('Parsing root partition usage...')
156+ root_line = next(line for line in stdout.splitlines()
157+ if line.endswith('/'))
158+ use_str = root_line.split()[4]
159+ match = re.match('(\d+)%', use_str)
160+ self.assertTrue(match,
161+ "Unable to parse root partition use percentage: {}"
162+ .format(use_str))
163+ use = int(match.group(1))
164+ logging.info('Root partition usage is: {}%'.format(use))
165+ self.assertLess(use, 100,
166+ 'Root filesystem must *not* be full after install')
167+
168+if __name__ == '__main__':
169+ logging.basicConfig(level=logging.DEBUG,
170+ format='%(levelname)s: %(message)s')
171+ unittest.main()
172
173=== modified file 'testsuites/usit/empty_startup_app/setup.py'
174--- testsuites/usit/empty_startup_app/setup.py 2012-08-27 16:00:12 +0000
175+++ testsuites/usit/empty_startup_app/setup.py 2013-01-04 08:39:19 +0000
176@@ -18,6 +18,8 @@
177 # along with ubuntu-test-cases. If not, see
178 # <http://www.gnu.org/licenses/>.
179
180+"""Check imagemagic is installed."""
181+
182 import logging
183 import apt
184
185@@ -25,9 +27,7 @@
186
187
188 def main():
189- """
190- Check imagemagic is installed
191- """
192+ """Check imagemagic is installed."""
193 logging.info('Getting apt cache')
194 cache = apt.cache.Cache()
195
196
197=== modified file 'testsuites/usit/empty_startup_app/test.py'
198--- testsuites/usit/empty_startup_app/test.py 2012-08-27 16:00:12 +0000
199+++ testsuites/usit/empty_startup_app/test.py 2013-01-04 08:39:19 +0000
200@@ -18,6 +18,8 @@
201 # along with ubuntu-test-cases. If not, see
202 # <http://www.gnu.org/licenses/>.
203
204+"""Startup application list is empty."""
205+
206 import logging
207 import unittest
208 import subprocess
209@@ -32,9 +34,7 @@
210 IMAGE_SIZE = '400x300'
211
212 def test_empty_startup_app_test(self):
213- """
214- Startup application list is empty
215- """
216+ """Startup application list is empty."""
217 logging.info('Launching {!r}...'.format(self.APP_BINARY))
218 app_process = subprocess.Popen(self.APP_BINARY)
219 time.sleep(1) # Wait for the application window to be displayed
220
221=== modified file 'testsuites/usit/encrypted_home_content/test.py'
222--- testsuites/usit/encrypted_home_content/test.py 2012-08-28 16:14:15 +0000
223+++ testsuites/usit/encrypted_home_content/test.py 2013-01-04 08:39:19 +0000
224@@ -18,6 +18,18 @@
225 # along with ubuntu-test-cases. If not, see
226 # <http://www.gnu.org/licenses/>.
227
228+"""Test encrypted home content.
229+
230+Requires root access to access these links
231+
232+If it is not mounted there are 2 symlinks:
233+Access-Your-Private-Data.desktop ->
234+ /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop
235+README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt
236+
237+"""
238+
239+
240 import logging
241 import unittest
242 import os
243@@ -32,16 +44,7 @@
244 PRIVATE_DIR = os.path.join(HOMEDIR, '.Private')
245
246 def test_encrypted_home_content(self):
247- """
248- Test encrypted home content
249-
250- Requires root access to access these links
251-
252- If it is not mounted there are 2 symlinks:
253- Access-Your-Private-Data.desktop ->
254- /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop
255- README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt
256- """
257+ """Test encrypted home content."""
258 logging.info('Checking that home directory ({!r}) exists'
259 .format(self.HOMEDIR))
260 self.assertTrue(os.path.exists(self.HOMEDIR),
261
262=== modified file 'testsuites/usit/encrypted_home_permissions/test.py'
263--- testsuites/usit/encrypted_home_permissions/test.py 2012-08-28 16:14:15 +0000
264+++ testsuites/usit/encrypted_home_permissions/test.py 2013-01-04 08:39:19 +0000
265@@ -18,6 +18,12 @@
266 # along with ubuntu-test-cases. If not, see
267 # <http://www.gnu.org/licenses/>.
268
269+"""Test permissions of encrypted home directory.
270+
271+Must be owned by ubuntu and mode set to 0500 if not mounted or 0700 if mounted
272+
273+"""
274+
275 import logging
276 import unittest
277 import os
278@@ -29,12 +35,7 @@
279 HOMEDIR = os.path.join('/home', USER)
280
281 def test_encrypted_home_permissions(self):
282- """
283- Test permissions of encrypted home directory
284-
285- Must be owned by ubuntu and mode set to 0500 if not
286- mounted or 0700 if mounted
287- """
288+ """Test permissions of encrypted home directory."""
289 logging.info('Checking that home directory ({!r}) exists'
290 .format(self.HOMEDIR))
291 self.assertTrue(os.path.exists(self.HOMEDIR),
292@@ -49,9 +50,10 @@
293 else:
294 logging.info('Home directory is *not* mounted')
295 expected_permissions = 0700
296- self.assertEqual(permissions, expected_permissions,
297- 'Home directory permissions ({:o}) should be set to {:o}'
298- .format(permissions, expected_permissions))
299+ self.assertEqual(
300+ permissions, expected_permissions,
301+ 'Home directory permissions ({:o}) should be set to {:o}'
302+ .format(permissions, expected_permissions))
303 logging.info('Permissions ({:o}) are correctly set'
304 .format(permissions))
305
306
307=== modified file 'testsuites/usit/no_rofs_machine_id/test.py'
308--- testsuites/usit/no_rofs_machine_id/test.py 2012-08-27 16:00:12 +0000
309+++ testsuites/usit/no_rofs_machine_id/test.py 2013-01-04 08:39:19 +0000
310@@ -18,6 +18,8 @@
311 # along with ubuntu-test-cases. If not, see
312 # <http://www.gnu.org/licenses/>.
313
314+"""Machine ID doesn't exist on the rofs."""
315+
316 import logging
317 import os
318 import unittest
319@@ -28,9 +30,7 @@
320 ROFS_DIR = '/rofs'
321
322 def test_no_rofs_machine_id(self):
323- """
324- Machine ID doesn't exsit on the rofs
325- """
326+ """Machine ID doesn't exist on the rofs."""
327 rofs_machine_id = os.path.join(self.ROFS_DIR, self.MACHINE_ID_FILE)
328 logging.info("Checking that machine id file under {} ({}) "
329 "doesn't exist"
330
331=== modified file 'testsuites/usit/oem_pkg_installed/test.py'
332--- testsuites/usit/oem_pkg_installed/test.py 2012-08-27 16:00:12 +0000
333+++ testsuites/usit/oem_pkg_installed/test.py 2013-01-04 08:39:19 +0000
334@@ -18,6 +18,8 @@
335 # along with ubuntu-test-cases. If not, see
336 # <http://www.gnu.org/licenses/>.
337
338+"""OEM packages are installed."""
339+
340 import logging
341 import unittest
342 import apt
343@@ -27,9 +29,7 @@
344 PACKAGE_NAMES = ('oem-config', 'oem-config-gtk')
345
346 def test_oem_pkg_intalled(self):
347- """
348- OEM packages are installed
349- """
350+ """OEM packages are installed."""
351 logging.info('Getting apt cache...')
352 cache = apt.cache.Cache()
353
354
355=== added directory 'testsuites/usit/out_of_memory'
356=== added file 'testsuites/usit/out_of_memory/tc_control'
357--- testsuites/usit/out_of_memory/tc_control 1970-01-01 00:00:00 +0000
358+++ testsuites/usit/out_of_memory/tc_control 2013-01-04 08:39:19 +0000
359@@ -0,0 +1,11 @@
360+description: Check that kernel ring buffer doesn't contain any out of memory error
361+dependencies: util-linux
362+action: |
363+ 1. Read kernel ring buffer
364+ 2. Look for out of memory errors
365+expected_results: |
366+ 1. The buffer is read successfully
367+ 2. There isn't any out of memory error
368+type: userland
369+command: ./test.py
370+run_as: utah
371
372=== added file 'testsuites/usit/out_of_memory/test.py'
373--- testsuites/usit/out_of_memory/test.py 1970-01-01 00:00:00 +0000
374+++ testsuites/usit/out_of_memory/test.py 2013-01-04 08:39:19 +0000
375@@ -0,0 +1,49 @@
376+#!/usr/bin/python
377+#
378+# Copyright (C) 2012, Canonical Ltd (http://www.canonical.com/)
379+#
380+# This file is part of ubuntu-test-cases.
381+#
382+# ubuntu-test-cases is free software: you can redistribute it
383+# and/or modify it under the terms of the GNU General Public License
384+# as published by the Free Software Foundation, either version 3 of
385+# the License, or (at your option) any later version.
386+#
387+# ubuntu-test-cases is distributed in the hope that it will
388+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
389+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
390+# GNU General Public License for more details.
391+#
392+# You should have received a copy of the GNU General Public License
393+# along with ubuntu-test-cases. If not, see
394+# <http://www.gnu.org/licenses/>.
395+
396+"""Check that kernel ring buffer doesn't contain any out of memory error."""
397+
398+import logging
399+import unittest
400+import subprocess
401+import re
402+
403+
404+class OutOfMemoryTest(unittest.TestCase):
405+ OOM_REGEX = re.compile(r'^.*oom-killer.*$', re.MULTILINE)
406+
407+ def test_out_of_memory(self):
408+ """Check that there isn't any out of memory error."""
409+ logging.info('Reading kernel ring buffer...')
410+ output = subprocess.check_output('dmesg')
411+ logging.info('Looking for out of memory pattern...')
412+ matches = self.OOM_REGEX.findall(output)
413+ logging.info('Pattern found {} times'.format(len(matches)))
414+ for match in matches:
415+ logging.debug(match)
416+ self.assertEqual(len(matches), 0,
417+ 'Out of memory pattern found {} times (see above)'
418+ .format(len(matches)))
419+
420+
421+if __name__ == '__main__':
422+ logging.basicConfig(level=logging.DEBUG,
423+ format='%(levelname)s: %(message)s')
424+ unittest.main()
425
426=== modified file 'testsuites/usit/read_write/test.py'
427--- testsuites/usit/read_write/test.py 2012-08-27 16:00:12 +0000
428+++ testsuites/usit/read_write/test.py 2013-01-04 08:39:19 +0000
429@@ -18,6 +18,8 @@
430 # along with ubuntu-test-cases. If not, see
431 # <http://www.gnu.org/licenses/>.
432
433+"""Temporary file can be written."""
434+
435 import logging
436 import os.path
437 import unittest
438@@ -28,9 +30,7 @@
439 CONTENTS = 'a'
440
441 def test_read_write(self):
442- """
443- Temporary file can be written
444- """
445+ """Temporary file can be written."""
446 logging.info('Opening file {!r} for writing...'.format(self.FILENAME))
447 f = open(self.FILENAME, 'w')
448
449
450=== added directory 'testsuites/usit/total_disk'
451=== added file 'testsuites/usit/total_disk/tc_control'
452--- testsuites/usit/total_disk/tc_control 1970-01-01 00:00:00 +0000
453+++ testsuites/usit/total_disk/tc_control 2013-01-04 08:39:19 +0000
454@@ -0,0 +1,9 @@
455+description: Check that disk size is the expected one
456+dependencies: util-linux
457+action: |
458+ 1. Get disk size using `sfdisk`command
459+expected_results: |
460+ 1. Disk size is the expected value
461+type: userland
462+command: ./test.py
463+run_as: root
464
465=== added file 'testsuites/usit/total_disk/test.py'
466--- testsuites/usit/total_disk/test.py 1970-01-01 00:00:00 +0000
467+++ testsuites/usit/total_disk/test.py 2013-01-04 08:39:19 +0000
468@@ -0,0 +1,54 @@
469+#!/usr/bin/python
470+#
471+# Copyright (C) 2012, Canonical Ltd (http://www.canonical.com/)
472+#
473+# This file is part of ubuntu-test-cases.
474+#
475+# ubuntu-test-cases is free software: you can redistribute it
476+# and/or modify it under the terms of the GNU General Public License
477+# as published by the Free Software Foundation, either version 3 of
478+# the License, or (at your option) any later version.
479+#
480+# ubuntu-test-cases is distributed in the hope that it will
481+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
482+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
483+# GNU General Public License for more details.
484+#
485+# You should have received a copy of the GNU General Public License
486+# along with ubuntu-test-cases. If not, see
487+# <http://www.gnu.org/licenses/>.
488+
489+"""Check that disk size is the expected one.
490+
491+Note: This test case assumes expected size (5GB) matches the physical size or
492+the size assigned to the virtual machine being tested for the expected device.
493+
494+"""
495+
496+import logging
497+import unittest
498+import subprocess
499+
500+
501+class TotalDiskTest(unittest.TestCase):
502+ DEVICE = '/dev/vda'
503+ EXPECTED_SIZE = 5242880
504+
505+ def test_total_disk(self):
506+ """Check that disk size is the expected one."""
507+ logging.info('Getting disk size for {}'.format(self.DEVICE))
508+ command = ['sfdisk', '--show-size', self.DEVICE]
509+ size = int(subprocess.check_output(command))
510+ logging.info('Disk size is: {}'.format(size))
511+ self.assertEqual(size, self.EXPECTED_SIZE,
512+ 'Expected disk size ({}), '
513+ 'does *not* match expected value: {}'
514+ .format(size, self.EXPECTED_SIZE))
515+
516+ logging.info('Disk size matches the expected value: {}'
517+ .format(self.EXPECTED_SIZE))
518+
519+if __name__ == '__main__':
520+ logging.basicConfig(level=logging.DEBUG,
521+ format='%(levelname)s: %(message)s')
522+ unittest.main()
523
524=== added directory 'testsuites/usit/total_mem'
525=== added file 'testsuites/usit/total_mem/tc_control'
526--- testsuites/usit/total_mem/tc_control 1970-01-01 00:00:00 +0000
527+++ testsuites/usit/total_mem/tc_control 2013-01-04 08:39:19 +0000
528@@ -0,0 +1,9 @@
529+description: Check that total memory is in the expected range
530+dependencies: procps
531+action: |
532+ 1. Get total memory using `free` command
533+expected_results: |
534+ 1. Total memory is in the expected range
535+type: userland
536+command: ./test.py
537+run_as: utah
538
539=== added file 'testsuites/usit/total_mem/test.py'
540--- testsuites/usit/total_mem/test.py 1970-01-01 00:00:00 +0000
541+++ testsuites/usit/total_mem/test.py 2013-01-04 08:39:19 +0000
542@@ -0,0 +1,62 @@
543+#!/usr/bin/python
544+#
545+# Copyright (C) 2012, Canonical Ltd (http://www.canonical.com/)
546+#
547+# This file is part of ubuntu-test-cases.
548+#
549+# ubuntu-test-cases is free software: you can redistribute it
550+# and/or modify it under the terms of the GNU General Public License
551+# as published by the Free Software Foundation, either version 3 of
552+# the License, or (at your option) any later version.
553+#
554+# ubuntu-test-cases is distributed in the hope that it will
555+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
556+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
557+# GNU General Public License for more details.
558+#
559+# You should have received a copy of the GNU General Public License
560+# along with ubuntu-test-cases. If not, see
561+# <http://www.gnu.org/licenses/>.
562+
563+"""Check that total memory is in the expected range.
564+
565+Note: This test case assumes the upper bound matches the physical memory or the
566+memory assigned to the virtual machine being tested.
567+
568+"""
569+
570+import logging
571+import unittest
572+import subprocess
573+
574+
575+class TotalMemTest(unittest.TestCase):
576+ UPPER_BOUND = 512
577+ LOWER_BOUND = UPPER_BOUND - 40
578+
579+ def test_total_mem(self):
580+ """Check that total memory is in the expected range."""
581+ logging.info('Getting total memory...')
582+ stdout = subprocess.check_output(['free', '-m'])
583+ lines = stdout.splitlines()
584+ mem_line = lines[1].split()
585+ self.assertEqual(mem_line[0], 'Mem:',
586+ 'Failed to parse memory line: {}'.format(mem_line))
587+
588+ total_mem = int(mem_line[1])
589+ logging.info('Total memory is: {}'.format(total_mem))
590+
591+ self.assertTrue(
592+ self.LOWER_BOUND < total_mem < self.UPPER_BOUND,
593+ "Total memory ({} MB) is *not* in the expected range: "
594+ "({} MB - {} MB)"
595+ .format(total_mem, self.LOWER_BOUND, self.UPPER_BOUND))
596+
597+ logging.info("Total memory ({} MB) is in the expected range: "
598+ "({} MB - {} MB)"
599+ .format(total_mem, self.LOWER_BOUND, self.UPPER_BOUND))
600+
601+if __name__ == '__main__':
602+ logging.basicConfig(level=logging.DEBUG,
603+ format='%(levelname)s: %(message)s')
604+ unittest.main()
605
606=== modified file 'testsuites/usit/tslist.run'
607--- testsuites/usit/tslist.run 2012-08-23 14:55:59 +0000
608+++ testsuites/usit/tslist.run 2013-01-04 08:39:19 +0000
609@@ -7,3 +7,7 @@
610 - test: desktop_shortcut_exists
611 - test: oem_pkg_installed
612 - test: ubiquity
613+- test: total_mem
614+- test: total_disk
615+- test: disk_not_full
616+- test: out_of_memory
617
618=== modified file 'testsuites/usit/ubiquity/test.py'
619--- testsuites/usit/ubiquity/test.py 2012-08-27 16:00:12 +0000
620+++ testsuites/usit/ubiquity/test.py 2013-01-04 08:39:19 +0000
621@@ -18,6 +18,8 @@
622 # along with ubuntu-test-cases. If not, see
623 # <http://www.gnu.org/licenses/>.
624
625+"""Ubiquity installation works correctly."""
626+
627 import logging
628 import unittest
629 import ldtp
630@@ -40,9 +42,7 @@
631 TXT_PASSWORD2 = 'txtverifiedpassword' # Password confirmation
632
633 def _waittillenabled(self, ui, component_name, timeout=300):
634- """
635- Wait until widget is enabled
636- """
637+ """Wait until widget is enabled."""
638 ldtp.wait(15) # UI is slow to react sometimes
639 component = ui.getchild(component_name)
640 while not component.stateenabled():
641@@ -55,9 +55,7 @@
642 return True
643
644 def test_ubiquity(self):
645- """
646- Ubiquity installation works correctly
647- """
648+ """Ubiquity installation works correctly."""
649 # Content to fill the forms with
650 data = {
651 'location': 'London',

Subscribers

People subscribed via source and target branches

to all changes: