Merge lp:~sbaldassin/snappy-ecosystem-tests/merge_builder_snapd into lp:snappy-ecosystem-tests
- merge_builder_snapd
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Heber Parrucci |
Approved revision: | 50 |
Merged at revision: | 49 |
Proposed branch: | lp:~sbaldassin/snappy-ecosystem-tests/merge_builder_snapd |
Merge into: | lp:snappy-ecosystem-tests |
Diff against target: |
467 lines (+135/-182) 7 files modified
snappy_ecosystem_tests/helpers/snapcraft/build_snap.py (+0/-161) snappy_ecosystem_tests/helpers/snapcraft/client.py (+123/-4) snappy_ecosystem_tests/helpers/snapd/snapd.py (+5/-5) snappy_ecosystem_tests/helpers/test_base.py (+0/-1) snappy_ecosystem_tests/tests/test_install_private_snap.py (+2/-7) snappy_ecosystem_tests/utils/ssh.py (+5/-3) snappy_ecosystem_tests/utils/user.py (+0/-1) |
To merge this branch: | bzr merge lp:~sbaldassin/snappy-ecosystem-tests/merge_builder_snapd |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Heber Parrucci (community) | Approve | ||
platform-qa-bot | continuous-integration | Approve | |
Review via email: mp+320163@code.launchpad.net |
Commit message
Merge Snapcraft and SnapBuilder in a single class
Description of the change
This mp merge Snapcraft and SnapBuilder in a single class as they represent the same class. We'll need to instantiate two different objects, pointing to the builder container and the snapcraft container respectively
platform-qa-bot (platform-qa-bot) wrote : | # |
Heber Parrucci (heber013) wrote : | # |
Looks good. One comment inline
- 48. By Santiago Baldassin
-
Addressing comments from the reviews
Santiago Baldassin (sbaldassin) wrote : | # |
Thanks Heber. Comments addressed
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:48
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Heber Parrucci (heber013) wrote : | # |
There are some tests failing in this branch that pass on trunk, see log http://
Seems that the time between snaps registration is broken.
- 49. By Santiago Baldassin
-
Merge from trunk
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:49
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 50. By Santiago Baldassin
-
Merge from trunk
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:50
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Heber Parrucci (heber013) wrote : | # |
Tests are passing properly now http://
Let's land it.
Preview Diff
1 | === removed file 'snappy_ecosystem_tests/helpers/snapcraft/build_snap.py' | |||
2 | --- snappy_ecosystem_tests/helpers/snapcraft/build_snap.py 2017-03-16 11:40:13 +0000 | |||
3 | +++ snappy_ecosystem_tests/helpers/snapcraft/build_snap.py 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,161 +0,0 @@ | |||
5 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
6 | 2 | |||
7 | 3 | # | ||
8 | 4 | # Snappy Ecosystem Tests | ||
9 | 5 | # Copyright (C) 2017 Canonical | ||
10 | 6 | # | ||
11 | 7 | # This program is free software: you can redistribute it and/or modify | ||
12 | 8 | # it under the terms of the GNU General Public License as published by | ||
13 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
14 | 10 | # (at your option) any later version. | ||
15 | 11 | # | ||
16 | 12 | # This program is distributed in the hope that it will be useful, | ||
17 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | 15 | # GNU General Public License for more details. | ||
20 | 16 | # | ||
21 | 17 | # You should have received a copy of the GNU General Public License | ||
22 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
23 | 19 | # | ||
24 | 20 | |||
25 | 21 | """Module to build a snap in a remote machine.""" | ||
26 | 22 | |||
27 | 23 | import os | ||
28 | 24 | from pathlib import PurePath | ||
29 | 25 | |||
30 | 26 | from snappy_ecosystem_tests.utils.ssh import SSHManager | ||
31 | 27 | |||
32 | 28 | COMMANDS_SETUP = [ | ||
33 | 29 | 'apt update', | ||
34 | 30 | 'apt dist-upgrade -y', | ||
35 | 31 | 'apt install snapcraft -y' | ||
36 | 32 | ] | ||
37 | 33 | SNAPCRAFT_YAML = """\ | ||
38 | 34 | name: {snap_name} | ||
39 | 35 | version: {version} | ||
40 | 36 | summary: {summary} | ||
41 | 37 | description: | | ||
42 | 38 | {description} | ||
43 | 39 | |||
44 | 40 | grade: {grade} | ||
45 | 41 | confinement: {confinement} | ||
46 | 42 | |||
47 | 43 | parts: | ||
48 | 44 | {snap_name}: | ||
49 | 45 | plugin: nil | ||
50 | 46 | |||
51 | 47 | apps: | ||
52 | 48 | {snap_name}: | ||
53 | 49 | command: echo ok | ||
54 | 50 | """ | ||
55 | 51 | SUMMARY_SNAP_DEFAULT = 'A test snap.' | ||
56 | 52 | DESCRIPTION_SNAP_DEFAULT = 'A very awesome test snap.' | ||
57 | 53 | GRADE_SNAP_DEFAULT = 'stable' | ||
58 | 54 | CONFINEMENT_SNAP_DEFAULT = 'strict' | ||
59 | 55 | |||
60 | 56 | |||
61 | 57 | class SnapBuilder: | ||
62 | 58 | """Class to build a snap on a remote machine and download its content.""" | ||
63 | 59 | def __init__(self, hostname, username, port=22): | ||
64 | 60 | self.hostname = hostname | ||
65 | 61 | self.username = username | ||
66 | 62 | self.port = port | ||
67 | 63 | |||
68 | 64 | @property | ||
69 | 65 | def ssh(self): | ||
70 | 66 | """Property tu ensure we get an active connection for every command | ||
71 | 67 | execution over ssh""" | ||
72 | 68 | return SSHManager.get_instance(self.hostname, self.username, self.port) | ||
73 | 69 | |||
74 | 70 | def run_command_ssh(self, command, cwd=''): | ||
75 | 71 | """Run command over ssh with optional cwd.""" | ||
76 | 72 | if cwd: | ||
77 | 73 | command = 'cd {}; {}'.format(cwd, command) | ||
78 | 74 | return self.ssh.exec_command(command) | ||
79 | 75 | |||
80 | 76 | def is_host_setup(self): | ||
81 | 77 | """Return bool representing whether the remote host is setup by | ||
82 | 78 | checking if snapcraft package is installed.""" | ||
83 | 79 | try: | ||
84 | 80 | self.ssh.exec_command('which snapcraft') | ||
85 | 81 | return True | ||
86 | 82 | except ValueError: | ||
87 | 83 | return False | ||
88 | 84 | |||
89 | 85 | def setup_host(self): | ||
90 | 86 | """Setup the host to build a snap, currently only installs | ||
91 | 87 | snapcraft.""" | ||
92 | 88 | for command in COMMANDS_SETUP: | ||
93 | 89 | self.ssh.exec_command(command) | ||
94 | 90 | |||
95 | 91 | def build(self, name, version, summary=SUMMARY_SNAP_DEFAULT, | ||
96 | 92 | description=DESCRIPTION_SNAP_DEFAULT, grade=GRADE_SNAP_DEFAULT, | ||
97 | 93 | confinement=CONFINEMENT_SNAP_DEFAULT): | ||
98 | 94 | """Build a new snap in the remote host and return its remote path. | ||
99 | 95 | |||
100 | 96 | :param name: name of the snap to build. | ||
101 | 97 | :param version: version number for the snap to build. | ||
102 | 98 | :param summary: short summary of the snap to build. | ||
103 | 99 | :param description: long description of the snap. | ||
104 | 100 | :param grade: stability grade of the snap e.g. stable or devel. | ||
105 | 101 | :param confinement: confinement policy for the snap e.g. | ||
106 | 102 | classic, devmode or strict. | ||
107 | 103 | :raises ValueError: If an error is occurred during snap build. | ||
108 | 104 | :return: Remote path of the newly build snap package. | ||
109 | 105 | """ | ||
110 | 106 | if not self.is_host_setup(): | ||
111 | 107 | self.setup_host() | ||
112 | 108 | tempdir = self.ssh.exec_command('mktemp -d') | ||
113 | 109 | self.run_command_ssh('mkdir snap', cwd=tempdir) | ||
114 | 110 | self.run_command_ssh('echo "{}" > snap/snapcraft.yaml'.format( | ||
115 | 111 | SNAPCRAFT_YAML.format( | ||
116 | 112 | snap_name=name, | ||
117 | 113 | version=version, | ||
118 | 114 | summary=summary, | ||
119 | 115 | description=description, | ||
120 | 116 | grade=grade, | ||
121 | 117 | confinement=confinement | ||
122 | 118 | ) | ||
123 | 119 | ), cwd=tempdir) | ||
124 | 120 | self.run_command_ssh('snapcraft', cwd=tempdir) | ||
125 | 121 | return os.path.join( | ||
126 | 122 | tempdir, | ||
127 | 123 | '{name}_{version}_{arch}.snap'.format( | ||
128 | 124 | name=name, | ||
129 | 125 | version=version, | ||
130 | 126 | arch=self.ssh.exec_command('dpkg --print-architecture') | ||
131 | 127 | ) | ||
132 | 128 | ) | ||
133 | 129 | |||
134 | 130 | def build_and_pull(self, name, version, summary=SUMMARY_SNAP_DEFAULT, | ||
135 | 131 | description=DESCRIPTION_SNAP_DEFAULT, | ||
136 | 132 | grade=GRADE_SNAP_DEFAULT, | ||
137 | 133 | confinement=CONFINEMENT_SNAP_DEFAULT, | ||
138 | 134 | output_location='.'): | ||
139 | 135 | """Build a snap based on the provided arguments and download it. | ||
140 | 136 | |||
141 | 137 | :param name: name of the snap to build. | ||
142 | 138 | :param version: version number for the snap to build. | ||
143 | 139 | :param summary: short summary of the snap to build. | ||
144 | 140 | :param description: long description of the snap. | ||
145 | 141 | :param grade: stability grade of the snap e.g. stable or devel. | ||
146 | 142 | :param confinement: confinement policy for the snap e.g. | ||
147 | 143 | classic, devmode or strict. | ||
148 | 144 | :param output_location: Local location to download the newly built | ||
149 | 145 | snap to. Defaults to pwd. | ||
150 | 146 | :raises ValueError: If an error is occurred during snap build. | ||
151 | 147 | :return: Local path of the newly built and downloaded snap package. | ||
152 | 148 | """ | ||
153 | 149 | remote_snap_path = self.build( | ||
154 | 150 | name=name, | ||
155 | 151 | version=version, | ||
156 | 152 | summary=summary, | ||
157 | 153 | description=description, | ||
158 | 154 | grade=grade, | ||
159 | 155 | confinement=confinement | ||
160 | 156 | ) | ||
161 | 157 | output_path_absolute = os.path.abspath( | ||
162 | 158 | os.path.join(output_location, PurePath(remote_snap_path).name) | ||
163 | 159 | ) | ||
164 | 160 | self.ssh.pull(remote_snap_path, output_path_absolute) | ||
165 | 161 | return output_path_absolute | ||
166 | 162 | 0 | ||
167 | === modified file 'snappy_ecosystem_tests/helpers/snapcraft/client.py' | |||
168 | --- snappy_ecosystem_tests/helpers/snapcraft/client.py 2017-03-16 16:42:44 +0000 | |||
169 | +++ snappy_ecosystem_tests/helpers/snapcraft/client.py 2017-03-22 12:29:23 +0000 | |||
170 | @@ -21,9 +21,12 @@ | |||
171 | 21 | """Snapcraft client helpers""" | 21 | """Snapcraft client helpers""" |
172 | 22 | 22 | ||
173 | 23 | import logging | 23 | import logging |
174 | 24 | import os | ||
175 | 24 | import subprocess | 25 | import subprocess |
176 | 25 | import time | 26 | import time |
177 | 26 | 27 | ||
178 | 28 | from pathlib import PurePath | ||
179 | 29 | |||
180 | 27 | from snappy_ecosystem_tests.models.snap import Snap | 30 | from snappy_ecosystem_tests.models.snap import Snap |
181 | 28 | from snappy_ecosystem_tests.utils.commands import build_command | 31 | from snappy_ecosystem_tests.utils.commands import build_command |
182 | 29 | from snappy_ecosystem_tests.utils.filters import filter_list | 32 | from snappy_ecosystem_tests.utils.filters import filter_list |
183 | @@ -61,6 +64,34 @@ | |||
184 | 61 | SNAPCRAFT_CONFIG_FILE_PATH = '~/.config/snapcraft/snapcraft.cfg' | 64 | SNAPCRAFT_CONFIG_FILE_PATH = '~/.config/snapcraft/snapcraft.cfg' |
185 | 62 | 65 | ||
186 | 63 | 66 | ||
187 | 67 | COMMANDS_SETUP = [ | ||
188 | 68 | 'apt update', | ||
189 | 69 | 'apt dist-upgrade -y', | ||
190 | 70 | 'apt install snapcraft -y' | ||
191 | 71 | ] | ||
192 | 72 | SNAPCRAFT_YAML = """\ | ||
193 | 73 | name: {snap_name} | ||
194 | 74 | version: {version} | ||
195 | 75 | summary: {summary} | ||
196 | 76 | description: | | ||
197 | 77 | {description} | ||
198 | 78 | |||
199 | 79 | grade: {grade} | ||
200 | 80 | confinement: {confinement} | ||
201 | 81 | |||
202 | 82 | parts: | ||
203 | 83 | {snap_name}: | ||
204 | 84 | plugin: nil | ||
205 | 85 | |||
206 | 86 | apps: | ||
207 | 87 | {snap_name}: | ||
208 | 88 | command: echo ok | ||
209 | 89 | """ | ||
210 | 90 | SUMMARY_SNAP_DEFAULT = 'A test snap.' | ||
211 | 91 | DESCRIPTION_SNAP_DEFAULT = 'A very awesome test snap.' | ||
212 | 92 | GRADE_SNAP_DEFAULT = 'stable' | ||
213 | 93 | CONFINEMENT_SNAP_DEFAULT = 'strict' | ||
214 | 94 | |||
215 | 64 | class Snapcraft: | 95 | class Snapcraft: |
216 | 65 | """Contain Snapcraft specific functionality to use via command | 96 | """Contain Snapcraft specific functionality to use via command |
217 | 66 | line interface""" | 97 | line interface""" |
218 | @@ -75,7 +106,22 @@ | |||
219 | 75 | execution over ssh""" | 106 | execution over ssh""" |
220 | 76 | return SSHManager.get_instance(HOSTNAME, USERNAME, PORT) | 107 | return SSHManager.get_instance(HOSTNAME, USERNAME, PORT) |
221 | 77 | 108 | ||
223 | 78 | def _run_snapcraft_command_ssh(self, command, debug=True): | 109 | def is_host_setup(self): |
224 | 110 | """Return bool representing whether the remote host is setup by | ||
225 | 111 | checking if snapcraft package is installed.""" | ||
226 | 112 | try: | ||
227 | 113 | self.ssh.run_command('which snapcraft') | ||
228 | 114 | return True | ||
229 | 115 | except ValueError: | ||
230 | 116 | return False | ||
231 | 117 | |||
232 | 118 | def setup_host(self): | ||
233 | 119 | """Setup the host to build a snap, currently only installs | ||
234 | 120 | snapcraft.""" | ||
235 | 121 | for command in COMMANDS_SETUP: | ||
236 | 122 | self.ssh.run_command(command) | ||
237 | 123 | |||
238 | 124 | def _run_snapcraft_command_ssh(self, command='', debug=True, cwd=''): | ||
239 | 79 | """ | 125 | """ |
240 | 80 | Run snapcraft command via ssh | 126 | Run snapcraft command via ssh |
241 | 81 | :param command: the command to be executed. | 127 | :param command: the command to be executed. |
242 | @@ -87,7 +133,7 @@ | |||
243 | 87 | command = build_snapcraft_command(command) | 133 | command = build_snapcraft_command(command) |
244 | 88 | if debug: | 134 | if debug: |
245 | 89 | command += ' -d' | 135 | command += ' -d' |
247 | 90 | return self.ssh.exec_command(command) | 136 | return self.ssh.run_command(command, cwd=cwd) |
248 | 91 | 137 | ||
249 | 92 | def assert_logged_in(self): | 138 | def assert_logged_in(self): |
250 | 93 | """Assert that an user is logged. | 139 | """Assert that an user is logged. |
251 | @@ -100,7 +146,7 @@ | |||
252 | 100 | def is_logged_in(self): | 146 | def is_logged_in(self): |
253 | 101 | """Return bool representing if the user is logged into snapcraft.""" | 147 | """Return bool representing if the user is logged into snapcraft.""" |
254 | 102 | try: | 148 | try: |
256 | 103 | output = self.ssh.exec_command( | 149 | output = self.ssh.run_command( |
257 | 104 | 'cat %s' % SNAPCRAFT_CONFIG_FILE_PATH) | 150 | 'cat %s' % SNAPCRAFT_CONFIG_FILE_PATH) |
258 | 105 | return output is not '' | 151 | return output is not '' |
259 | 106 | except ValueError: | 152 | except ValueError: |
260 | @@ -123,7 +169,7 @@ | |||
261 | 123 | :param email: the SSO email | 169 | :param email: the SSO email |
262 | 124 | :param password: the email password | 170 | :param password: the email password |
263 | 125 | """ | 171 | """ |
265 | 126 | self.ssh.exec_command( | 172 | self.ssh.run_command( |
266 | 127 | COMMANDS_LOGIN.format(email=email, password=password, | 173 | COMMANDS_LOGIN.format(email=email, password=password, |
267 | 128 | snapcraft=PATH_SNAPCRAFT)) | 174 | snapcraft=PATH_SNAPCRAFT)) |
268 | 129 | return self.is_logged_in() | 175 | return self.is_logged_in() |
269 | @@ -185,6 +231,79 @@ | |||
270 | 185 | LOGGER.info('Snap %s registered successfully!!!', snap_name) | 231 | LOGGER.info('Snap %s registered successfully!!!', snap_name) |
271 | 186 | return True | 232 | return True |
272 | 187 | 233 | ||
273 | 234 | def build(self, name, version, summary=SUMMARY_SNAP_DEFAULT, | ||
274 | 235 | description=DESCRIPTION_SNAP_DEFAULT, grade=GRADE_SNAP_DEFAULT, | ||
275 | 236 | confinement=CONFINEMENT_SNAP_DEFAULT): | ||
276 | 237 | """Build a new snap in the remote host and return its remote path. | ||
277 | 238 | |||
278 | 239 | :param name: name of the snap to build. | ||
279 | 240 | :param version: version number for the snap to build. | ||
280 | 241 | :param summary: short summary of the snap to build. | ||
281 | 242 | :param description: long description of the snap. | ||
282 | 243 | :param grade: stability grade of the snap e.g. stable or devel. | ||
283 | 244 | :param confinement: confinement policy for the snap e.g. | ||
284 | 245 | classic, devmode or strict. | ||
285 | 246 | :raises ValueError: If an error is occurred during snap build. | ||
286 | 247 | :return: Remote path of the newly build snap package. | ||
287 | 248 | """ | ||
288 | 249 | if not self.is_host_setup(): | ||
289 | 250 | self.setup_host() | ||
290 | 251 | tempdir = self.ssh.run_command('mktemp -d') | ||
291 | 252 | self.ssh.run_command('mkdir snap', cwd=tempdir) | ||
292 | 253 | self.ssh.run_command( | ||
293 | 254 | 'echo "{}" > snap/snapcraft.yaml'.format( | ||
294 | 255 | SNAPCRAFT_YAML.format( | ||
295 | 256 | snap_name=name, | ||
296 | 257 | version=version, | ||
297 | 258 | summary=summary, | ||
298 | 259 | description=description, | ||
299 | 260 | grade=grade, | ||
300 | 261 | confinement=confinement | ||
301 | 262 | ) | ||
302 | 263 | ), cwd=tempdir) | ||
303 | 264 | self._run_snapcraft_command_ssh(cwd=tempdir) | ||
304 | 265 | return os.path.join( | ||
305 | 266 | tempdir, | ||
306 | 267 | '{name}_{version}_{arch}.snap'.format( | ||
307 | 268 | name=name, | ||
308 | 269 | version=version, | ||
309 | 270 | arch=self.ssh.run_command('dpkg --print-architecture') | ||
310 | 271 | ) | ||
311 | 272 | ) | ||
312 | 273 | |||
313 | 274 | def build_and_pull(self, name, version, summary=SUMMARY_SNAP_DEFAULT, | ||
314 | 275 | description=DESCRIPTION_SNAP_DEFAULT, | ||
315 | 276 | grade=GRADE_SNAP_DEFAULT, | ||
316 | 277 | confinement=CONFINEMENT_SNAP_DEFAULT, | ||
317 | 278 | output_location='.'): | ||
318 | 279 | """Build a snap based on the provided arguments and download it. | ||
319 | 280 | |||
320 | 281 | :param name: name of the snap to build. | ||
321 | 282 | :param version: version number for the snap to build. | ||
322 | 283 | :param summary: short summary of the snap to build. | ||
323 | 284 | :param description: long description of the snap. | ||
324 | 285 | :param grade: stability grade of the snap e.g. stable or devel. | ||
325 | 286 | :param confinement: confinement policy for the snap e.g. | ||
326 | 287 | classic, devmode or strict. | ||
327 | 288 | :param output_location: Local location to download the newly built | ||
328 | 289 | snap to. Defaults to pwd. | ||
329 | 290 | :raises ValueError: If an error is occurred during snap build. | ||
330 | 291 | :return: Local path of the newly built and downloaded snap package. | ||
331 | 292 | """ | ||
332 | 293 | remote_snap_path = self.build( | ||
333 | 294 | name=name, | ||
334 | 295 | version=version, | ||
335 | 296 | summary=summary, | ||
336 | 297 | description=description, | ||
337 | 298 | grade=grade, | ||
338 | 299 | confinement=confinement | ||
339 | 300 | ) | ||
340 | 301 | output_path_absolute = os.path.abspath( | ||
341 | 302 | os.path.join(output_location, PurePath(remote_snap_path).name) | ||
342 | 303 | ) | ||
343 | 304 | self.ssh.pull(remote_snap_path, output_path_absolute) | ||
344 | 305 | return output_path_absolute | ||
345 | 306 | |||
346 | 188 | 307 | ||
347 | 189 | def build_snapcraft_command(*args, base_command=PATH_SNAPCRAFT): | 308 | def build_snapcraft_command(*args, base_command=PATH_SNAPCRAFT): |
348 | 190 | """ | 309 | """ |
349 | 191 | 310 | ||
350 | === modified file 'snappy_ecosystem_tests/helpers/snapd/snapd.py' | |||
351 | --- snappy_ecosystem_tests/helpers/snapd/snapd.py 2017-03-19 15:27:11 +0000 | |||
352 | +++ snappy_ecosystem_tests/helpers/snapd/snapd.py 2017-03-22 12:29:23 +0000 | |||
353 | @@ -74,7 +74,7 @@ | |||
354 | 74 | command = '{} {}'.format(PATH_SNAP, command) | 74 | command = '{} {}'.format(PATH_SNAP, command) |
355 | 75 | if cwd: | 75 | if cwd: |
356 | 76 | command = '{}; {}'.format(cwd, command) | 76 | command = '{}; {}'.format(cwd, command) |
358 | 77 | return self.ssh.exec_command(command) | 77 | return self.ssh.run_command(command) |
359 | 78 | 78 | ||
360 | 79 | def login(self, email, password): | 79 | def login(self, email, password): |
361 | 80 | """Login to snapd. | 80 | """Login to snapd. |
362 | @@ -82,15 +82,15 @@ | |||
363 | 82 | :param email: Ubuntu SSO account email address. | 82 | :param email: Ubuntu SSO account email address. |
364 | 83 | :param password: Ubuntu SSO account password. | 83 | :param password: Ubuntu SSO account password. |
365 | 84 | """ | 84 | """ |
368 | 85 | self.ssh.exec_command(COMMANDS_LOGIN.format(email=email, | 85 | self.ssh.run_command(COMMANDS_LOGIN.format(email=email, |
369 | 86 | password=password)) | 86 | password=password)) |
370 | 87 | return self.is_logged_in(email) | 87 | return self.is_logged_in(email) |
371 | 88 | 88 | ||
372 | 89 | def is_logged_in(self, email): | 89 | def is_logged_in(self, email): |
373 | 90 | """Return bool representing if the user is logged into snapd.""" | 90 | """Return bool representing if the user is logged into snapd.""" |
374 | 91 | try: | 91 | try: |
375 | 92 | return json.loads( | 92 | return json.loads( |
377 | 93 | self.ssh.exec_command( | 93 | self.ssh.run_command( |
378 | 94 | 'cat ~/.snap/auth.json')).get('email') == email | 94 | 'cat ~/.snap/auth.json')).get('email') == email |
379 | 95 | except ValueError: | 95 | except ValueError: |
380 | 96 | return False | 96 | return False |
381 | @@ -108,7 +108,7 @@ | |||
382 | 108 | """ | 108 | """ |
383 | 109 | command = COMMAND_DOWNLOAD.format(snap=snap, channel=channel) | 109 | command = COMMAND_DOWNLOAD.format(snap=snap, channel=channel) |
384 | 110 | self.run_snapd_command_ssh(command, | 110 | self.run_snapd_command_ssh(command, |
386 | 111 | cwd=self.ssh.exec_command('mktemp -d')) | 111 | cwd=self.ssh.run_command('mktemp -d')) |
387 | 112 | 112 | ||
388 | 113 | def install(self, snap, channel=CHANNEL_STABLE): | 113 | def install(self, snap, channel=CHANNEL_STABLE): |
389 | 114 | """Install the requested snap.""" | 114 | """Install the requested snap.""" |
390 | 115 | 115 | ||
391 | === modified file 'snappy_ecosystem_tests/helpers/test_base.py' | |||
392 | --- snappy_ecosystem_tests/helpers/test_base.py 2017-03-08 17:29:20 +0000 | |||
393 | +++ snappy_ecosystem_tests/helpers/test_base.py 2017-03-22 12:29:23 +0000 | |||
394 | @@ -15,7 +15,6 @@ | |||
395 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
396 | 16 | 16 | ||
397 | 17 | """Base Snappy Ecosystem test""" | 17 | """Base Snappy Ecosystem test""" |
398 | 18 | |||
399 | 19 | import testscenarios | 18 | import testscenarios |
400 | 20 | import testtools | 19 | import testtools |
401 | 21 | 20 | ||
402 | 22 | 21 | ||
403 | === modified file 'snappy_ecosystem_tests/tests/test_install_private_snap.py' | |||
404 | --- snappy_ecosystem_tests/tests/test_install_private_snap.py 2017-03-17 20:50:55 +0000 | |||
405 | +++ snappy_ecosystem_tests/tests/test_install_private_snap.py 2017-03-22 12:29:23 +0000 | |||
406 | @@ -19,16 +19,12 @@ | |||
407 | 19 | # | 19 | # |
408 | 20 | 20 | ||
409 | 21 | """Tests for Installing private snaps.""" | 21 | """Tests for Installing private snaps.""" |
411 | 22 | 22 | from snappy_ecosystem_tests.helpers.snapcraft.client import Snapcraft | |
412 | 23 | from snappy_ecosystem_tests.helpers.snapd.snapd import Snapd | 23 | from snappy_ecosystem_tests.helpers.snapd.snapd import Snapd |
413 | 24 | from snappy_ecosystem_tests.helpers.store_apis.rest_apis import Store | 24 | from snappy_ecosystem_tests.helpers.store_apis.rest_apis import Store |
414 | 25 | from snappy_ecosystem_tests.helpers.snapcraft.build_snap import SnapBuilder | ||
415 | 26 | from snappy_ecosystem_tests.helpers.test_base import SnappyEcosystemTestCase | 25 | from snappy_ecosystem_tests.helpers.test_base import SnappyEcosystemTestCase |
416 | 27 | from snappy_ecosystem_tests.tests.commons import get_random_snap_name | 26 | from snappy_ecosystem_tests.tests.commons import get_random_snap_name |
417 | 28 | from snappy_ecosystem_tests.utils.storeconfig import get_store_credentials | 27 | from snappy_ecosystem_tests.utils.storeconfig import get_store_credentials |
418 | 29 | from snappy_ecosystem_tests.utils.user import ( | ||
419 | 30 | get_snapcraft_remote_host_credentials | ||
420 | 31 | ) | ||
421 | 32 | 28 | ||
422 | 33 | 29 | ||
423 | 34 | class RegisterInstallPrivateSnapTestCase(SnappyEcosystemTestCase): | 30 | class RegisterInstallPrivateSnapTestCase(SnappyEcosystemTestCase): |
424 | @@ -42,8 +38,7 @@ | |||
425 | 42 | self.addCleanup(self.snapd.logout, email) | 38 | self.addCleanup(self.snapd.logout, email) |
426 | 43 | self.store.login(email, password) | 39 | self.store.login(email, password) |
427 | 44 | self.addCleanup(self.store.logout) | 40 | self.addCleanup(self.store.logout) |
430 | 45 | self.snap_builder = SnapBuilder( | 41 | self.snap_builder = Snapcraft() |
429 | 46 | *get_snapcraft_remote_host_credentials()) | ||
431 | 47 | 42 | ||
432 | 48 | def test_upload_and_install_private_snap(self): | 43 | def test_upload_and_install_private_snap(self): |
433 | 49 | """Test to register and upload a private snap via the REST API | 44 | """Test to register and upload a private snap via the REST API |
434 | 50 | 45 | ||
435 | === modified file 'snappy_ecosystem_tests/utils/ssh.py' | |||
436 | --- snappy_ecosystem_tests/utils/ssh.py 2017-03-09 17:24:06 +0000 | |||
437 | +++ snappy_ecosystem_tests/utils/ssh.py 2017-03-22 12:29:23 +0000 | |||
438 | @@ -30,12 +30,14 @@ | |||
439 | 30 | class SSHClient(paramiko.SSHClient): | 30 | class SSHClient(paramiko.SSHClient): |
440 | 31 | """Extended SSHClient.""" | 31 | """Extended SSHClient.""" |
441 | 32 | 32 | ||
444 | 33 | def exec_command(self, command, bufsize=-1, timeout=None, get_pty=False, | 33 | def run_command(self, command, bufsize=-1, timeout=None, |
445 | 34 | environment=None): | 34 | get_pty=False, cwd=''): |
446 | 35 | """Execute the given command over ssh.""" | 35 | """Execute the given command over ssh.""" |
447 | 36 | if cwd: | ||
448 | 37 | command = 'cd {}; {}'.format(cwd, command) | ||
449 | 36 | _, stdout, stderr = super().exec_command( | 38 | _, stdout, stderr = super().exec_command( |
450 | 37 | command, bufsize, timeout, | 39 | command, bufsize, timeout, |
452 | 38 | get_pty, environment=environment) | 40 | get_pty) |
453 | 39 | if stdout.channel.recv_exit_status() != 0: | 41 | if stdout.channel.recv_exit_status() != 0: |
454 | 40 | raise ValueError(stderr.read().decode().strip()) | 42 | raise ValueError(stderr.read().decode().strip()) |
455 | 41 | response = stdout.read().decode().strip() | 43 | response = stdout.read().decode().strip() |
456 | 42 | 44 | ||
457 | === modified file 'snappy_ecosystem_tests/utils/user.py' | |||
458 | --- snappy_ecosystem_tests/utils/user.py 2017-03-09 10:41:13 +0000 | |||
459 | +++ snappy_ecosystem_tests/utils/user.py 2017-03-22 12:29:23 +0000 | |||
460 | @@ -27,7 +27,6 @@ | |||
461 | 27 | 27 | ||
462 | 28 | MANAGER = get_manager(os.environ['target']) | 28 | MANAGER = get_manager(os.environ['target']) |
463 | 29 | 29 | ||
464 | 30 | |||
465 | 31 | def get_snapd_remote_host_credentials(): | 30 | def get_snapd_remote_host_credentials(): |
466 | 32 | """Return credentials for snapd remote machine, to run commands on.""" | 31 | """Return credentials for snapd remote machine, to run commands on.""" |
467 | 33 | _ip = MANAGER.driver.get_ip(USER_CONFIG_STACK.get( | 32 | _ip = MANAGER.driver.get_ip(USER_CONFIG_STACK.get( |
PASSED: Continuous integration, rev:47 /platform- qa-jenkins. ubuntu. com/job/ snappy- ecosystem- tests-ci/ 295/ /platform- qa-jenkins. ubuntu. com/job/ generic- update- mp/2150/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /platform- qa-jenkins. ubuntu. com/job/ snappy- ecosystem- tests-ci/ 295/rebuild
https:/