Merge lp:~canonical-platform-qa/snappy-ecosystem-tests/install-private-snap into lp:snappy-ecosystem-tests

Proposed by Omer Akram
Status: Merged
Approved by: Santiago Baldassin
Approved revision: 90
Merged at revision: 45
Proposed branch: lp:~canonical-platform-qa/snappy-ecosystem-tests/install-private-snap
Merge into: lp:snappy-ecosystem-tests
Prerequisite: lp:~canonical-platform-qa/snappy-ecosystem-tests/fix-snap-builder
Diff against target: 202 lines (+99/-19)
5 files modified
snappy_ecosystem_tests/environment/constants.py (+1/-1)
snappy_ecosystem_tests/helpers/snapd/snapd.py (+4/-4)
snappy_ecosystem_tests/tests/commons.py (+28/-0)
snappy_ecosystem_tests/tests/test_install_private_snap.py (+61/-0)
snappy_ecosystem_tests/tests/test_register_snap.py (+5/-14)
To merge this branch: bzr merge lp:~canonical-platform-qa/snappy-ecosystem-tests/install-private-snap
Reviewer Review Type Date Requested Status
platform-qa-bot continuous-integration Approve
Santiago Baldassin (community) Approve
Review via email: mp+320036@code.launchpad.net

Commit message

test: register private snap and install it

Description of the change

test: register private snap and install it

To post a comment you must log in.
Revision history for this message
Omer Akram (om26er) wrote :

Note: for snaps to be installable inside a container, the package squashfuse has to be installed, added it as a dependency for snapd.

The `install` method of snapd was broken, this branch fixes that.

Also run_setup would need to be run again to test this as I just pushed an update to my ppa, with fixed staging.

Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Looks great!

review: Approve
Revision history for this message
platform-qa-bot (platform-qa-bot) :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
90. By Omer Akram

Better name the TestCase class

Revision history for this message
platform-qa-bot (platform-qa-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy_ecosystem_tests/environment/constants.py'
2--- snappy_ecosystem_tests/environment/constants.py 2017-03-10 15:53:13 +0000
3+++ snappy_ecosystem_tests/environment/constants.py 2017-03-16 19:28:32 +0000
4@@ -24,7 +24,7 @@
5 SNAPCRAFT = 'snapcraft'
6
7 DEPENDENCIES = {
8- SNAPD: [],
9+ SNAPD: ["squashfuse"],
10 SNAPCRAFT: [],
11 "shared": ["expect"]
12 }
13
14=== modified file 'snappy_ecosystem_tests/helpers/snapd/snapd.py'
15--- snappy_ecosystem_tests/helpers/snapd/snapd.py 2017-03-13 08:58:43 +0000
16+++ snappy_ecosystem_tests/helpers/snapd/snapd.py 2017-03-16 19:28:32 +0000
17@@ -111,10 +111,10 @@
18
19 def install(self, snap, channel=CHANNEL_STABLE):
20 """Install the requested snap."""
21- self.ssh.exec_command(COMMAND_INSTALL.format(snap=snap,
22- channel=channel))
23+ self.run_snapd_command_ssh(COMMAND_INSTALL.format(snap=snap,
24+ channel=channel))
25
26- def _is_installed(self, snap):
27+ def is_installed(self, snap):
28 """Return bool representing whether a snap is installed."""
29 for installed_snap in Snapd._parse_output(
30 self.run_snapd_command_ssh(COMMAND_LIST)):
31@@ -124,7 +124,7 @@
32
33 def remove(self, snap):
34 """Remove a snap, if its already installed."""
35- if self._is_installed(snap):
36+ if self.is_installed(snap):
37 self.run_snapd_command_ssh(COMMAND_REMOVE.format(snap=snap))
38
39 def info(self, snap, verbose=False):
40
41=== added file 'snappy_ecosystem_tests/tests/commons.py'
42--- snappy_ecosystem_tests/tests/commons.py 1970-01-01 00:00:00 +0000
43+++ snappy_ecosystem_tests/tests/commons.py 2017-03-16 19:28:32 +0000
44@@ -0,0 +1,28 @@
45+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
46+
47+#
48+# Snappy Ecosystem Tests
49+# Copyright (C) 2017 Canonical
50+#
51+# This program is free software: you can redistribute it and/or modify
52+# it under the terms of the GNU General Public License as published by
53+# the Free Software Foundation, either version 3 of the License, or
54+# (at your option) any later version.
55+#
56+# This program is distributed in the hope that it will be useful,
57+# but WITHOUT ANY WARRANTY; without even the implied warranty of
58+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59+# GNU General Public License for more details.
60+#
61+# You should have received a copy of the GNU General Public License
62+# along with this program. If not, see <http://www.gnu.org/licenses/>.
63+#
64+
65+"""Module to container common helpers for test."""
66+
67+import uuid
68+
69+
70+def get_random_snap_name():
71+ """Get a random snap name using uuid."""
72+ return uuid.uuid4().__str__()
73
74=== added file 'snappy_ecosystem_tests/tests/test_install_private_snap.py'
75--- snappy_ecosystem_tests/tests/test_install_private_snap.py 1970-01-01 00:00:00 +0000
76+++ snappy_ecosystem_tests/tests/test_install_private_snap.py 2017-03-16 19:28:32 +0000
77@@ -0,0 +1,61 @@
78+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
79+
80+#
81+# Snappy Ecosystem Tests
82+# Copyright (C) 2017 Canonical
83+#
84+# This program is free software: you can redistribute it and/or modify
85+# it under the terms of the GNU General Public License as published by
86+# the Free Software Foundation, either version 3 of the License, or
87+# (at your option) any later version.
88+#
89+# This program is distributed in the hope that it will be useful,
90+# but WITHOUT ANY WARRANTY; without even the implied warranty of
91+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92+# GNU General Public License for more details.
93+#
94+# You should have received a copy of the GNU General Public License
95+# along with this program. If not, see <http://www.gnu.org/licenses/>.
96+#
97+
98+"""Tests for Installing private snaps."""
99+
100+from snappy_ecosystem_tests.helpers.snapd.snapd import Snapd
101+from snappy_ecosystem_tests.helpers.store_apis.rest_apis import Store
102+from snappy_ecosystem_tests.helpers.snapcraft.build_snap import SnapBuilder
103+from snappy_ecosystem_tests.helpers.test_base import SnappyEcosystemTestCase
104+from snappy_ecosystem_tests.tests.commons import get_random_snap_name
105+from snappy_ecosystem_tests.utils.storeconfig import get_store_credentials
106+from snappy_ecosystem_tests.utils.user import (
107+ get_snapcraft_remote_host_credentials
108+)
109+
110+
111+class RegisterInstallPrivateSnapTestCase(SnappyEcosystemTestCase):
112+
113+ def setUp(self):
114+ super().setUp()
115+ self.store = Store()
116+ self.snapd = Snapd()
117+ email, password = get_store_credentials()
118+ self.assertTrue(self.snapd.login(email, password))
119+ self.addCleanup(self.snapd.logout, email)
120+ self.store.login(email, password)
121+ self.addCleanup(self.store.logout)
122+ self.snap_builder = SnapBuilder(
123+ *get_snapcraft_remote_host_credentials())
124+
125+ def test_upload_and_install_private_snap(self):
126+ """Test to register and upload a private snap via the REST API
127+ and installing through snapd."""
128+ snap_name = get_random_snap_name()
129+ self.assertTrue(self.store.register(snap_name, private=True),
130+ 'Unable to register snap')
131+ # Upload the snap and wait for its processing on server to finish.
132+ tracker = self.store.upload(
133+ snap_name, self.snap_builder.build_and_pull(snap_name, '0.1'))
134+ tracker.track()
135+ self.store.release(snap_name, '1', ['stable'])
136+ self.snapd.install(snap_name)
137+ self.addCleanup(self.snapd.remove, snap_name)
138+ self.assertTrue(self.snapd.is_installed, snap_name)
139
140=== modified file 'snappy_ecosystem_tests/tests/test_register_snap.py'
141--- snappy_ecosystem_tests/tests/test_register_snap.py 2017-02-21 19:06:58 +0000
142+++ snappy_ecosystem_tests/tests/test_register_snap.py 2017-03-16 19:28:32 +0000
143@@ -20,11 +20,10 @@
144
145 """Tests for Registering a snap name in the store"""
146
147-import uuid
148-
149 from snappy_ecosystem_tests.helpers.snapcraft.client import Snapcraft
150 from snappy_ecosystem_tests.helpers.store_apis.rest_apis import Store
151 from snappy_ecosystem_tests.helpers.test_base import SnappyEcosystemTestCase
152+from snappy_ecosystem_tests.tests.commons import get_random_snap_name
153 from snappy_ecosystem_tests.utils.storeconfig import get_store_credentials
154
155
156@@ -39,19 +38,11 @@
157 self.snapcraft.login()
158 self.addCleanup(self.snapcraft.logout)
159
160- @staticmethod
161- def _get_random_snap_name(prefix='ecosystem-test'):
162- """Get a random snap name using uuid
163- :param prefix: the string prefix,
164- if not provided, use default one.
165- """
166- return '{}{}'.format(prefix, int(uuid.uuid4()))
167-
168 def test_register_public_snap_name_using_snapcraft(self):
169 """Test register a public snap name via snapcraft
170 and verify it via REST API"""
171 # Register snap via Snapcraft
172- snap_name = self._get_random_snap_name()
173+ snap_name = get_random_snap_name()
174 self.assertTrue(self.snapcraft.register(snap_name),
175 'Unable to register snap')
176
177@@ -68,7 +59,7 @@
178 """Test register a private snap name via snapcraft
179 and verify it via REST API"""
180 # Register snap via Snapcraft
181- snap_name = self._get_random_snap_name()
182+ snap_name = get_random_snap_name()
183 self.assertTrue(self.snapcraft.register(snap_name, private=True),
184 'Unable to register snap')
185
186@@ -85,7 +76,7 @@
187 """Verify that snapcraft lists a new snap registered via
188 RESTful API when using the command snapcraft list-registered"""
189 # Register snap via API
190- snap_name = self._get_random_snap_name()
191+ snap_name = get_random_snap_name()
192 self.assertTrue(self.store.register(snap_name),
193 'Unable to register snap')
194
195@@ -102,7 +93,7 @@
196 """Verify that snapcraft lists a new private snap registered via
197 RESTful API when using the command snapcraft list-registered"""
198 # Register snap via API
199- snap_name = self._get_random_snap_name()
200+ snap_name = get_random_snap_name()
201 self.assertTrue(self.store.register(snap_name, private=True),
202 'Unable to register snap')
203

Subscribers

People subscribed via source and target branches