Merge lp:~heber013/ubuntu-system-tests/fixing-vm-provisioning into lp:ubuntu-system-tests
- fixing-vm-provisioning
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~heber013/ubuntu-system-tests/fixing-vm-provisioning |
Merge into: | lp:ubuntu-system-tests |
Diff against target: | 452 lines (+90/-118) 8 files modified debian/tests/dependencies.json (+0/-39) ubuntu_system_tests/host/debian.py (+1/-3) ubuntu_system_tests/host/qemu-scripts/qemu-setup.py (+1/-1) ubuntu_system_tests/host/qemu.py (+18/-19) ubuntu_system_tests/host/target_setup.py (+48/-20) ubuntu_system_tests/selftests/_test_setup_runner.py (+9/-3) ubuntu_system_tests/selftests/test_debian.py (+0/-8) ubuntu_system_tests/selftests/test_qemu.py (+13/-25) |
To merge this branch: | bzr merge lp:~heber013/ubuntu-system-tests/fixing-vm-provisioning |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
platform-qa-bot | continuous-integration | Needs Fixing | |
Jean-Baptiste Lallement | Pending | ||
Review via email: |
Commit message
Fixing VM provisioning to work with multipart initrd
Description of the change
Fixing VM provisioning to work with multipart initrd

platform-qa-bot (platform-qa-bot) wrote : | # |
- 583. By Heber Parrucci
-
Fixing broken self tests

platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:583
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 584. By Heber Parrucci
-
Fixing flake8 warning

platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:584
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 585. By Heber Parrucci
-
Fixing qemu-setup

platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:585
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 586. By Heber Parrucci
-
update setup actions

platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:586
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 587. By Heber Parrucci
-
Install checkbox snap as part of target setup

platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:587
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 588. By Heber Parrucci
-
Install snaps as part of target setup

platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:588
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 589. By Heber Parrucci
-
Install expect package as part of target setup

platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:589
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 590. By Heber Parrucci
-
pass list when intalling packages as part of the setup

platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:590
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 591. By Heber Parrucci
-
removing dependencies

platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:591
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 592. By Heber Parrucci
-
fixing missing dependencies

platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:592
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 593. By Heber Parrucci
-
removing no longer valid self tests

platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:593
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 594. By Heber Parrucci
-
adding autologin for sd display manager

platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:594
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 595. By Heber Parrucci
-
fixing autologin for sd display manager

platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:595
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Unmerged revisions
- 595. By Heber Parrucci
-
fixing autologin for sd display manager
- 594. By Heber Parrucci
-
adding autologin for sd display manager
- 593. By Heber Parrucci
-
removing no longer valid self tests
- 592. By Heber Parrucci
-
fixing missing dependencies
- 591. By Heber Parrucci
-
removing dependencies
- 590. By Heber Parrucci
-
pass list when intalling packages as part of the setup
- 589. By Heber Parrucci
-
Install expect package as part of target setup
- 588. By Heber Parrucci
-
Install snaps as part of target setup
- 587. By Heber Parrucci
-
Install checkbox snap as part of target setup
- 586. By Heber Parrucci
-
update setup actions
Preview Diff
1 | === modified file 'debian/tests/dependencies.json' |
2 | --- debian/tests/dependencies.json 2018-01-02 13:42:38 +0000 |
3 | +++ debian/tests/dependencies.json 2018-10-26 04:46:44 +0000 |
4 | @@ -1,52 +1,13 @@ |
5 | { |
6 | "dependencies": [ |
7 | - { "id": "python3-autopilot", "version": "1.6.0", "tmpinstall": "false" }, |
8 | - { "id": "python3-dbus", "version": "", "tmpinstall": "false" }, |
9 | - { "id": "python3-debian", "version": "", "tmpinstall": "false" }, |
10 | - { "id": "python3-gi", "version": "", "tmpinstall": "false" }, |
11 | - { "id": "python3-paramiko", "version": "", "tmpinstall": "false" }, |
12 | - { "id": "python3-pexpect", "version": "", "tmpinstall": "false" }, |
13 | - { "id": "python3-requests", "version": "", "tmpinstall": "false" }, |
14 | - { "id": "python3-requests-unixsocket", "version": "", "tmpinstall": "false" }, |
15 | - { "id": "python3-retrying", "version": "", "tmpinstall": "false" }, |
16 | - { "id": "python3-testtools", "version": "", "tmpinstall": "false" }, |
17 | - { "id": "python3-warlock", "version": "", "tmpinstall": "false" }, |
18 | - { "id": "python3-xlib", "version": "", "tmpinstall": "false" }, |
19 | - { "id": "python3-yaml", "version": "", "tmpinstall": "false" }, |
20 | - { "id": "subunit", "version": "", "tmpinstall": "false" }, |
21 | - { "id": "ubuntu-app-launch-tools", "version": "", "tmpinstall": "false" }, |
22 | - { "id": "ubuntu-system-tests-helpers", "version": "", "tmpinstall": "false", "condition": "installed" }, |
23 | - { "id": "ubuntu-system-tests-suite", "version": "", "tmpinstall": "false", "condition": "installed" }, |
24 | - { "id": "usbutils", "version": "", "tmpinstall": "false" } |
25 | ], |
26 | "dependencies-common": [ |
27 | - "python3-pexpect", |
28 | - "python3-retrying" |
29 | ], |
30 | "tests": [ |
31 | { |
32 | "ids": [ |
33 | - "ubuntu_system_tests" |
34 | ], |
35 | "depends": [ |
36 | - "python3-autopilot", |
37 | - "python3-dbus", |
38 | - "python3-debian", |
39 | - "python3-gi", |
40 | - "python3-paramiko", |
41 | - "python3-pexpect", |
42 | - "python3-requests", |
43 | - "python3-requests-unixsocket", |
44 | - "python3-retrying", |
45 | - "python3-testtools", |
46 | - "python3-warlock", |
47 | - "python3-xlib", |
48 | - "python3-yaml", |
49 | - "subunit", |
50 | - "ubuntu-app-launch-tools", |
51 | - "ubuntu-system-tests-helpers", |
52 | - "ubuntu-system-tests-suite", |
53 | - "usbutils" |
54 | ] |
55 | } |
56 | ] |
57 | |
58 | === modified file 'ubuntu_system_tests/host/debian.py' |
59 | --- ubuntu_system_tests/host/debian.py 2017-01-09 09:27:28 +0000 |
60 | +++ ubuntu_system_tests/host/debian.py 2018-10-26 04:46:44 +0000 |
61 | @@ -100,9 +100,7 @@ |
62 | # Either way, the dependencies should be added to list. |
63 | dependencies.extend(depends_map[id]) |
64 | if not dependencies: |
65 | - raise RuntimeError( |
66 | - 'No dependencies defind for test: {t}. Check ' |
67 | - 'debian/tests/dependencies.json.'.format(t=test_id)) |
68 | + pass |
69 | return dependencies |
70 | |
71 | |
72 | |
73 | === modified file 'ubuntu_system_tests/host/qemu-scripts/qemu-setup.py' |
74 | --- ubuntu_system_tests/host/qemu-scripts/qemu-setup.py 2017-06-29 12:17:07 +0000 |
75 | +++ ubuntu_system_tests/host/qemu-scripts/qemu-setup.py 2018-10-26 04:46:44 +0000 |
76 | @@ -152,7 +152,7 @@ |
77 | ) |
78 | changed = True |
79 | |
80 | - zero_timeout = subprocess.check_output( |
81 | + zero_timeout = subprocess.call( |
82 | ['grep', '-q', 'GRUB_HIDDEN_TIMEOUT=0', '/etc/default/grub'] |
83 | ) == 0 |
84 | |
85 | |
86 | === modified file 'ubuntu_system_tests/host/qemu.py' |
87 | --- ubuntu_system_tests/host/qemu.py 2017-12-21 18:54:34 +0000 |
88 | +++ ubuntu_system_tests/host/qemu.py 2018-10-26 04:46:44 +0000 |
89 | @@ -20,6 +20,7 @@ |
90 | # |
91 | |
92 | import os |
93 | +import pipes |
94 | import shlex |
95 | import shutil |
96 | import stat |
97 | @@ -30,7 +31,6 @@ |
98 | KERNEL_FILTER = 'casper/vmlinuz*' |
99 | # initial ram disk |
100 | CASPER_INITRD = 'casper/initrd' |
101 | -CASPER_INITRDLZ = 'casper/initrd.lz' |
102 | |
103 | KERNEL_OPTS = ( |
104 | 'boot=casper DEBCONF_DEBUG=developer -- debconf/priority=critical ' |
105 | @@ -129,7 +129,7 @@ |
106 | cmd += options.format(workdir=work_dir, serial_port=serial_port) |
107 | # Add install options if specified |
108 | if iso_path and kernel and kernel_opts: |
109 | - initrd_path = os.path.join(work_dir, CASPER_INITRD) |
110 | + initrd_path = os.path.join(work_dir, 'initrd.d', 'initrd') |
111 | kernel_path = os.path.join(work_dir, kernel) |
112 | cmd += QEMU_INSTALL_OPTS.format( |
113 | iso=iso_path, initrd=initrd_path, kernel=kernel_path, |
114 | @@ -232,7 +232,7 @@ |
115 | def extract_kernel(iso_path, kernel_path, dst_path): |
116 | """Extract kernel from iso to specified path.""" |
117 | subprocess.check_call( |
118 | - ['bsdtar', 'xf', iso_path, '-C', dst_path, CASPER_INITRDLZ, |
119 | + ['bsdtar', 'xf', iso_path, '-C', dst_path, CASPER_INITRD, |
120 | kernel_path]) |
121 | |
122 | |
123 | @@ -313,29 +313,28 @@ |
124 | :return: Path of initrd file with installer scripts added. |
125 | """ |
126 | initrd_path = os.path.join(working_dir, CASPER_INITRD) |
127 | - initrdlz_path = os.path.join(working_dir, CASPER_INITRDLZ) |
128 | - initrd_work_dir = os.path.join(working_dir, 'initrd') |
129 | + initrd_work_dir = os.path.join(working_dir, 'initrd.d') |
130 | + my_initrd_path = os.path.join(initrd_work_dir, 'initrd') |
131 | # create dir to extract initrd, change to it and then extract files |
132 | os.mkdir(initrd_work_dir) |
133 | os.chdir(initrd_work_dir) |
134 | - ps = subprocess.Popen(['xzcat', initrdlz_path], stdout=subprocess.PIPE) |
135 | - subprocess.check_call(['cpio', '--quiet', '-id'], stdin=ps.stdout) |
136 | - ps.wait() |
137 | + subprocess.check_call(['unmkinitramfs', initrd_path, os.getcwd()]) |
138 | # copy the qemu scripts into initrd |
139 | - copy_qemu_scripts_to_path(initrd_work_dir) |
140 | - casper_prov = os.path.join(initrd_work_dir, 'qemu-casper-provision') |
141 | + copy_qemu_scripts_to_path(os.path.join(initrd_work_dir, 'main')) |
142 | + casper_prov = os.path.join(initrd_work_dir, 'main', 'qemu-casper-provision') |
143 | add_script_to_casper_setup(initrd_work_dir, casper_prov) |
144 | # create the preseed file |
145 | - preseed_path = os.path.join(initrd_work_dir, PRESEED) |
146 | + preseed_path = os.path.join(initrd_work_dir, 'main', PRESEED) |
147 | create_preseed(preseed_path, username, password, display_name) |
148 | # Copy all files back to the archive |
149 | - with open(initrd_path, 'w') as initrd: |
150 | - ps = subprocess.Popen(['find', '.'], stdout=subprocess.PIPE) |
151 | - subprocess.check_call( |
152 | - ['cpio', '--quiet', '-o', '-H', 'newc'], |
153 | - stdin=ps.stdout, stdout=initrd) |
154 | - ps.wait() |
155 | - return initrd_path |
156 | + os.chdir(os.path.join(initrd_work_dir, 'main')) |
157 | + pipe = pipes.Template() |
158 | + pipe.prepend('find .', '.-') |
159 | + pipe.append('cpio --quiet -o -H newc', '--') |
160 | + initrd = os.path.join(initrd_work_dir, 'initrd') |
161 | + if pipe.copy('/dev/null', initrd) != 0: |
162 | + raise Exception('Failed to repack initrd') |
163 | + return my_initrd_path |
164 | |
165 | |
166 | def add_script_to_casper_setup(initrd_path, script_path): |
167 | @@ -343,7 +342,7 @@ |
168 | :param initrd_path: Path of initial ram disk to add the scripts. |
169 | :param script_path: Path of script file to add. |
170 | """ |
171 | - casper_dir = os.path.join(initrd_path, 'scripts', 'casper-bottom') |
172 | + casper_dir = os.path.join(initrd_path, 'main', 'scripts', 'casper-bottom') |
173 | script_name = os.path.basename(script_path) |
174 | script_dst = os.path.join(casper_dir, script_name) |
175 | shutil.copy2(script_path, script_dst) |
176 | |
177 | === modified file 'ubuntu_system_tests/host/target_setup.py' |
178 | --- ubuntu_system_tests/host/target_setup.py 2018-01-16 17:19:00 +0000 |
179 | +++ ubuntu_system_tests/host/target_setup.py 2018-10-26 04:46:44 +0000 |
180 | @@ -59,10 +59,13 @@ |
181 | |
182 | GDM_DISPLAY_MANAGER = 'gdm3' |
183 | LIGHTDM_DISPLAY_MANAGER = 'lightdm' |
184 | +SD_DISPLAY_MANAGER = 'sddm' |
185 | + |
186 | +SNAP_NAME = 'checkbox-desktop-snaps' |
187 | +SNAPS_TO_TEST = ['vlc', 'spotify', 'kcalc'] |
188 | |
189 | |
190 | class SetupRunner: |
191 | - |
192 | """Class to run setup actions directly on the target device.""" |
193 | |
194 | def __init__(self, config, snapd_https_proxy=None, snapd_http_proxy=None): |
195 | @@ -85,18 +88,11 @@ |
196 | self.ext_logs_dir = None |
197 | |
198 | def run_setup_commands(self, username=None): |
199 | - self.setup_network() |
200 | self.wait_for_network() |
201 | - self.add_ppas() |
202 | - self.update_apt() |
203 | - self.dist_upgrade() |
204 | - self.install_test_packages() |
205 | - self.install_apt_cacher() |
206 | self.set_auto_login(username) |
207 | - with open("/etc/environment", "r") as environment: |
208 | - if "QT_LOAD_TESTABILITY" not in environment.read(): |
209 | - self.enable_testability() |
210 | - self.setup_snapd_proxy() |
211 | + self.install_snaps([SNAP_NAME]) |
212 | + self.install_snaps(SNAPS_TO_TEST, channel='stable') |
213 | + self.install_packages(['expect']) |
214 | |
215 | def get_release(self): |
216 | """Return float release number of running system.""" |
217 | @@ -151,7 +147,7 @@ |
218 | |
219 | """ |
220 | if (self.config.get('create_network') and |
221 | - not self.config.get('network_ready')): |
222 | + not self.config.get('network_ready')): |
223 | subprocess.check_call( |
224 | ['nmcli', 'device', 'wifi', |
225 | 'connect', self.config['wifi_ssid'], |
226 | @@ -212,19 +208,27 @@ |
227 | ['apt-get', '-y', '--no-install-recommends', 'install'] + |
228 | packages) |
229 | |
230 | - def install_snaps(self, snaps): # NOQA |
231 | + def install_snaps(self, snaps, channel=None): # NOQA |
232 | if snaps: |
233 | self.mount_fs_rw() |
234 | for snap in snaps: |
235 | installed = False |
236 | cmd = 'refresh' if self.is_snap_installed(snap) else 'install' |
237 | - for channel in ['beta', 'edge']: |
238 | + if channel: |
239 | if self.is_snap_published_for_channel(snap, channel): |
240 | - channel_arg = '--{}'.format(channel) |
241 | - subprocess.check_call( |
242 | - ['snap', cmd, '--devmode', channel_arg, snap]) |
243 | - installed = True |
244 | - break |
245 | + if self.is_snap_published_for_channel(snap, channel): |
246 | + channel_arg = '--{}'.format(channel) |
247 | + subprocess.check_call( |
248 | + ['snap', cmd, channel_arg, snap]) |
249 | + installed = True |
250 | + else: |
251 | + for _channel in ['beta', 'edge']: |
252 | + if self.is_snap_published_for_channel(snap, _channel): |
253 | + channel_arg = '--{}'.format(_channel) |
254 | + subprocess.check_call( |
255 | + ['snap', cmd, '--devmode', channel_arg, snap]) |
256 | + installed = True |
257 | + break |
258 | if not installed: |
259 | raise RuntimeError( |
260 | 'Could not find channel for snap {}'.format(snap)) |
261 | @@ -284,6 +288,28 @@ |
262 | self._set_autologin_gdm(username) |
263 | elif default_display_manager == LIGHTDM_DISPLAY_MANAGER: |
264 | self._set_autologin_lightdm(username) |
265 | + elif default_display_manager == SD_DISPLAY_MANAGER: |
266 | + self._set_autologin_sd(username) |
267 | + |
268 | + def _set_autologin_sd(self, username): # NOQA |
269 | + if os.path.isfile('/etc/sddm.conf'): |
270 | + with open('/etc/sddm.conf') as fin, open( |
271 | + '/tmp/sddm.conf', 'w') as fout: |
272 | + for line in fin: |
273 | + if 'User' not in line: |
274 | + fout.write(line) |
275 | + if 'Autologin' in line: |
276 | + next_line = next(fin) |
277 | + fout.write('User=%s\n' % username) |
278 | + fout.write('Session=plasma.desktop\n') |
279 | + if 'User' not in next_line: |
280 | + fout.write(next_line) |
281 | + shutil.move('/tmp/sddm.conf', '/etc/sddm.conf') |
282 | + else: |
283 | + with open('/etc/sddm.conf', 'x') as _f: |
284 | + _f.write('[Autologin]\n') |
285 | + _f.write('User=%s\n' % username) |
286 | + _f.write('Session=plasma.desktop\n') |
287 | |
288 | def _set_autologin_gdm(self, username): # NOQA |
289 | with open('/etc/gdm3/custom.conf') as fin, open('/tmp/custom_new.conf', 'w') as fout: |
290 | @@ -345,8 +371,10 @@ |
291 | def _get_default_display_manager(self): |
292 | if self.is_process_running(GDM_DISPLAY_MANAGER): |
293 | return GDM_DISPLAY_MANAGER |
294 | - else: |
295 | + elif self.is_process_running(LIGHTDM_DISPLAY_MANAGER): |
296 | return LIGHTDM_DISPLAY_MANAGER |
297 | + elif self.is_process_running(SD_DISPLAY_MANAGER): |
298 | + return SD_DISPLAY_MANAGER |
299 | |
300 | def is_process_running(self, pname): |
301 | try: |
302 | |
303 | === modified file 'ubuntu_system_tests/selftests/_test_setup_runner.py' |
304 | --- ubuntu_system_tests/selftests/_test_setup_runner.py 2017-08-17 19:25:43 +0000 |
305 | +++ ubuntu_system_tests/selftests/_test_setup_runner.py 2018-10-26 04:46:44 +0000 |
306 | @@ -356,7 +356,9 @@ |
307 | '"mount_fs_rw": false, ' |
308 | '"dist_upgrade_hold_list": []}') |
309 | with patch('builtins.open', mock_open(read_data=json)) as o: |
310 | - target_setup_main('/tmp/test_config.json', 'ubuntu') |
311 | + target_setup_main('/tmp/test_config.json', |
312 | + 'snapd_https_proxy', |
313 | + 'snapd_http_proxy', 'ubuntu') |
314 | o.assert_called_once_with('/tmp/test_config.json', 'r') |
315 | mock_run_setup.assert_called_once_with('ubuntu') |
316 | mock_mount_fs_ro.assert_called_once_with() |
317 | @@ -370,7 +372,8 @@ |
318 | '"dist_upgrade_hold_list": []') |
319 | with patch('builtins.open', mock_open(read_data=json)): |
320 | with self.assertRaises(JSONDecodeError): |
321 | - target_setup_main(['/tmp/test_config.json'], 'ubuntu') |
322 | + target_setup_main(['/tmp/test_config.json'], 'snapd_https_proxy', |
323 | + 'snapd_http_proxy', 'ubuntu') |
324 | |
325 | def test_mount_ro_called_after_failure(self, mock_mount_fs_ro, |
326 | mock_run_setup): |
327 | @@ -382,7 +385,10 @@ |
328 | mock_run_setup.side_effect = ConnectionError |
329 | with patch('builtins.open', mock_open(read_data=json)) as o: |
330 | with self.assertRaises(ConnectionError): |
331 | - target_setup_main('/tmp/test_config.json', 'ubuntu') |
332 | + target_setup_main('/tmp/test_config.json', |
333 | + 'snapd_https_proxy', |
334 | + 'snapd_http_proxy', |
335 | + 'ubuntu') |
336 | o.assert_called_once_with('/tmp/test_config.json', 'r') |
337 | mock_run_setup.assert_called_once_with('ubuntu') |
338 | mock_mount_fs_ro.assert_called_once_with() |
339 | |
340 | === modified file 'ubuntu_system_tests/selftests/test_debian.py' |
341 | --- ubuntu_system_tests/selftests/test_debian.py 2016-12-06 12:08:38 +0000 |
342 | +++ ubuntu_system_tests/selftests/test_debian.py 2018-10-26 04:46:44 +0000 |
343 | @@ -158,14 +158,6 @@ |
344 | depends = debian.get_dependencies(['app1.tests']) |
345 | self.assertCountEqual(depends, ['dep1']) |
346 | |
347 | - def test_invalid_single_test_id_raises_exception(self, mock_read_depends): |
348 | - with self.assertRaises(RuntimeError): |
349 | - debian.get_dependencies(['app2.tests']) |
350 | - |
351 | - def test_invalid_mutli_test_id_raises_exception(self, mock_read_depends): |
352 | - with self.assertRaises(RuntimeError): |
353 | - debian.get_dependencies(['app1.tests', 'app2.tests']) |
354 | - |
355 | |
356 | class ReadDependenciesDataTestCase(ConfigBaseTestCase): |
357 | |
358 | |
359 | === modified file 'ubuntu_system_tests/selftests/test_qemu.py' |
360 | --- ubuntu_system_tests/selftests/test_qemu.py 2017-02-20 19:49:08 +0000 |
361 | +++ ubuntu_system_tests/selftests/test_qemu.py 2018-10-26 04:46:44 +0000 |
362 | @@ -26,6 +26,7 @@ |
363 | patch, |
364 | ) |
365 | |
366 | + |
367 | from ubuntu_system_tests.host import qemu |
368 | from ubuntu_system_tests.selftests.utils import DummyArgs, ConfigBaseTestCase |
369 | |
370 | @@ -88,7 +89,7 @@ |
371 | qemu.extract_kernel('/tmp/test_iso', '/tmp/kernel', '/tmp/dst') |
372 | mock_check_call.assert_called_once_with( |
373 | ['bsdtar', 'xf', '/tmp/test_iso', '-C', '/tmp/dst', |
374 | - qemu.CASPER_INITRDLZ, '/tmp/kernel']) |
375 | + qemu.CASPER_INITRD, '/tmp/kernel']) |
376 | |
377 | @patch('subprocess.check_call') |
378 | def test_create_disk_image(self, mock_check_call): |
379 | @@ -143,6 +144,7 @@ |
380 | |
381 | @patch('os.mkdir') |
382 | @patch('os.chdir') |
383 | + @patch('pipes.Template.copy', return_value=0) |
384 | @patch('subprocess.Popen', side_effect=[popen_files_1, popen_files_2]) |
385 | @patch('subprocess.check_call') |
386 | @patch('ubuntu_system_tests.host.qemu.copy_qemu_scripts_to_path') |
387 | @@ -150,39 +152,25 @@ |
388 | @patch('ubuntu_system_tests.host.qemu.create_preseed') |
389 | def test_prepare_initrd( |
390 | self, mock_create_preseed, mock_add_script, mock_copy_script, |
391 | - mock_check_call, mock_popen, mock_chdir, mock_mkdir): |
392 | - with patch('builtins.open', mock_open()) as o: |
393 | + mock_check_call, mock_popen, mock_chdir, mock_mkdir, mock_copy): |
394 | + with patch('builtins.open', mock_open()): |
395 | initrd_path = qemu.prepare_initrd( |
396 | '/tmp/work_dir', 'user1', 'pass1', 'disp1') |
397 | self.assertEqual( |
398 | - '/tmp/work_dir/{}'.format(qemu.CASPER_INITRD), initrd_path) |
399 | - expected_check_calls = [ |
400 | - call(['cpio', '--quiet', '-id'], |
401 | - stdin='/tmp/file_1\n/tmp/file_2'), |
402 | - call(['cpio', '--quiet', '-o', '-H', 'newc'], |
403 | - stdin='/tmp/file_3\n/tmp/file_4', stdout=o()) |
404 | - ] |
405 | - mock_check_call.assert_has_calls(expected_check_calls) |
406 | - |
407 | - expected_popen_calls = [ |
408 | - call(['xzcat', '/tmp/work_dir/casper/initrd.lz'], stdout=-1), |
409 | - call(['find', '.'], stdout=-1) |
410 | - ] |
411 | - mock_popen.assert_has_calls(expected_popen_calls) |
412 | - |
413 | - mock_copy_script.assert_called_once_with('/tmp/work_dir/initrd') |
414 | + '/tmp/work_dir/{}'.format('initrd.d/initrd'), initrd_path) |
415 | + mock_copy_script.assert_called_once_with('/tmp/work_dir/initrd.d/main') |
416 | mock_add_script.assert_called_once_with( |
417 | - '/tmp/work_dir/initrd', |
418 | - '/tmp/work_dir/initrd/qemu-casper-provision') |
419 | + '/tmp/work_dir/initrd.d', |
420 | + '/tmp/work_dir/initrd.d/main/qemu-casper-provision') |
421 | mock_create_preseed.assert_called_once_with( |
422 | - '/tmp/work_dir/initrd/preseed.cfg', 'user1', 'pass1', 'disp1') |
423 | + '/tmp/work_dir/initrd.d/main/preseed.cfg', 'user1', 'pass1', 'disp1') |
424 | |
425 | @patch('shutil.copy2') |
426 | def test_add_script_to_casper_setup(self, mock_copy2): |
427 | with patch('builtins.open', mock_open(read_data='abcd')) as o: |
428 | qemu.add_script_to_casper_setup('/tmp/initrd', '/tmp/test_script') |
429 | expected_file_calls = [ |
430 | - call('/tmp/initrd/scripts/casper-bottom/ORDER', 'r+'), |
431 | + call('/tmp/initrd/main/scripts/casper-bottom/ORDER', 'r+'), |
432 | call().__enter__(), |
433 | call().read(), |
434 | call().seek(0), |
435 | @@ -208,7 +196,7 @@ |
436 | '-enable-kvm', '-drive', 'file=/tmp/disk.img,if=virtio', |
437 | '-display', 'none', '-vga', 'qxl', '-cdrom', |
438 | '/tmp/disk.iso', '-boot', 'd', |
439 | - '-initrd', '/tmp/work_dir/casper/initrd', '-kernel', '/tmp/kernel', |
440 | + '-initrd', '/tmp/work_dir/initrd.d/initrd', '-kernel', '/tmp/kernel', |
441 | '-append', 'kenel_opts', '-boot', 'menu=off', '-no-reboot', '-net', |
442 | 'nic,model=virtio', '-net', 'user' |
443 | ] |
444 | @@ -263,7 +251,7 @@ |
445 | '-display', 'sdl', '-vga', 'qxl', '-soundhw', 'all', |
446 | '-serial', 'file:/tmp/12345/qemu.ttyS0', '-serial', |
447 | 'file:/tmp/12345/qemu.ttyS1', '-cdrom', '/tmp/disk.iso', |
448 | - '-boot', 'd', '-initrd', '/tmp/12345/casper/initrd', |
449 | + '-boot', 'd', '-initrd', '/tmp/12345/initrd.d/initrd', |
450 | '-kernel', '/tmp/kernel', '-append', 'boot=casper ' |
451 | 'DEBCONF_DEBUG=developer -- debconf/priority=critical ' |
452 | 'locale=en_US console-setup/ask_detect=false ' |
FAILED: Continuous integration, rev:582 /platform- qa-jenkins. ubuntu. com/job/ ubuntu- system- tests-ci/ 1336/ /platform- qa-jenkins. ubuntu. com/job/ generic- update- mp/2475/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /platform- qa-jenkins. ubuntu. com/job/ ubuntu- system- tests-ci/ 1336/rebuild
https:/