Merge lp:~sbaldassin/snappy-ecosystem-tests/ecosystem_deployment into lp:snappy-ecosystem-tests
- ecosystem_deployment
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Omer Akram |
Approved revision: | 27 |
Merged at revision: | 25 |
Proposed branch: | lp:~sbaldassin/snappy-ecosystem-tests/ecosystem_deployment |
Merge into: | lp:snappy-ecosystem-tests |
Diff against target: |
535 lines (+407/-58) 10 files modified
requirements.txt (+1/-1) run_checks (+2/-2) snappy_ecosystem_tests/environment/__init__.py (+19/-0) snappy_ecosystem_tests/environment/constants.py (+66/-0) snappy_ecosystem_tests/environment/data/__init__.py (+19/-0) snappy_ecosystem_tests/environment/data/snapcraft.py (+21/-0) snappy_ecosystem_tests/environment/data/snapd.py (+88/-0) snappy_ecosystem_tests/environment/managers.py (+143/-0) snappy_ecosystem_tests/environment/setup.py (+46/-0) snappy_ecosystem_tests/helpers/snapd/staging_builder.py (+2/-55) |
To merge this branch: | bzr merge lp:~sbaldassin/snappy-ecosystem-tests/ecosystem_deployment |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Omer Akram (community) | Approve | ||
platform-qa-bot | continuous-integration | Approve | |
Heber Parrucci (community) | Approve | ||
prod-platform-qa | continuous-integration | Pending | |
Review via email: mp+318018@code.launchpad.net |
Commit message
Scripts to build a couple of lxd containers to deploy snapcraft and snapd
Description of the change
Scripts to build a couple of lxd containers to deploy snapcraft and snapd
platform-qa-bot (platform-qa-bot) wrote : | # |
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Heber Parrucci (heber013) wrote : | # |
Comments inline.
Additionally:
* We already have in trunk some code for building a snapd container for staging:
snappy_
and some container helpers:
snappy_
Some parts of that code seem to overlap with this changes. My suggestion is to merge that code with yours to have one place for building containers.
Update the README with instructions to build the environment.
Add logging to see the activities and progress while building the containers... When I run the setup I just see the cursor for some minutes and have no idea what is happening behind the scene.
I am getting an error when executing the setup: http://
When it tries to enable ssh, it tries to put the public key in the container, and it seems that the file /home/ubuntu/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:18
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 19. By Santiago Baldassin
-
Addressing comments from the reviews
Santiago Baldassin (sbaldassin) wrote : | # |
All comments addressed
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:19
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
I Ahmad (iahmad) wrote : | # |
Could this be landed soon as heber's other mp is waiting on it. Please update readme with instructions before landing.
Omer Akram (om26er) wrote : | # |
Minor cosmetic review. Need to do a thorough review later.
Omer Akram (om26er) : | # |
- 20. By Santiago Baldassin
-
Fixing the script
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:20
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Santiago Baldassin (sbaldassin) wrote : | # |
Thanks Omer. All comments were addressed
- 21. By Santiago Baldassin
-
Addressing comments from the reviews
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:21
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 22. By Santiago Baldassin
-
Merge from trunk
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:22
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 23. By Santiago Baldassin
-
Adding a get_ip api
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:23
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 24. By Santiago Baldassin
-
Minor fix
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:24
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 25. By Santiago Baldassin
-
Minor change
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:25
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 26. By Santiago Baldassin
-
fixing pylint
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:26
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Omer Akram (om26er) wrote : | # |
I have done the code review of the LxdManager class. The problems that were previously mentioned for the Container class were either non existent(for example a container getting out of sync, found after more research, pylxd is intelligent), or duplicate object creation, which I explained in a separate email, detailed, that its not an issue on the memory as we were only passing in a reference to an already existing object and the one that we were passing that object to was not more than the size of an empty object (a class that inherits from object but does not add any override methods).
Santiago Baldassin (sbaldassin) wrote : | # |
> I have done the code review of the LxdManager class. The problems that were
> previously mentioned for the Container class were either non existent(for
> example a container getting out of sync, found after more research, pylxd is
> intelligent), or duplicate object creation, which I explained in a separate
> email, detailed, that its not an issue on the memory as we were only passing
> in a reference to an already existing object and the one that we were passing
> that object to was not more than the size of an empty object (a class that
> inherits from object but does not add any override methods).
Let's go through the approach over the phone. Heber and I clearly agree that the best course of action is to use a manager and to avoid the use of the Container class. Once agreed on the approach we'll get rid of the either the manager or the container class to avoid code duplication
Omer Akram (om26er) wrote : | # |
Phone call sounds good to me and as an added bonus this is what the new(lean) code would look like: http://
I do understand that you have certain preference for the "manager" paradigm but in this specific case that doesn't feel like solving any problem :)
- 27. By Santiago Baldassin
-
Minor fix
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:27
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'requirements.txt' |
2 | --- requirements.txt 2017-02-21 21:07:33 +0000 |
3 | +++ requirements.txt 2017-03-03 10:19:52 +0000 |
4 | @@ -14,7 +14,7 @@ |
5 | pexpect |
6 | pymacaroons==0.9.2 |
7 | requests-toolbelt==0.6.0 |
8 | -#chromedriver_installer |
9 | pylxd |
10 | pyyaml |
11 | +retrying |
12 | paramiko |
13 | |
14 | === modified file 'run_checks' |
15 | --- run_checks 2017-02-20 13:10:18 +0000 |
16 | +++ run_checks 2017-03-03 10:19:52 +0000 |
17 | @@ -51,9 +51,9 @@ |
18 | |
19 | if [ "$proxy" ]; then |
20 | echo "Using proxy: $proxy to install dependencies" |
21 | - pip install --proxy $proxy -r requirements-unit-tests.txt |
22 | + pip3 install --proxy $proxy -r requirements-unit-tests.txt |
23 | else |
24 | - pip install -r requirements-unit-tests.txt |
25 | + pip3 install -r requirements-unit-tests.txt |
26 | fi |
27 | |
28 | ve_unit_tests/bin/python3 -m unittest discover snappy_ecosystem_tests.unittests |
29 | |
30 | === added directory 'snappy_ecosystem_tests/environment' |
31 | === added file 'snappy_ecosystem_tests/environment/__init__.py' |
32 | --- snappy_ecosystem_tests/environment/__init__.py 1970-01-01 00:00:00 +0000 |
33 | +++ snappy_ecosystem_tests/environment/__init__.py 2017-03-03 10:19:52 +0000 |
34 | @@ -0,0 +1,19 @@ |
35 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
36 | + |
37 | +# |
38 | +# Snappy Ecosystem Tests |
39 | +# Copyright (C) 2017 Canonical |
40 | +# |
41 | +# This program is free software: you can redistribute it and/or modify |
42 | +# it under the terms of the GNU General Public License as published by |
43 | +# the Free Software Foundation, either version 3 of the License, or |
44 | +# (at your option) any later version. |
45 | +# |
46 | +# This program is distributed in the hope that it will be useful, |
47 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
48 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
49 | +# GNU General Public License for more details. |
50 | +# |
51 | +# You should have received a copy of the GNU General Public License |
52 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
53 | +# |
54 | |
55 | === added file 'snappy_ecosystem_tests/environment/constants.py' |
56 | --- snappy_ecosystem_tests/environment/constants.py 1970-01-01 00:00:00 +0000 |
57 | +++ snappy_ecosystem_tests/environment/constants.py 2017-03-03 10:19:52 +0000 |
58 | @@ -0,0 +1,66 @@ |
59 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
60 | + |
61 | +# |
62 | +# Snappy Ecosystem Tests |
63 | +# Copyright (C) 2017 Canonical |
64 | +# |
65 | +# This program is free software: you can redistribute it and/or modify |
66 | +# it under the terms of the GNU General Public License as published by |
67 | +# the Free Software Foundation, either version 3 of the License, or |
68 | +# (at your option) any later version. |
69 | +# |
70 | +# This program is distributed in the hope that it will be useful, |
71 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
72 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
73 | +# GNU General Public License for more details. |
74 | +# |
75 | +# You should have received a copy of the GNU General Public License |
76 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
77 | +# |
78 | + |
79 | +"""Constants used accross the environment setup""" |
80 | + |
81 | +SNAPD = 'snapd' |
82 | +SNAPCRAFT = 'snapcraft' |
83 | + |
84 | +DEPENDENCIES = { |
85 | + SNAPD : [], |
86 | + SNAPCRAFT : [], |
87 | + "shared" : ["expect"] |
88 | +} |
89 | + |
90 | +PROFILES = { |
91 | + "staging":{ |
92 | + SNAPD:{ |
93 | + "channel": "xenial", |
94 | + "package_name": 'snapd', |
95 | + "environment_variables": { |
96 | + "UBUNTU_STORE_API_ROOT_URL": |
97 | + "https://myapps.developer.ubuntu.com/dev/api/", |
98 | + "UBUNTU_STORE_UPLOAD_ROOT_URL": |
99 | + "https://upload.apps.ubuntu.com", |
100 | + "UBUNTU_SSO_API_ROOT_URL": |
101 | + "https://login.ubuntu.com/api/v2/", |
102 | + "UBUNTU_STORE_SEARCH_ROOT_URL": |
103 | + "https://search.apps.ubuntu.com/" |
104 | + } |
105 | + }, |
106 | + SNAPCRAFT: { |
107 | + "channel": "xenial", |
108 | + "package_name": 'snapcraft', |
109 | + "environment_variables": { |
110 | + "UBUNTU_STORE_API_ROOT_URL": |
111 | + "https://myapps.developer.ubuntu.com/dev/api/", |
112 | + "UBUNTU_STORE_UPLOAD_ROOT_URL": |
113 | + "https://upload.apps.ubuntu.com", |
114 | + "UBUNTU_SSO_API_ROOT_URL": |
115 | + "https://login.ubuntu.com/api/v2/", |
116 | + "UBUNTU_STORE_SEARCH_ROOT_URL": |
117 | + "https://search.apps.ubuntu.com/" |
118 | + } |
119 | + }, |
120 | + "snapweb":{ |
121 | + "url": "https://myapps.developer.ubuntu.com/" |
122 | + }, |
123 | + } |
124 | +} |
125 | |
126 | === added directory 'snappy_ecosystem_tests/environment/data' |
127 | === added file 'snappy_ecosystem_tests/environment/data/__init__.py' |
128 | --- snappy_ecosystem_tests/environment/data/__init__.py 1970-01-01 00:00:00 +0000 |
129 | +++ snappy_ecosystem_tests/environment/data/__init__.py 2017-03-03 10:19:52 +0000 |
130 | @@ -0,0 +1,19 @@ |
131 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
132 | + |
133 | +# |
134 | +# Snappy Ecosystem Tests |
135 | +# Copyright (C) 2017 Canonical |
136 | +# |
137 | +# This program is free software: you can redistribute it and/or modify |
138 | +# it under the terms of the GNU General Public License as published by |
139 | +# the Free Software Foundation, either version 3 of the License, or |
140 | +# (at your option) any later version. |
141 | +# |
142 | +# This program is distributed in the hope that it will be useful, |
143 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
144 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
145 | +# GNU General Public License for more details. |
146 | +# |
147 | +# You should have received a copy of the GNU General Public License |
148 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
149 | +# |
150 | |
151 | === added file 'snappy_ecosystem_tests/environment/data/snapcraft.py' |
152 | --- snappy_ecosystem_tests/environment/data/snapcraft.py 1970-01-01 00:00:00 +0000 |
153 | +++ snappy_ecosystem_tests/environment/data/snapcraft.py 2017-03-03 10:19:52 +0000 |
154 | @@ -0,0 +1,21 @@ |
155 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
156 | + |
157 | +# |
158 | +# Snappy Ecosystem Tests |
159 | +# Copyright (C) 2017 Canonical |
160 | +# |
161 | +# This program is free software: you can redistribute it and/or modify |
162 | +# it under the terms of the GNU General Public License as published by |
163 | +# the Free Software Foundation, either version 3 of the License, or |
164 | +# (at your option) any later version. |
165 | +# |
166 | +# This program is distributed in the hope that it will be useful, |
167 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
168 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
169 | +# GNU General Public License for more details. |
170 | +# |
171 | +# You should have received a copy of the GNU General Public License |
172 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
173 | +# |
174 | +"""Snapcraft data""" |
175 | +SNAPCRAFT_CONTAINER_NAME = 'snapcraft' |
176 | |
177 | === added file 'snappy_ecosystem_tests/environment/data/snapd.py' |
178 | --- snappy_ecosystem_tests/environment/data/snapd.py 1970-01-01 00:00:00 +0000 |
179 | +++ snappy_ecosystem_tests/environment/data/snapd.py 2017-03-03 10:19:52 +0000 |
180 | @@ -0,0 +1,88 @@ |
181 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
182 | + |
183 | +# |
184 | +# Snappy Ecosystem Tests |
185 | +# Copyright (C) 2017 Canonical |
186 | +# |
187 | +# This program is free software: you can redistribute it and/or modify |
188 | +# it under the terms of the GNU General Public License as published by |
189 | +# the Free Software Foundation, either version 3 of the License, or |
190 | +# (at your option) any later version. |
191 | +# |
192 | +# This program is distributed in the hope that it will be useful, |
193 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
194 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
195 | +# GNU General Public License for more details. |
196 | +# |
197 | +# You should have received a copy of the GNU General Public License |
198 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
199 | +# |
200 | +"""snapd data""" |
201 | +SNAPD_CONTAINER_NAME = 'snapd' |
202 | + |
203 | +CONTAINER_HOME = '/root' |
204 | +DIRECTORY_CLONE = '{}/src/github.com/snapcore/snapd'.format(CONTAINER_HOME) |
205 | +DOMAIN_PING = 'ubuntu.com' |
206 | +ENV_STORE_API_ROOT = 'UBUNTU_STORE_API_ROOT_URL' |
207 | +ENV_STORE_SEARCH_ROOT = 'UBUNTU_STORE_SEARCH_ROOT_URL' |
208 | +ENV_STORE_UPLOAD_ROOT = 'UBUNTU_STORE_UPLOAD_ROOT_URL' |
209 | +ENV_SSO_API_ROOT = 'UBUNTU_SSO_API_ROOT_URL' |
210 | +PACKAGES_SNAPD = ['snapd', 'snap-confine', 'ubuntu-core-launcher'] |
211 | +COMMAND_REMOVE_SNAPD = 'apt purge -y {}'.format(' '.join(PACKAGES_SNAPD)) |
212 | +COMMAND_APT_BUILD_DEP = 'apt build-dep -y ./' |
213 | +COMMAND_APT_INSTALL = 'apt install -y {}' |
214 | +COMMAND_APT_INSTALL_STAGING_DEBS = COMMAND_APT_INSTALL.format( |
215 | + ' '.join(['../{}*.deb'.format(pkg) for pkg in PACKAGES_SNAPD])) |
216 | +COMMAND_APT_UPDATE = 'apt update' |
217 | +COMMAND_APT_UPGRADE = 'apt dist-upgrade -y' |
218 | +COMMAND_BUILD_SNAPD = 'DEB_BUILD_OPTIONS="nocheck testkeys" ' \ |
219 | + 'dpkg-buildpackage -tc -b' |
220 | +COMMAND_EXPORT_STAGING_STORE_VAR = 'echo SNAPPY_USE_STAGING_STORE=1 >> ' \ |
221 | + '/etc/environment' |
222 | +COMMAND_GET_GOVENDOR = 'go get -v github.com/kardianos/govendor' |
223 | +COMMAND_GIT_CLONE = 'git clone {} {}' |
224 | +COMMAND_GOVENDOR_SYNC = 'govendor sync' |
225 | +REPOSITORY_GIT = 'https://github.com/snapcore/snapd' |
226 | +URL_API_ROOT = 'https://myapps.developer.staging.ubuntu.com/dev/api/' |
227 | +URL_SEARCH_ROOT = 'https://search.apps.staging.ubuntu.com/' |
228 | +URL_UPLOAD_ROOT = 'https://upload.apps.staging.ubuntu.com/' |
229 | +URL_SSO_API_ROOT = 'https://login.staging.ubuntu.com/api/v2/' |
230 | + |
231 | +CONTAINER_SETUP = [ |
232 | + COMMAND_REMOVE_SNAPD, |
233 | + COMMAND_APT_UPDATE, |
234 | + # Hold open-iscsi which is causing apt upgrade errors while running |
235 | + # inside container. |
236 | + 'apt-mark hold open-iscsi', |
237 | + COMMAND_APT_UPGRADE, |
238 | + # Needed for snaps to work inside a lxd container |
239 | + # ref: https://stgraber.org/2016/12/07/running-snaps-in-lxd-containers/ |
240 | + COMMAND_APT_INSTALL.format('squashfuse'), |
241 | + COMMAND_GIT_CLONE.format(REPOSITORY_GIT, DIRECTORY_CLONE), |
242 | + {'command': COMMAND_APT_BUILD_DEP, 'cwd': DIRECTORY_CLONE}, |
243 | + {'command': COMMAND_GET_GOVENDOR, 'cwd': DIRECTORY_CLONE}, |
244 | + {'command': COMMAND_GOVENDOR_SYNC, 'cwd': DIRECTORY_CLONE}, |
245 | + {'command': COMMAND_BUILD_SNAPD, 'cwd': DIRECTORY_CLONE}, |
246 | + COMMAND_EXPORT_STAGING_STORE_VAR, |
247 | + {'command': COMMAND_APT_INSTALL_STAGING_DEBS, 'cwd': DIRECTORY_CLONE} |
248 | +] |
249 | + |
250 | +CONTAINER_ENV_VARS = { |
251 | + 'GOPATH': CONTAINER_HOME, |
252 | + 'SNAPPY_USE_STAGING_STORE': '1', |
253 | + ENV_STORE_API_ROOT: URL_API_ROOT, |
254 | + ENV_STORE_SEARCH_ROOT: URL_SEARCH_ROOT, |
255 | + ENV_STORE_UPLOAD_ROOT: URL_UPLOAD_ROOT, |
256 | + ENV_SSO_API_ROOT: URL_SSO_API_ROOT, |
257 | +} |
258 | + |
259 | +DEFAULT_CONTAINER_CONFIG = { |
260 | + "name": "snapd", |
261 | + "source": { |
262 | + "type": "image", |
263 | + "mode": "pull", |
264 | + "server": "https://cloud-images.ubuntu.com/releases", |
265 | + "protocol": "simplestreams", |
266 | + "fingerprint": "16.04" |
267 | + } |
268 | +} |
269 | |
270 | === added file 'snappy_ecosystem_tests/environment/managers.py' |
271 | --- snappy_ecosystem_tests/environment/managers.py 1970-01-01 00:00:00 +0000 |
272 | +++ snappy_ecosystem_tests/environment/managers.py 2017-03-03 10:19:52 +0000 |
273 | @@ -0,0 +1,143 @@ |
274 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
275 | + |
276 | +# |
277 | +# Ubuntu System Tests |
278 | +# Copyright (C) 2017 Canonical |
279 | +# |
280 | +# This program is free software: you can redistribute it and/or modify |
281 | +# it under the terms of the GNU General Public License as published by |
282 | +# the Free Software Foundation, either version 3 of the License, or |
283 | +# (at your option) any later version. |
284 | +# |
285 | +# This program is distributed in the hope that it will be useful, |
286 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
287 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
288 | +# GNU General Public License for more details. |
289 | +# |
290 | +# You should have received a copy of the GNU General Public License |
291 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
292 | +# |
293 | + |
294 | +"""Managers to setup the environment""" |
295 | + |
296 | +import os |
297 | +import shlex |
298 | +from pylxd import Client |
299 | +from pylxd.exceptions import NotFound, LXDAPIException |
300 | +from retrying import retry |
301 | + |
302 | +from snappy_ecosystem_tests.environment import constants |
303 | +from snappy_ecosystem_tests.environment.constants import ( |
304 | + PROFILES, DEPENDENCIES) |
305 | +from snappy_ecosystem_tests.environment.data.snapcraft import ( |
306 | + SNAPCRAFT_CONTAINER_NAME) |
307 | +from snappy_ecosystem_tests.environment.data.snapd import ( |
308 | + DEFAULT_CONTAINER_CONFIG, SNAPD_CONTAINER_NAME) |
309 | + |
310 | +def get_manager(mode): |
311 | + """Get the manager for the given mode""" |
312 | + supported_modules = { |
313 | + "lxd": LxdManager |
314 | + } |
315 | + try: |
316 | + manager = supported_modules[mode] |
317 | + return manager() |
318 | + except KeyError: |
319 | + raise RuntimeError("Mode: {} is not supported".format(mode)) |
320 | + |
321 | + |
322 | +class LxdManager: |
323 | + """Manage lxd containers""" |
324 | + |
325 | + def __init__(self): |
326 | + self.client = Client() |
327 | + |
328 | + def launch(self, container_name, release='16.04'): |
329 | + """Launch a container""" |
330 | + try: |
331 | + container = self.client.containers.get(container_name) |
332 | + if container.status == "Running": |
333 | + container.stop(wait=True) |
334 | + container.delete(wait=True) |
335 | + except NotFound: |
336 | + pass |
337 | + container_config = DEFAULT_CONTAINER_CONFIG.copy() |
338 | + container_config['source']['alias'] = release |
339 | + container_config['name'] = container_name |
340 | + container = self.client.containers.create(container_config, wait=True) |
341 | + container.start(wait=True) |
342 | + |
343 | + def execute_command(self, container_name, command): |
344 | + """execute command""" |
345 | + container = self.client.containers.get(container_name) |
346 | + container.execute(command) |
347 | + |
348 | + def install(self, container_name, packages, channel=None): |
349 | + """Install a packages""" |
350 | + container = self.client.containers.get(container_name) |
351 | + container.execute(shlex.split('apt-get update')) |
352 | + install_command = 'apt-get install {} -y'.format(packages) |
353 | + if channel: |
354 | + install_command += ' -t {}'.format(channel) |
355 | + container.execute(shlex.split(install_command)) |
356 | + |
357 | + def install_dependencies(self, container_name, container_type): |
358 | + """Install a dependencies""" |
359 | + self.install( |
360 | + container_name, |
361 | + DEPENDENCIES[container_type] + DEPENDENCIES['shared']) |
362 | + |
363 | + |
364 | + def configure(self, container_name, container_type, profile): |
365 | + """Configure a given container""" |
366 | + container = self.client.containers.get(container_name) |
367 | + for key, value in \ |
368 | + PROFILES[profile][container_type]['environment_variables'].\ |
369 | + items(): |
370 | + container.config.update({'environment.{}'.format( |
371 | + key): value}) |
372 | + container.save(wait=True) |
373 | + |
374 | + @retry(stop_max_attempt_number=5, wait_fixed=3000, |
375 | + retry_on_exception=lambda exception: isinstance( |
376 | + exception, LXDAPIException)) |
377 | + def enable_ssh(self, container_name): |
378 | + """Enable the ssh connection on the container""" |
379 | + container = self.client.containers.get(container_name) |
380 | + pub_key = open( |
381 | + os.path.expanduser('~') + '/.ssh/id_rsa.pub').read().strip('\n') |
382 | + container.files.put('/home/ubuntu/.ssh/authorized_keys', pub_key) |
383 | + |
384 | + |
385 | + def setup(self, profile): |
386 | + """setup the container based on the profile""" |
387 | + self._setup(SNAPD_CONTAINER_NAME, constants.SNAPD, profile) |
388 | + self._setup( |
389 | + SNAPCRAFT_CONTAINER_NAME, constants.SNAPCRAFT, profile) |
390 | + |
391 | + |
392 | + def _setup(self, container_name, container_type, profile): |
393 | + """ |
394 | + Launch a container, enable ssh, install dependencies |
395 | + and setup the needed environment variables |
396 | + """ |
397 | + self.launch(container_name) |
398 | + self.enable_ssh(container_name) |
399 | + self.install( |
400 | + container_name, |
401 | + packages=PROFILES[profile][container_type]["package_name"], |
402 | + channel=PROFILES[profile][container_type]["channel"]) |
403 | + self.install_dependencies(container_name, container_type) |
404 | + self.configure(container_name, container_type, profile) |
405 | + |
406 | + def get_ip(self, container_name): |
407 | + """Gets the ip address for a given container""" |
408 | + networks = self.client.containers.get( |
409 | + container_name).state().network['eth0']['addresses'] |
410 | + |
411 | + for network in networks: |
412 | + if network['address']: |
413 | + return network['address'] |
414 | + raise RuntimeError( |
415 | + "The container {} does not have an IPV4 connection".format( |
416 | + container_name)) |
417 | |
418 | === added file 'snappy_ecosystem_tests/environment/setup.py' |
419 | --- snappy_ecosystem_tests/environment/setup.py 1970-01-01 00:00:00 +0000 |
420 | +++ snappy_ecosystem_tests/environment/setup.py 2017-03-03 10:19:52 +0000 |
421 | @@ -0,0 +1,46 @@ |
422 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
423 | + |
424 | +# |
425 | +# Ubuntu System Tests |
426 | +# Copyright (C) 2017 Canonical |
427 | +# |
428 | +# This program is free software: you can redistribute it and/or modify |
429 | +# it under the terms of the GNU General Public License as published by |
430 | +# the Free Software Foundation, either version 3 of the License, or |
431 | +# (at your option) any later version. |
432 | +# |
433 | +# This program is distributed in the hope that it will be useful, |
434 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
435 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
436 | +# GNU General Public License for more details. |
437 | +# |
438 | +# You should have received a copy of the GNU General Public License |
439 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
440 | +# |
441 | + |
442 | +"""Standalone script to setup an ecosystem environment""" |
443 | + |
444 | +import argparse |
445 | + |
446 | +import logging |
447 | + |
448 | +from snappy_ecosystem_tests.environment.managers import get_manager |
449 | + |
450 | +logging.basicConfig(level=logging.DEBUG) |
451 | + |
452 | +def main(mode, profile): |
453 | + """Main script""" |
454 | + manager = get_manager(mode) |
455 | + manager.setup(profile) |
456 | + |
457 | + |
458 | +if __name__ == '__main__': |
459 | + PARSER = argparse.ArgumentParser(description= |
460 | + 'Setup a snappy ecosystem environment.') |
461 | + PARSER.add_argument('--mode', default="lxd", |
462 | + help='lxd') |
463 | + PARSER.add_argument('--profile', default="staging", |
464 | + help='Profile to configure the environment') |
465 | + ARGS = PARSER.parse_args() |
466 | + |
467 | + main(ARGS.mode, ARGS.profile) |
468 | |
469 | === modified file 'snappy_ecosystem_tests/helpers/snapd/staging_builder.py' |
470 | --- snappy_ecosystem_tests/helpers/snapd/staging_builder.py 2017-02-21 13:46:08 +0000 |
471 | +++ snappy_ecosystem_tests/helpers/snapd/staging_builder.py 2017-03-03 10:19:52 +0000 |
472 | @@ -24,63 +24,10 @@ |
473 | import sys |
474 | from time import sleep |
475 | |
476 | +from snappy_ecosystem_tests.environment.data.snapd import ( |
477 | + CONTAINER_HOME, CONTAINER_ENV_VARS, CONTAINER_SETUP) |
478 | from snappy_ecosystem_tests.utils.lxd import Container, launch_container |
479 | |
480 | -CONTAINER_HOME = '/root' |
481 | -DIRECTORY_CLONE = '{}/src/github.com/snapcore/snapd'.format(CONTAINER_HOME) |
482 | -ENV_STORE_API_ROOT = 'UBUNTU_STORE_API_ROOT_URL' |
483 | -ENV_STORE_SEARCH_ROOT = 'UBUNTU_STORE_SEARCH_ROOT_URL' |
484 | -ENV_STORE_UPLOAD_ROOT = 'UBUNTU_STORE_UPLOAD_ROOT_URL' |
485 | -ENV_SSO_API_ROOT = 'UBUNTU_SSO_API_ROOT_URL' |
486 | -PACKAGES_SNAPD = ['snapd', 'snap-confine', 'ubuntu-core-launcher'] |
487 | -COMMAND_REMOVE_SNAPD = 'apt purge -y {}'.format(' '.join(PACKAGES_SNAPD)) |
488 | -COMMAND_APT_BUILD_DEP = 'apt build-dep -y ./' |
489 | -COMMAND_APT_INSTALL = 'apt install -y {}' |
490 | -COMMAND_APT_INSTALL_STAGING_DEBS = COMMAND_APT_INSTALL.format( |
491 | - ' '.join(['../{}*.deb'.format(pkg) for pkg in PACKAGES_SNAPD])) |
492 | -COMMAND_APT_UPDATE = 'apt update' |
493 | -COMMAND_APT_UPGRADE = 'apt dist-upgrade -y' |
494 | -COMMAND_BUILD_SNAPD = 'DEB_BUILD_OPTIONS="nocheck testkeys" ' \ |
495 | - 'dpkg-buildpackage -tc -b' |
496 | -COMMAND_EXPORT_STAGING_STORE_VAR = 'echo SNAPPY_USE_STAGING_STORE=1 >> ' \ |
497 | - '/etc/environment' |
498 | -COMMAND_GET_GOVENDOR = 'go get -v github.com/kardianos/govendor' |
499 | -COMMAND_GIT_CLONE = 'git clone {} {}' |
500 | -COMMAND_GOVENDOR_SYNC = 'govendor sync' |
501 | -REPOSITORY_GIT = 'https://github.com/snapcore/snapd' |
502 | -URL_API_ROOT = 'https://myapps.developer.staging.ubuntu.com/dev/api/' |
503 | -URL_SEARCH_ROOT = 'https://search.apps.staging.ubuntu.com/' |
504 | -URL_UPLOAD_ROOT = 'https://upload.apps.staging.ubuntu.com/' |
505 | -URL_SSO_API_ROOT = 'https://login.staging.ubuntu.com/api/v2/' |
506 | - |
507 | -CONTAINER_SETUP = [ |
508 | - COMMAND_REMOVE_SNAPD, |
509 | - COMMAND_APT_UPDATE, |
510 | - # Hold open-iscsi which is causing apt upgrade errors while running |
511 | - # inside container. |
512 | - 'apt-mark hold open-iscsi', |
513 | - COMMAND_APT_UPGRADE, |
514 | - # Needed for snaps to work inside a lxd container |
515 | - # ref: https://stgraber.org/2016/12/07/running-snaps-in-lxd-containers/ |
516 | - COMMAND_APT_INSTALL.format('squashfuse'), |
517 | - COMMAND_GIT_CLONE.format(REPOSITORY_GIT, DIRECTORY_CLONE), |
518 | - {'command': COMMAND_APT_BUILD_DEP, 'cwd': DIRECTORY_CLONE}, |
519 | - {'command': COMMAND_GET_GOVENDOR, 'cwd': DIRECTORY_CLONE}, |
520 | - {'command': COMMAND_GOVENDOR_SYNC, 'cwd': DIRECTORY_CLONE}, |
521 | - {'command': COMMAND_BUILD_SNAPD, 'cwd': DIRECTORY_CLONE}, |
522 | - COMMAND_EXPORT_STAGING_STORE_VAR, |
523 | - {'command': COMMAND_APT_INSTALL_STAGING_DEBS, 'cwd': DIRECTORY_CLONE} |
524 | -] |
525 | - |
526 | -CONTAINER_ENV_VARS = { |
527 | - 'GOPATH': CONTAINER_HOME, |
528 | - 'SNAPPY_USE_STAGING_STORE': '1', |
529 | - ENV_STORE_API_ROOT: URL_API_ROOT, |
530 | - ENV_STORE_SEARCH_ROOT: URL_SEARCH_ROOT, |
531 | - ENV_STORE_UPLOAD_ROOT: URL_UPLOAD_ROOT, |
532 | - ENV_SSO_API_ROOT: URL_SSO_API_ROOT, |
533 | -} |
534 | - |
535 | LOGGER = logging.getLogger(__name__) |
536 | |
537 |
PASSED: Continuous integration, rev:18 /platform- qa-jenkins. ubuntu. com/job/ snappy- ecosystem- tests-ci/ 94/ /platform- qa-jenkins. ubuntu. com/job/ generic- update- mp/1683/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /platform- qa-jenkins. ubuntu. com/job/ snappy- ecosystem- tests-ci/ 94/rebuild
https:/