Merge lp:~seb128/ubuntu-test-cases/desktop-minimal-install into lp:ubuntu-test-cases/desktop

Proposed by Sebastien Bacher
Status: Merged
Merged at revision: 70
Proposed branch: lp:~seb128/ubuntu-test-cases/desktop-minimal-install
Merge into: lp:ubuntu-test-cases/desktop
Diff against target: 143 lines (+115/-0)
5 files modified
preseeds/default_minimal.yaml (+20/-0)
runlists/default_minimal.run (+8/-0)
testsuites/usit/minimal_install/tc_control (+12/-0)
testsuites/usit/minimal_install/test.py (+74/-0)
testsuites/usit/tslist.run (+1/-0)
To merge this branch: bzr merge lp:~seb128/ubuntu-test-cases/desktop-minimal-install
Reviewer Review Type Date Requested Status
Paride Legovini Approve
Review via email: mp+441257@code.launchpad.net

Description of the change

The code is copied from the existing oem_pkg_installed sightly tweaked

To post a comment you must log in.
70. By Sebastien Bacher

New desktop minimal install testcase

Ensure that the installed system correctly exclude packages

Revision history for this message
Paride Legovini (paride) wrote :

I find some messages a bit confusing ("Not all packages have been found and are not installed"), but I see that's what we had already. The diff LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'preseeds/default_minimal.yaml'
2--- preseeds/default_minimal.yaml 1970-01-01 00:00:00 +0000
3+++ preseeds/default_minimal.yaml 2023-04-17 21:53:56 +0000
4@@ -0,0 +1,20 @@
5+identity:
6+ hostname: utah-hostname
7+ password: "$y$j9T$nSo5WE2iVRpZQTf1zdNMA1$aFwGMR.afMfV2ouu9tTfP5.r81iCVcBjIa2chzWIYc7"
8+ username: utah
9+packages:
10+ - openssh-server
11+ - python3-yaml
12+ - bzr
13+ - git
14+ - gdebi-core
15+ - python3-psutil
16+early-commands:
17+ - chmod 666 /dev/ttyS0
18+ - echo "AutoLoginUser=utah" > /tmp/ubuntu_desktop_installer.conf
19+late-commands:
20+ - sh /utah-latecommand
21+ - curtin in-target -- sh /etc/utah/autorun/01_utah-setup
22+source:
23+ id: ubuntu-desktop-minimal
24+version: 1
25
26=== added file 'runlists/default_minimal.run'
27--- runlists/default_minimal.run 1970-01-01 00:00:00 +0000
28+++ runlists/default_minimal.run 2023-04-17 21:53:56 +0000
29@@ -0,0 +1,8 @@
30+testsuites:
31+ - name: usit
32+ fetch_method: bzr-export
33+ fetch_location: https://code.launchpad.net/ubuntu-test-cases/desktop/testsuites/usit
34+ include_tests:
35+ - read_write
36+ - dbus_machine_id
37+ - minimal_install
38
39=== added directory 'testsuites/usit/minimal_install'
40=== added file 'testsuites/usit/minimal_install/tc_control'
41--- testsuites/usit/minimal_install/tc_control 1970-01-01 00:00:00 +0000
42+++ testsuites/usit/minimal_install/tc_control 2023-04-17 21:53:56 +0000
43@@ -0,0 +1,12 @@
44+description: the minimal install should have packages not installed
45+dependencies: none
46+action: |
47+ 1. Look for packages in apt cache
48+ 2. Get installation status for package
49+ 3. Iterate over the list of packages that shouldn't be installed
50+expected_results: |
51+ 1. Package is found in apt cache
52+ 2. Package is not installed
53+type: userland
54+command: ./test.py
55+run_as: utah
56
57=== added file 'testsuites/usit/minimal_install/test.py'
58--- testsuites/usit/minimal_install/test.py 1970-01-01 00:00:00 +0000
59+++ testsuites/usit/minimal_install/test.py 2023-04-17 21:53:56 +0000
60@@ -0,0 +1,74 @@
61+#!/usr/bin/python3
62+#
63+# Copyright (C) 2023, Canonical Ltd (http://www.canonical.com/)
64+#
65+# This file is part of ubuntu-test-cases.
66+#
67+# ubuntu-test-cases is free software: you can redistribute it
68+# and/or modify it under the terms of the GNU General Public License
69+# as published by the Free Software Foundation, either version 3 of
70+# the License, or (at your option) any later version.
71+#
72+# ubuntu-test-cases is distributed in the hope that it will
73+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
74+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
75+# GNU General Public License for more details.
76+#
77+# You should have received a copy of the GNU General Public License
78+# along with ubuntu-test-cases. If not, see
79+# <http://www.gnu.org/licenses/>.
80+
81+"""Minimal install packages are not installed."""
82+
83+import logging
84+import unittest
85+import apt
86+
87+
88+class MinimalInstall(unittest.TestCase):
89+ PACKAGE_NAMES = (
90+ "thunderbird",
91+ "transmission-gtk",
92+ "rhythmbox",
93+ "gnome-sudoku",
94+ "totem",
95+ "shotwell",
96+ "libreoffice-writer",
97+ )
98+
99+ def test_minimal_install(self):
100+ """minimal install packages are not installed."""
101+ logging.info('Getting apt cache...')
102+ cache = apt.cache.Cache()
103+
104+ def check_installed(package_name):
105+ """
106+ Check a single package
107+ """
108+ logging.info('Checking if {!r} is in cache...'
109+ .format(package_name))
110+ if package_name not in cache:
111+ logging.error('{!r} not found in the cache'
112+ .format(package_name))
113+ return False
114+
115+ logging.info('Checking if {!r} is not installed...'
116+ .format(package_name))
117+ package = cache[package_name]
118+ if package.is_installed:
119+ logging.error('{!r} is installed'
120+ .format(package_name))
121+ return False
122+ return True
123+
124+ installed = [check_installed(package_name)
125+ for package_name in self.PACKAGE_NAMES]
126+ if not all(installed):
127+ raise AssertionError('Not all packages have been found '
128+ 'and are not installed')
129+
130+
131+if __name__ == '__main__':
132+ logging.basicConfig(level=logging.DEBUG,
133+ format='%(levelname)s: %(message)s')
134+ unittest.main()
135
136=== modified file 'testsuites/usit/tslist.run'
137--- testsuites/usit/tslist.run 2023-04-17 15:59:09 +0000
138+++ testsuites/usit/tslist.run 2023-04-17 21:53:56 +0000
139@@ -13,3 +13,4 @@
140 - test: out_of_memory
141 - test: archive_location
142 - test: system_localized
143+- test: minimal_install

Subscribers

People subscribed via source and target branches