Merge lp:~canonical-platform-qa/snappy-ecosystem-tests/export-staging-variables-ssh into lp:snappy-ecosystem-tests

Proposed by Omer Akram
Status: Superseded
Proposed branch: lp:~canonical-platform-qa/snappy-ecosystem-tests/export-staging-variables-ssh
Merge into: lp:snappy-ecosystem-tests
Diff against target: 1658 lines (+1185/-111)
30 files modified
README.rst (+12/-7)
pylint.cfg (+4/-4)
requirements-unit-tests.txt (+1/-1)
requirements.txt (+2/-1)
run_checks (+2/-2)
run_system_tests (+1/-0)
snappy_ecosystem_tests/configs/ecosystem_tests.cfg (+8/-3)
snappy_ecosystem_tests/environment/__init__.py (+19/-0)
snappy_ecosystem_tests/environment/constants.py (+82/-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 (+142/-0)
snappy_ecosystem_tests/environment/setup.py (+46/-0)
snappy_ecosystem_tests/helpers/snapcraft/client.py (+164/-23)
snappy_ecosystem_tests/helpers/snapd/snapd.py (+5/-1)
snappy_ecosystem_tests/helpers/snapd/staging_builder.py (+11/-4)
snappy_ecosystem_tests/helpers/store_apis/rest_apis.py (+51/-6)
snappy_ecosystem_tests/models/__init__.py (+19/-0)
snappy_ecosystem_tests/models/snap.py (+39/-0)
snappy_ecosystem_tests/run.py (+24/-14)
snappy_ecosystem_tests/tests/test_register_snap.py (+116/-0)
snappy_ecosystem_tests/unittests/test_filters.py (+113/-0)
snappy_ecosystem_tests/unittests/test_snapcraft.py (+0/-31)
snappy_ecosystem_tests/utils/commands.py (+31/-0)
snappy_ecosystem_tests/utils/filters.py (+51/-0)
snappy_ecosystem_tests/utils/ssh.py (+7/-2)
snappy_ecosystem_tests/utils/store_versions.py (+74/-0)
snappy_ecosystem_tests/utils/storeconfig.py (+2/-2)
snappy_ecosystem_tests/utils/user.py (+31/-10)
To merge this branch: bzr merge lp:~canonical-platform-qa/snappy-ecosystem-tests/export-staging-variables-ssh
Reviewer Review Type Date Requested Status
platform-qa-bot continuous-integration Approve
Snappy ecosystem tests developer Pending
Review via email: mp+318728@code.launchpad.net

This proposal has been superseded by a proposal from 2017-03-02.

Commit message

Export staging variables over ssh.

Description of the change

Ensure staging environment variables are available over ssh.

To post a comment you must log in.
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote :

By default ssh is secure and does not allow any random environment variable to be exported. So the ssh config within the container also needs to be updated to allow these variables to be exported.

That can be enabled by container setup script. We basically need to append staging environment variable names to AcceptEnv key inside /etc/ssh/sshd_config. OR if we just want to put this variables inside /etc/environment while we setup the container, that would work, though I am not a fan of that.

For testing just update the AcceptEnv line in the container to

AcceptEnv *

Revision history for this message
Omer Akram (om26er) wrote :

(and restart the container)

25. By Omer Akram

merge with trunk

26. By Omer Akram

Finish rebase

27. By Omer Akram

fix

28. By Omer Akram

fix per suggestion

29. By Omer Akram

merge with pre-req

30. By Omer Akram

ignore arguments-differ pylint warning

31. By Omer Akram

merge with trunk

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README.rst'
--- README.rst 2017-02-22 17:40:11 +0000
+++ README.rst 2017-03-02 10:45:12 +0000
@@ -69,17 +69,22 @@
69[user]69[user]
70user_email=^USER_NAME^70user_email=^USER_NAME^
71user_password=^USER_PASSWORD^71user_password=^USER_PASSWORD^
72hostname_remote=^SSH_HOSTNAME^72snapd_hostname_remote=^SNAPD_SSH_HOSTNAME^
73username_remote=^SSH_USERNAME^73snapd_username_remote=^SNAPD_SSH_USERNAME^
74port_remote=^SSH_PORT^74snapd_port_remote=^SNAPD_SSH_PORT^
75snapcraft_hostname_remote=^SNAPCRAFT_SSH_HOSTNAME^
76snapcraft_username_remote=^SNAPCRAFT_SSH_USERNAME^
77snapcraft_port_remote=^SNAPCRAFT_SSH_PORT^
7578
76option 2 - Set the following environment variables:79option 2 - Set the following environment variables:
77user_email=^USER_NAME^80user_email=^USER_NAME^
78user_password=^USER_PASSWORD^81user_password=^USER_PASSWORD^
79hostname_remote=^SSH_HOSTNAME^82snapd_hostname_remote=^SNAPD_SSH_HOSTNAME^
80username_remote=^SSH_USERNAME^83snapd_username_remote=^SNAPD_SSH_USERNAME^
81port_remote=^SSH_PORT^84snapd_port_remote=^SNAPD_SSH_PORT^
8285snapcraft_hostname_remote=^SNAPCRAFT_SSH_HOSTNAME^
86snapcraft_username_remote=^SNAPCRAFT_SSH_USERNAME^
87snapcraft_port_remote=^SNAPCRAFT_SSH_PORT^
8388
84Changing store:89Changing store:
85===============90===============
8691
=== modified file 'pylint.cfg'
--- pylint.cfg 2017-02-21 13:46:08 +0000
+++ pylint.cfg 2017-03-02 10:45:12 +0000
@@ -169,10 +169,10 @@
169inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$169inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
170170
171# Regular expression matching correct function names171# Regular expression matching correct function names
172function-rgx=[a-z_][a-z0-9_]{2,30}$172function-rgx=[a-z_][a-z0-9_]{2,40}$
173173
174# Naming hint for function names174# Naming hint for function names
175function-name-hint=[a-z_][a-z0-9_]{2,30}$175function-name-hint=[a-z_][a-z0-9_]{2,40}$
176176
177# Regular expression matching correct attribute names177# Regular expression matching correct attribute names
178attr-rgx=[a-z_][a-z0-9_]{2,30}$178attr-rgx=[a-z_][a-z0-9_]{2,30}$
@@ -181,10 +181,10 @@
181attr-name-hint=[a-z_][a-z0-9_]{2,30}$181attr-name-hint=[a-z_][a-z0-9_]{2,30}$
182182
183# Regular expression matching correct method names183# Regular expression matching correct method names
184method-rgx=[a-z_][a-z0-9_]{2,30}$|setUp|tearDown184method-rgx=[a-z_][a-z0-9_]{2,30}$|setUp|tearDown|test_*
185185
186# Naming hint for method names186# Naming hint for method names
187method-name-hint=[a-z_][a-z0-9_]{2,30}$|setUp|tearDown187method-name-hint=[a-z_][a-z0-9_]{2,30}$|setUp|tearDown|test_*
188188
189# Regular expression matching correct class attribute names189# Regular expression matching correct class attribute names
190class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$190class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
191191
=== modified file 'requirements-unit-tests.txt'
--- requirements-unit-tests.txt 2017-02-10 18:18:45 +0000
+++ requirements-unit-tests.txt 2017-03-02 10:45:12 +0000
@@ -1,1 +1,1 @@
1unittest21testtools
22
=== modified file 'requirements.txt'
--- requirements.txt 2017-02-21 21:07:33 +0000
+++ requirements.txt 2017-03-02 10:45:12 +0000
@@ -14,7 +14,8 @@
14pexpect14pexpect
15pymacaroons==0.9.215pymacaroons==0.9.2
16requests-toolbelt==0.6.016requests-toolbelt==0.6.0
17#chromedriver_installer
18pylxd17pylxd
19pyyaml18pyyaml
19retrying
20paramiko20paramiko
21chromedriver_installer
2122
=== modified file 'run_checks'
--- run_checks 2017-02-20 13:10:18 +0000
+++ run_checks 2017-03-02 10:45:12 +0000
@@ -51,9 +51,9 @@
5151
52 if [ "$proxy" ]; then52 if [ "$proxy" ]; then
53 echo "Using proxy: $proxy to install dependencies"53 echo "Using proxy: $proxy to install dependencies"
54 pip install --proxy $proxy -r requirements-unit-tests.txt54 pip3 install --proxy $proxy -r requirements-unit-tests.txt
55 else55 else
56 pip install -r requirements-unit-tests.txt56 pip3 install -r requirements-unit-tests.txt
57 fi57 fi
5858
59 ve_unit_tests/bin/python3 -m unittest discover snappy_ecosystem_tests.unittests 59 ve_unit_tests/bin/python3 -m unittest discover snappy_ecosystem_tests.unittests
6060
=== modified file 'run_system_tests'
--- run_system_tests 2017-02-13 16:00:04 +0000
+++ run_system_tests 2017-03-02 10:45:12 +0000
@@ -20,6 +20,7 @@
2020
21. ./mk-venv "$@"21. ./mk-venv "$@"
2222
23ve/bin/python3 ./snappy_ecosystem_tests/utils/store_versions.py
23ve/bin/python3 ./snappy_ecosystem_tests/run.py "$@" -c snappy_ecosystem_tests/configs/pytest.cfg --ignore snappy_ecosystem_tests/unittests/ --junitxml snappy-ecosystem-results.xml24ve/bin/python3 ./snappy_ecosystem_tests/run.py "$@" -c snappy_ecosystem_tests/configs/pytest.cfg --ignore snappy_ecosystem_tests/unittests/ --junitxml snappy-ecosystem-results.xml
2425
25deactivate26deactivate
2627
=== modified file 'snappy_ecosystem_tests/configs/ecosystem_tests.cfg'
--- snappy_ecosystem_tests/configs/ecosystem_tests.cfg 2017-02-10 19:20:45 +0000
+++ snappy_ecosystem_tests/configs/ecosystem_tests.cfg 2017-03-02 10:45:12 +0000
@@ -1,7 +1,5 @@
1[web-ui]1[selenium]
2browser=chrome2browser=chrome
3stage_url=https://myapps.developer.staging.ubuntu.com/
4production_url=https://myapps.developer.ubuntu.com/
53
6[store]4[store]
7# store to use in tests. Possible values: staging or production5# store to use in tests. Possible values: staging or production
@@ -12,9 +10,16 @@
12upload=https://upload.apps.staging.ubuntu.com/10upload=https://upload.apps.staging.ubuntu.com/
13sso=https://login.staging.ubuntu.com/api/v2/11sso=https://login.staging.ubuntu.com/api/v2/
14search=https://search.apps.staging.ubuntu.com/12search=https://search.apps.staging.ubuntu.com/
13web=https://myapps.developer.staging.ubuntu.com/
1514
16[production_urls]15[production_urls]
17root_api=https://myapps.developer.ubuntu.com/dev/api/16root_api=https://myapps.developer.ubuntu.com/dev/api/
18upload=https://upload.apps.ubuntu.com/17upload=https://upload.apps.ubuntu.com/
19sso=https://login.ubuntu.com/api/v2/18sso=https://login.ubuntu.com/api/v2/
20search=https://search.apps.ubuntu.com/19search=https://search.apps.ubuntu.com/
20web=https://myapps.developer.ubuntu.com/
21
22[time_between_registrations]
23# Time in seconds between each snap registration
24staging=10
25production=180
2126
=== added directory 'snappy_ecosystem_tests/environment'
=== added file 'snappy_ecosystem_tests/environment/__init__.py'
--- snappy_ecosystem_tests/environment/__init__.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/environment/__init__.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,19 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
020
=== added file 'snappy_ecosystem_tests/environment/constants.py'
--- snappy_ecosystem_tests/environment/constants.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/environment/constants.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,82 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Constants used accross the environment setup"""
22
23SNAPD = 'snapd'
24SNAPCRAFT = 'snapcraft'
25
26DEPENDENCIES = {
27 SNAPD : [],
28 SNAPCRAFT : [],
29 "shared" : ["expect"]
30}
31
32PROFILES = {
33 "staging":{
34 SNAPD:{
35 "channel": "xenial",
36 "package_name": 'snapd',
37 "environment_variables": [
38 {
39 "name": "UBUNTU_STORE_API_ROOT_URL",
40 "value": "https://myapps.developer.ubuntu.com/dev/api/"
41 },
42 {
43 "name": "UBUNTU_STORE_UPLOAD_ROOT_URL",
44 "value": "https://upload.apps.ubuntu.com"
45 },
46 {
47 "name":"UBUNTU_SSO_API_ROOT_URL",
48 "value":"https://login.ubuntu.com/api/v2/"
49 },
50 {
51 "name":"UBUNTU_STORE_SEARCH_ROOT_URL",
52 "value":"https://search.apps.ubuntu.com/"
53 }
54 ]
55 },
56 SNAPCRAFT: {
57 "channel": "xenial",
58 "package_name": 'snapcraft',
59 "environment_variables": [
60 {
61 "name": "UBUNTU_STORE_API_ROOT_URL",
62 "value": "https://myapps.developer.ubuntu.com/dev/api/"
63 },
64 {
65 "name": "UBUNTU_STORE_UPLOAD_ROOT_URL",
66 "value": "https://upload.apps.ubuntu.com"
67 },
68 {
69 "name":"UBUNTU_SSO_API_ROOT_URL",
70 "value":"https://login.ubuntu.com/api/v2/"
71 },
72 {
73 "name":"UBUNTU_STORE_SEARCH_ROOT_URL",
74 "value":"https://search.apps.ubuntu.com/"
75 }
76 ]
77 },
78 "snapweb":{
79 "url": "https://myapps.developer.ubuntu.com/"
80 },
81 }
82}
083
=== added directory 'snappy_ecosystem_tests/environment/data'
=== added file 'snappy_ecosystem_tests/environment/data/__init__.py'
--- snappy_ecosystem_tests/environment/data/__init__.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/environment/data/__init__.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,19 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
020
=== added file 'snappy_ecosystem_tests/environment/data/snapcraft.py'
--- snappy_ecosystem_tests/environment/data/snapcraft.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/environment/data/snapcraft.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,21 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20"""Snapcraft data"""
21SNAPCRAFT_CONTAINER_NAME = 'snapcraft'
022
=== added file 'snappy_ecosystem_tests/environment/data/snapd.py'
--- snappy_ecosystem_tests/environment/data/snapd.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/environment/data/snapd.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,88 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20"""snapd data"""
21SNAPD_CONTAINER_NAME = 'snapd'
22
23CONTAINER_HOME = '/root'
24DIRECTORY_CLONE = '{}/src/github.com/snapcore/snapd'.format(CONTAINER_HOME)
25DOMAIN_PING = 'ubuntu.com'
26ENV_STORE_API_ROOT = 'UBUNTU_STORE_API_ROOT_URL'
27ENV_STORE_SEARCH_ROOT = 'UBUNTU_STORE_SEARCH_ROOT_URL'
28ENV_STORE_UPLOAD_ROOT = 'UBUNTU_STORE_UPLOAD_ROOT_URL'
29ENV_SSO_API_ROOT = 'UBUNTU_SSO_API_ROOT_URL'
30PACKAGES_SNAPD = ['snapd', 'snap-confine', 'ubuntu-core-launcher']
31COMMAND_REMOVE_SNAPD = 'apt purge -y {}'.format(' '.join(PACKAGES_SNAPD))
32COMMAND_APT_BUILD_DEP = 'apt build-dep -y ./'
33COMMAND_APT_INSTALL = 'apt install -y {}'
34COMMAND_APT_INSTALL_STAGING_DEBS = COMMAND_APT_INSTALL.format(
35 ' '.join(['../{}*.deb'.format(pkg) for pkg in PACKAGES_SNAPD]))
36COMMAND_APT_UPDATE = 'apt update'
37COMMAND_APT_UPGRADE = 'apt dist-upgrade -y'
38COMMAND_BUILD_SNAPD = 'DEB_BUILD_OPTIONS="nocheck testkeys" ' \
39 'dpkg-buildpackage -tc -b'
40COMMAND_EXPORT_STAGING_STORE_VAR = 'echo SNAPPY_USE_STAGING_STORE=1 >> ' \
41 '/etc/environment'
42COMMAND_GET_GOVENDOR = 'go get -v github.com/kardianos/govendor'
43COMMAND_GIT_CLONE = 'git clone {} {}'
44COMMAND_GOVENDOR_SYNC = 'govendor sync'
45REPOSITORY_GIT = 'https://github.com/snapcore/snapd'
46URL_API_ROOT = 'https://myapps.developer.staging.ubuntu.com/dev/api/'
47URL_SEARCH_ROOT = 'https://search.apps.staging.ubuntu.com/'
48URL_UPLOAD_ROOT = 'https://upload.apps.staging.ubuntu.com/'
49URL_SSO_API_ROOT = 'https://login.staging.ubuntu.com/api/v2/'
50
51CONTAINER_SETUP = [
52 COMMAND_REMOVE_SNAPD,
53 COMMAND_APT_UPDATE,
54 # Hold open-iscsi which is causing apt upgrade errors while running
55 # inside container.
56 'apt-mark hold open-iscsi',
57 COMMAND_APT_UPGRADE,
58 # Needed for snaps to work inside a lxd container
59 # ref: https://stgraber.org/2016/12/07/running-snaps-in-lxd-containers/
60 COMMAND_APT_INSTALL.format('squashfuse'),
61 COMMAND_GIT_CLONE.format(REPOSITORY_GIT, DIRECTORY_CLONE),
62 {'command': COMMAND_APT_BUILD_DEP, 'cwd': DIRECTORY_CLONE},
63 {'command': COMMAND_GET_GOVENDOR, 'cwd': DIRECTORY_CLONE},
64 {'command': COMMAND_GOVENDOR_SYNC, 'cwd': DIRECTORY_CLONE},
65 {'command': COMMAND_BUILD_SNAPD, 'cwd': DIRECTORY_CLONE},
66 COMMAND_EXPORT_STAGING_STORE_VAR,
67 {'command': COMMAND_APT_INSTALL_STAGING_DEBS, 'cwd': DIRECTORY_CLONE}
68]
69
70CONTAINER_ENV_VARS = {
71 'GOPATH': CONTAINER_HOME,
72 'SNAPPY_USE_STAGING_STORE': '1',
73 ENV_STORE_API_ROOT: URL_API_ROOT,
74 ENV_STORE_SEARCH_ROOT: URL_SEARCH_ROOT,
75 ENV_STORE_UPLOAD_ROOT: URL_UPLOAD_ROOT,
76 ENV_SSO_API_ROOT: URL_SSO_API_ROOT,
77}
78
79DEFAULT_CONTAINER_CONFIG = {
80 "name": "snapd",
81 "source": {
82 "type": "image",
83 "mode": "pull",
84 "server": "https://cloud-images.ubuntu.com/releases",
85 "protocol": "simplestreams",
86 "fingerprint": "16.04"
87 }
88}
089
=== added file 'snappy_ecosystem_tests/environment/managers.py'
--- snappy_ecosystem_tests/environment/managers.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/environment/managers.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,142 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Ubuntu System Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Managers to setup the environment"""
22
23import os
24import shlex
25from pylxd import Client
26from pylxd.exceptions import NotFound, LXDAPIException
27from retrying import retry
28
29from snappy_ecosystem_tests.environment import constants
30from snappy_ecosystem_tests.environment.constants import (
31 PROFILES, DEPENDENCIES)
32from snappy_ecosystem_tests.environment.data.snapcraft import (
33 SNAPCRAFT_CONTAINER_NAME)
34from snappy_ecosystem_tests.environment.data.snapd import (
35 DEFAULT_CONTAINER_CONFIG, SNAPD_CONTAINER_NAME)
36
37def get_manager(mode):
38 """Get the manager for the given mode"""
39 supported_modules = {
40 "lxd": LxdManager
41 }
42 try:
43 manager = supported_modules[mode]
44 return manager()
45 except KeyError:
46 raise RuntimeError("Mode: {} is not supported".format(mode))
47
48
49class LxdManager:
50 """Manage lxd containers"""
51
52 def __init__(self):
53 self.client = Client()
54
55 def launch(self, container_name, release='16.04'):
56 """Launch a container"""
57 try:
58 container = self.client.containers.get(container_name)
59 if container.status == "Running":
60 container.stop(wait=True)
61 container.delete(wait=True)
62 except NotFound:
63 pass
64 container_config = DEFAULT_CONTAINER_CONFIG.copy()
65 container_config['source']['alias'] = release
66 container_config['name'] = container_name
67 container = self.client.containers.create(container_config, wait=True)
68 container.start(wait=True)
69
70 def execute_command(self, container_name, command):
71 """execute command"""
72 container = self.client.containers.get(container_name)
73 container.execute(command)
74
75 def install(self, container_name, packages, channel=None):
76 """Install a packages"""
77 container = self.client.containers.get(container_name)
78 container.execute(shlex.split('apt-get update'))
79 install_command = 'apt-get install {} -y'.format(packages)
80 if channel:
81 install_command += ' -t {}'.format(channel)
82 container.execute(shlex.split(install_command))
83
84 def install_dependencies(self, container_name, container_type):
85 """Install a dependencies"""
86 self.install(
87 container_name,
88 DEPENDENCIES[container_type] + DEPENDENCIES['shared'])
89
90
91 def configure(self, container_name, container_type, profile):
92 """Configure a given container"""
93 container = self.client.containers.get(container_name)
94 for variable in \
95 PROFILES[profile][container_type]['environment_variables']:
96 container.config.update({'environment.{}'.format(
97 variable['name']): variable['value']})
98 container.save(wait=True)
99
100 @retry(stop_max_attempt_number=5, wait_fixed=3000,
101 retry_on_exception=lambda exception: isinstance(
102 exception, LXDAPIException))
103 def enable_ssh(self, container_name):
104 """Enable the ssh connection on the container"""
105 container = self.client.containers.get(container_name)
106 pub_key = open(
107 os.path.expanduser('~') + '/.ssh/id_rsa.pub').read().strip('\n')
108 container.files.put('/home/ubuntu/.ssh/authorized_keys', pub_key)
109
110
111 def setup(self, profile):
112 """setup the container based on the profile"""
113 self._setup(SNAPD_CONTAINER_NAME, constants.SNAPD, profile)
114 self._setup(
115 SNAPCRAFT_CONTAINER_NAME, constants.SNAPCRAFT, profile)
116
117
118 def _setup(self, container_name, container_type, profile):
119 """
120 Launch a container, enable ssh, install dependencies
121 and setup the needed environment variables
122 """
123 self.launch(container_name)
124 self.enable_ssh(container_name)
125 self.install(
126 container_name,
127 packages=PROFILES[profile][container_type]["package_name"],
128 channel=PROFILES[profile][container_type]["channel"])
129 self.install_dependencies(container_name, container_type)
130 self.configure(container_name, container_type, profile)
131
132 def get_ip(self, container_name):
133 """Gets the ip address for a given container"""
134 networks = self.client.containers.get(
135 container_name).state().network['eth0']['addresses']
136
137 for network in networks:
138 if network['address']:
139 return network['address']
140 raise RuntimeError(
141 "The container {} does not have an IPV4 connection".format(
142 container_name))
0143
=== added file 'snappy_ecosystem_tests/environment/setup.py'
--- snappy_ecosystem_tests/environment/setup.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/environment/setup.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,46 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Ubuntu System Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Standalone script to setup an ecosystem environment"""
22
23import argparse
24
25import logging
26
27from snappy_ecosystem_tests.environment.managers import get_manager
28
29logging.basicConfig(level=logging.DEBUG)
30
31def main(mode, profile):
32 """Main script"""
33 manager = get_manager(mode)
34 manager.setup(profile)
35
36
37if __name__ == '__main__':
38 PARSER = argparse.ArgumentParser(description=
39 'Setup a snappy ecosystem environment.')
40 PARSER.add_argument('--mode', default="lxd",
41 help='lxd')
42 PARSER.add_argument('--profile', default="staging",
43 help='Profile to configure the environment')
44 ARGS = PARSER.parse_args()
45
46 main(ARGS.mode, ARGS.profile)
047
=== modified file 'snappy_ecosystem_tests/helpers/snapcraft/client.py'
--- snappy_ecosystem_tests/helpers/snapcraft/client.py 2017-02-15 19:35:54 +0000
+++ snappy_ecosystem_tests/helpers/snapcraft/client.py 2017-03-02 10:45:12 +0000
@@ -20,14 +20,49 @@
2020
21"""Snapcraft client helpers"""21"""Snapcraft client helpers"""
2222
23import logging
24import subprocess
25import time
26
23import pexpect27import pexpect
2428
2529from snappy_ecosystem_tests.models.snap import Snap
26# login credentials exported by shell environment30from snappy_ecosystem_tests.utils import ssh
31from snappy_ecosystem_tests.utils.commands import build_command
32from snappy_ecosystem_tests.utils.filters import filter_list
33from snappy_ecosystem_tests.utils.storeconfig import get_current_store
34
35from snappy_ecosystem_tests.commons.config import CONFIG_STACK
36
27from snappy_ecosystem_tests.utils import storeconfig37from snappy_ecosystem_tests.utils import storeconfig
2838
39# login credentials gotten from config file or shell environment
40from snappy_ecosystem_tests.utils.user import (
41 get_snapcraft_remote_host_credentials
42)
43
29LOGIN_EMAIL, LOGIN_PASSWORD = storeconfig.get_store_credentials()44LOGIN_EMAIL, LOGIN_PASSWORD = storeconfig.get_store_credentials()
3045
46# Commands
47PATH_SNAPCRAFT = '/usr/bin/snapcraft'
48COMMANDS_LOGIN = """\
49/usr/bin/expect \
50-c 'spawn {snapcraft} login' \
51-c 'expect Email:' \
52-c 'send {email}\\r' \
53-c 'expect Password:' \
54-c 'send {password}\\r' \
55-c 'interact'\
56"""
57
58COMMAND_LOGOUT = 'logout'
59COMMAND_REGISTER = 'register'
60COMMAND_LIST_REGISTERED = 'list-registered'
61
62LOGGER = logging.getLogger(__name__)
63
64HOSTNAME, USERNAME, PORT = get_snapcraft_remote_host_credentials()
65
3166
32class Snapcraft(object):67class Snapcraft(object):
33 """Contain Snapcraft specific functionality to use via command68 """Contain Snapcraft specific functionality to use via command
@@ -37,13 +72,37 @@
37 self._login = False72 self._login = False
38 self._cleanup()73 self._cleanup()
3974
75 @staticmethod
76 def _run_snapcraft_command_ssh(command, debug=True):
77 """
78 Run snapcraft command via ssh
79 :param command: the command to be executed.
80 Can be a single string or a list of strings
81 :param debug: whether to enable debug mode
82 :return: the command's output
83 """
84 if not command.startswith(PATH_SNAPCRAFT):
85 command = build_snapcraft_command(command)
86 if debug:
87 command += ' -d'
88 return ssh.run_command(command, hostname=HOSTNAME, username=USERNAME,
89 port=PORT)
90
91 def assert_logged_in(self):
92 """Assert that an user is logged.
93 :raise ValueError: in case login is false
94 """
95 if self._login is False:
96 raise ValueError("User is not logged in, "
97 "please login before using this command")
98
40 def _cleanup(self):99 def _cleanup(self):
41 """Perform cleanup actions"""100 """Perform cleanup actions"""
42 self.logout()101 self.logout()
43102
44 def logout(self):103 def logout(self):
45 """logout of snapcraft store session"""104 """logout of snapcraft store session"""
46 child = pexpect.spawn("snapcraft logout")105 child = pexpect.spawn(build_snapcraft_command(COMMAND_LOGOUT))
47 err = child.expect('Credentials cleared.')106 err = child.expect('Credentials cleared.')
48 child.terminate(True)107 child.terminate(True)
49 child.wait()108 child.wait()
@@ -52,23 +111,105 @@
52111
53 self._login = False112 self._login = False
54113
55 def login(self):114 def login(self, email=LOGIN_EMAIL, password=LOGIN_PASSWORD):
56 """login to store using the credential environment variables"""115 """Login to Snapcraft. If email and/or password are not provided,
57 child = pexpect.spawn("snapcraft login")116 use the default ones.
58 child.expect('Email: ')117 :param email: the SSO email
59 child.sendline(LOGIN_EMAIL)118 :param password: the email password
60 child.expect('Password:')119 """
61 child.sendline(LOGIN_PASSWORD)120 output = ssh.run_command(
62 err = child.expect('Login successful')121 COMMANDS_LOGIN.format(email=email, password=password,
63 if err is not 0:122 snapcraft=PATH_SNAPCRAFT),
64 raise ValueError("Failed to login")123 hostname=HOSTNAME, username=USERNAME, port=PORT)
65124 self._login = 'login successful' in output.lower()
66 self._login = True125 return self._login
67126
68 def list_registered(self):127 def list_registered(self, debug=True, raw=False):
69 """call snapcraft list-registered command,128 """Call snapcraft list-registered command,
70 raise exception if not logged in"""129 raise exception if not logged in
71 if self._login is False:130 :param debug: whether to enable debug mode
72 raise ValueError("User is not logged in, "131 :param raw: whether to return the output as a raw.
73 "please login before using this command")132 If False, return a list of Snap instances
74 return pexpect.spawnu("snapcraft list-registered").read()133 """
134 self.assert_logged_in()
135 registered_snaps_output = self._run_snapcraft_command_ssh(
136 COMMAND_LIST_REGISTERED,
137 debug=debug)
138 if raw:
139 return registered_snaps_output
140 else:
141 snaps = registered_snaps_output.splitlines()
142 # if debug is set, the first 3 lines of output are the API calls
143 return parse_snaps_raw(snaps if debug is False else snaps[3:])
144
145 def filter_snaps(self, **predicates):
146 """
147 Return a list of the snaps that match with all the given predicates.
148 Examples:
149 filter_snap() --> return all the snaps
150 filter_snap(name='my_name') --> return the snaps that matches with
151 name 'my_name'
152 filter_snap(name='my_name', private=True) --> return the snaps that
153 matches with name 'my_name' and are private.
154 filter_snap(price='5') --> return the snaps with price '5'.
155 :return: A list of snap instances
156 """
157 return filter_list(self.list_registered(raw=False), **predicates)
158
159 def register(self, snap_name, private=False, wait=True):
160 """
161 Register a snap name in the store.
162 :param snap_name: the snap name to register.
163 :param private: whether the snap name is private.
164 :param wait: wheter to wait after registration to hitting the store
165 restriction on following registrations
166 :return: True if the snap was registered successfully, False otherwise.
167 """
168 self.assert_logged_in()
169 LOGGER.info('About to register snap: %s', snap_name)
170 command = build_snapcraft_command(COMMAND_REGISTER, snap_name)
171 if private:
172 command += ' --private'
173 try:
174 Snapcraft._run_snapcraft_command_ssh(command)
175 except subprocess.CalledProcessError as _e:
176 LOGGER.error('Unable to register snap: %s', _e.output)
177 return False
178 if wait:
179 time.sleep(int(CONFIG_STACK.get('time_between_registrations',
180 get_current_store())))
181 LOGGER.info('Snap %s registered successfully!!!', snap_name)
182 return True
183
184
185def build_snapcraft_command(*args, base_command=PATH_SNAPCRAFT):
186 """
187 Build a snapcraft command with arguments
188 :param args: list of arguments for the command
189 :param base_command: snapcraft executable that is going to be used
190 :return: the snapcraft command ready to be executed
191 """
192 return build_command(base_command, *args)
193
194
195def parse_snaps_raw(raw):
196 """
197 Parse snaps raw output to a list of Snaps object
198 :param raw: the raw that contains the snaps info.
199 It assumes that the first line is the output Header like:
200 (Name, Since, Price, etc.) to get the attributes order.
201 :return: A list of snaps instances
202 """
203 attributes_order = {}
204 for _i, att in enumerate(raw[0].split()):
205 attributes_order[att.lower()] = _i
206 snaps = []
207 for snap_raw in raw[1:]:
208 attrs = snap_raw.split()
209 private = attrs[attributes_order.get('visibility')].lower() == 'private'
210 snaps.append(Snap(name=attrs[attributes_order.get('name')],
211 since=attrs[attributes_order.get('since')],
212 private=private,
213 price=attrs[attributes_order.get('price')],
214 notes=attrs[attributes_order.get('notes')]))
215 return snaps
75216
=== modified file 'snappy_ecosystem_tests/helpers/snapd/snapd.py'
--- snappy_ecosystem_tests/helpers/snapd/snapd.py 2017-02-21 15:17:12 +0000
+++ snappy_ecosystem_tests/helpers/snapd/snapd.py 2017-03-02 10:45:12 +0000
@@ -26,6 +26,7 @@
26import yaml26import yaml
2727
28from snappy_ecosystem_tests.utils import ssh28from snappy_ecosystem_tests.utils import ssh
29from snappy_ecosystem_tests.utils.user import get_snapd_remote_host_credentials
2930
30PATH_SNAP = '/usr/bin/snap'31PATH_SNAP = '/usr/bin/snap'
31COMMAND_DOWNLOAD = 'download {snap} --channel={channel}'32COMMAND_DOWNLOAD = 'download {snap} --channel={channel}'
@@ -47,6 +48,8 @@
47"""48"""
48LOGGER = logging.getLogger(__name__)49LOGGER = logging.getLogger(__name__)
4950
51HOSTNAME, USERNAME, PORT = get_snapd_remote_host_credentials()
52
5053
51def run_snapd_command_ssh(parameters, cwd=''):54def run_snapd_command_ssh(parameters, cwd=''):
52 """Run snapd command over ssh.55 """Run snapd command over ssh.
@@ -59,7 +62,8 @@
59 if cwd:62 if cwd:
60 return ssh.run_command(63 return ssh.run_command(
61 'cd {}; {} {}'.format(cwd, PATH_SNAP, parameters))64 'cd {}; {} {}'.format(cwd, PATH_SNAP, parameters))
62 return ssh.run_command('{} {}'.format(PATH_SNAP, parameters))65 return ssh.run_command('{} {}'.format(PATH_SNAP, parameters),
66 hostname=HOSTNAME, username=USERNAME, port=PORT)
6367
6468
65def login(email, password):69def login(email, password):
6670
=== modified file 'snappy_ecosystem_tests/helpers/snapd/staging_builder.py'
--- snappy_ecosystem_tests/helpers/snapd/staging_builder.py 2017-02-21 13:46:08 +0000
+++ snappy_ecosystem_tests/helpers/snapd/staging_builder.py 2017-03-02 10:45:12 +0000
@@ -24,6 +24,8 @@
24import sys24import sys
25from time import sleep25from time import sleep
2626
27from snappy_ecosystem_tests.environment.data.snapd import (
28 CONTAINER_HOME, CONTAINER_ENV_VARS, CONTAINER_SETUP)
27from snappy_ecosystem_tests.utils.lxd import Container, launch_container29from snappy_ecosystem_tests.utils.lxd import Container, launch_container
2830
29CONTAINER_HOME = '/root'31CONTAINER_HOME = '/root'
@@ -71,15 +73,20 @@
71 COMMAND_EXPORT_STAGING_STORE_VAR,73 COMMAND_EXPORT_STAGING_STORE_VAR,
72 {'command': COMMAND_APT_INSTALL_STAGING_DEBS, 'cwd': DIRECTORY_CLONE}74 {'command': COMMAND_APT_INSTALL_STAGING_DEBS, 'cwd': DIRECTORY_CLONE}
73]75]
7476SNAPCRAFT_STAGING_VARIABLES = {
75CONTAINER_ENV_VARS = {
76 'GOPATH': CONTAINER_HOME,
77 'SNAPPY_USE_STAGING_STORE': '1',
78 ENV_STORE_API_ROOT: URL_API_ROOT,77 ENV_STORE_API_ROOT: URL_API_ROOT,
79 ENV_STORE_SEARCH_ROOT: URL_SEARCH_ROOT,78 ENV_STORE_SEARCH_ROOT: URL_SEARCH_ROOT,
80 ENV_STORE_UPLOAD_ROOT: URL_UPLOAD_ROOT,79 ENV_STORE_UPLOAD_ROOT: URL_UPLOAD_ROOT,
81 ENV_SSO_API_ROOT: URL_SSO_API_ROOT,80 ENV_SSO_API_ROOT: URL_SSO_API_ROOT,
82}81}
82SNAPD_STAGING_VARIABLES = {
83 'SNAPPY_USE_STAGING_STORE': '1'
84}
85STAGING_VARIABLES = dict(
86 SNAPCRAFT_STAGING_VARIABLES, **SNAPD_STAGING_VARIABLES)
87CONTAINER_ENV_VARS = {
88 'GOPATH': CONTAINER_HOME,
89}
8390
84LOGGER = logging.getLogger(__name__)91LOGGER = logging.getLogger(__name__)
8592
8693
=== modified file 'snappy_ecosystem_tests/helpers/store_apis/rest_apis.py'
--- snappy_ecosystem_tests/helpers/store_apis/rest_apis.py 2017-02-17 18:41:32 +0000
+++ snappy_ecosystem_tests/helpers/store_apis/rest_apis.py 2017-03-02 10:45:12 +0000
@@ -45,6 +45,8 @@
45from snappy_ecosystem_tests.helpers.snapcraft.options import ProjectOptions45from snappy_ecosystem_tests.helpers.snapcraft.options import ProjectOptions
46from snappy_ecosystem_tests.helpers.store_apis import errors46from snappy_ecosystem_tests.helpers.store_apis import errors
47from snappy_ecosystem_tests.helpers.store_apis.upload import upload_files47from snappy_ecosystem_tests.helpers.store_apis.upload import upload_files
48from snappy_ecosystem_tests.models.snap import Snap
49from snappy_ecosystem_tests.utils.filters import filter_list
4850
49LOGGER = logging.getLogger(__name__)51LOGGER = logging.getLogger(__name__)
5052
@@ -193,16 +195,28 @@
193 """Get current account information"""195 """Get current account information"""
194 return self._refresh_if_necessary(self.sca.get_account_information)196 return self._refresh_if_necessary(self.sca.get_account_information)
195197
198 def get_registered_snaps(self, series=constants.DEFAULT_SERIES):
199 """Get registered snaps for current user.
200 First refresh macaroon if necessary"""
201 return self._refresh_if_necessary(self.sca.get_registered_snaps,
202 series)
203
204 def filter_snaps(self, series=constants.DEFAULT_SERIES, **predicates):
205 """Filter snaps that match with given predicates
206 First refresh macaroon if necessary"""
207 return self._refresh_if_necessary(self.sca.filter_snaps,
208 series=series, **predicates)
209
196 def register_key(self, account_key_request):210 def register_key(self, account_key_request):
197 """Register a key for the current user"""211 """Register a key for the current user"""
198 return self._refresh_if_necessary(212 return self._refresh_if_necessary(
199 self.sca.register_key, account_key_request)213 self.sca.register_key, account_key_request)
200214
201 def register(self, snap_name, is_private=False):215 def register(self, snap_name, private=False):
202 """Register a package name for the current user216 """Register a package name for the current user
203 First refresh macaroon if necessary"""217 First refresh macaroon if necessary"""
204 return self._refresh_if_necessary(218 return self._refresh_if_necessary(
205 self.sca.register, snap_name, is_private, constants.DEFAULT_SERIES)219 self.sca.register, snap_name, private, constants.DEFAULT_SERIES)
206220
207 def push_precheck(self, snap_name):221 def push_precheck(self, snap_name):
208 """Do a snap push as a pre-check (dry_run: do not actually push)222 """Do a snap push as a pre-check (dry_run: do not actually push)
@@ -555,6 +569,36 @@
555 else:569 else:
556 raise errors.StoreAccountInformationError(response)570 raise errors.StoreAccountInformationError(response)
557571
572 def get_registered_snaps(self, series=constants.DEFAULT_SERIES):
573 """
574 Get the registered snaps for the current user
575 :param series: get only snaps that match with this series
576 :return: the list of registered snaps
577 """
578 account_info = self.get_account_information()
579 user_snaps = account_info.get('snaps')
580 snaps_dict = user_snaps.get(series)
581 snaps = []
582 for name, snap_data in snaps_dict.items():
583 snaps.append(Snap(name=name, **snap_data))
584 return snaps
585
586 def filter_snaps(self, series=constants.DEFAULT_SERIES, **predicates):
587 """
588 Return a list of the snaps that match with all the given predicates.
589 :param: series: only look in the snaps that match with this series
590 Examples:
591 filter_snap() --> return all the snaps
592 filter_snap(name='my_name') --> return the snaps that matches with
593 name 'my_name'
594 filter_snap(name='my_name', private=True) --> return the snaps that
595 matches with name 'my_name' and are private.
596 filter_snap(price='5') --> return the snaps that with price '5'.
597 :return: A list of snap instances
598 """
599 return filter_list(self.get_registered_snaps(series=series),
600 **predicates)
601
558 def register_key(self, account_key_request):602 def register_key(self, account_key_request):
559 """Register a key for a user with the given request603 """Register a key for a user with the given request
560 :param account_key_request: the key to register604 :param account_key_request: the key to register
@@ -568,20 +612,21 @@
568 if not response.ok:612 if not response.ok:
569 raise errors.StoreKeyRegistrationError(response)613 raise errors.StoreKeyRegistrationError(response)
570614
571 def register(self, snap_name, is_private, series):615 def register(self, snap_name, private, series):
572 """Register a snap name in the store616 """Register a snap name in the store
573 :param snap_name: the name to be registered617 :param snap_name: the name to be registered
574 :param is_private: whether the snap name is private or not618 :param private: whether the snap name is private or not
575 :param series: the snap's series to be registered619 :param series: the snap's series to be registered
576 """620 """
577 auth = _macaroon_auth(self.conf)621 auth = _macaroon_auth(self.conf)
578 data = dict(snap_name=snap_name, is_private=is_private,622 data = dict(snap_name=snap_name, is_private=private,
579 series=series)623 series=series)
580 response = self.post(624 response = self.post(
581 'register-name/', data=json.dumps(data),625 'register-name/', data=json.dumps(data),
582 headers=dict({'Authorization': auth}, **JSON_ACCEPT))626 headers=dict({'Authorization': auth}, **JSON_CONTENT_TYPE))
583 if not response.ok:627 if not response.ok:
584 raise errors.StoreRegistrationError(snap_name, response)628 raise errors.StoreRegistrationError(snap_name, response)
629 return True
585630
586 def snap_push_precheck(self, snap_name):631 def snap_push_precheck(self, snap_name):
587 """Do a snap push pre-check (dry_run: do not actually push)632 """Do a snap push pre-check (dry_run: do not actually push)
588633
=== added directory 'snappy_ecosystem_tests/models'
=== added file 'snappy_ecosystem_tests/models/__init__.py'
--- snappy_ecosystem_tests/models/__init__.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/models/__init__.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,19 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
020
=== added file 'snappy_ecosystem_tests/models/snap.py'
--- snappy_ecosystem_tests/models/snap.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/models/snap.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,39 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Business model classes for snaps"""
22
23
24class Snap:
25 """Represents a snap entity."""
26
27 def __init__(self, name='', price=None, private=False, since=None,
28 _id=None, status=None, notes=None, **kwargs):
29 self.name = name
30 self.price = price
31 self.private = private
32 self.since = since
33 self._id = _id or kwargs.get('snap-id')
34 self.status = status
35 self.notes = notes
36
37 def is_private(self):
38 """Return True if the snap is private, False otherwise"""
39 return self.private
040
=== modified file 'snappy_ecosystem_tests/run.py'
--- snappy_ecosystem_tests/run.py 2017-02-15 19:14:19 +0000
+++ snappy_ecosystem_tests/run.py 2017-03-02 10:45:12 +0000
@@ -20,28 +20,38 @@
2020
21"""Entry point to run snappy ecosystem tests"""21"""Entry point to run snappy ecosystem tests"""
2222
23import argparse
24import os
23import re25import re
24import sys26import sys
25import pytest27import pytest
2628
27FILTER_ARGUMENTS = '--proxy'
28
29
30def _filter_arguments():
31 """Remove from command line arguments all the ones that are in
32 FILTER_ARGUMENTS list."""
33 filtered_args = sys.argv[1:]
34 for i, arg in enumerate(sys.argv[1:]):
35 if arg in FILTER_ARGUMENTS:
36 filtered_args.pop(i + 1)
37 filtered_args.pop(i)
38 return filtered_args
39
4029
41def _parse_arguments():30def _parse_arguments():
42 """Parse and filter command line arguments to makethem pytest compatible"""31 """Parse and filter command line arguments to makethem pytest compatible"""
43 sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])32 sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
44 return _filter_arguments()33 parser = argparse.ArgumentParser(description=
34 'Run snappy ecosystem tests.')
35 parser.add_argument('--proxy',
36 help='proxy to use for creating the virtual env.',
37 required=False)
38 parser.add_argument('--target', default="lxd",
39 help='Target on which tests will be executed.')
40 ecosystem_args, pytest_args = parser.parse_known_args()
41 _set_env_variables(ecosystem_args)
42 return pytest_args
43
44
45def _set_env_variables(args):
46 """
47 Set environment variables with ecosystem arguments passed
48 in the command line.
49 :param args: The arguments to store in env variables
50 """
51 for arg in vars(args):
52 value = getattr(args, arg, None)
53 if value:
54 os.environ[arg] = value
4555
46if __name__ == '__main__':56if __name__ == '__main__':
47 sys.exit(pytest.main(args=_parse_arguments() + ['-p', 'no:cacheprovider']))57 sys.exit(pytest.main(args=_parse_arguments() + ['-p', 'no:cacheprovider']))
4858
=== added file 'snappy_ecosystem_tests/tests/test_register_snap.py'
--- snappy_ecosystem_tests/tests/test_register_snap.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/tests/test_register_snap.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,116 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Tests for Registering a snap name in the store"""
22
23import uuid
24
25from snappy_ecosystem_tests.helpers.snapcraft.client import Snapcraft
26from snappy_ecosystem_tests.helpers.store_apis.rest_apis import Store
27from snappy_ecosystem_tests.helpers.test_base import SnappyEcosystemTestCase
28from snappy_ecosystem_tests.utils.storeconfig import get_store_credentials
29
30
31class RegisterSnapNameTestCase(SnappyEcosystemTestCase):
32
33 def setUp(self):
34 super().setUp()
35 self.store = Store()
36 self.snapcraft = Snapcraft()
37 self.store.login(*get_store_credentials())
38 self.addCleanup(self.store.logout)
39 self.snapcraft.login()
40 self.addCleanup(self.snapcraft.logout)
41
42 @staticmethod
43 def _get_random_snap_name(prefix='ecosystem-test'):
44 """Get a random snap name using uuid
45 :param prefix: the string prefix,
46 if not provided, use default one.
47 """
48 return '{}{}'.format(prefix, int(uuid.uuid4()))
49
50 def test_register_public_snap_name_using_snapcraft(self):
51 """Test register a public snap name via snapcraft
52 and verify it via REST API"""
53 # Register snap via Snapcraft
54 snap_name = self._get_random_snap_name()
55 self.assertTrue(self.snapcraft.register(snap_name),
56 'Unable to register snap')
57
58 # Verify the registered snap via REST API
59 snaps = self.store.filter_snaps(name=snap_name)
60 self.assertEqual(1, len(snaps),
61 'Expected 1 snap with name %s but found %s'
62 % (snap_name, len(snaps)))
63 snap = snaps[0]
64 self.assertEqual(snap_name, snap.name)
65 self.assertFalse(snap.is_private())
66
67 def test_register_private_snap_name_using_snapcraft(self):
68 """Test register a private snap name via snapcraft
69 and verify it via REST API"""
70 # Register snap via Snapcraft
71 snap_name = self._get_random_snap_name()
72 self.assertTrue(self.snapcraft.register(snap_name, private=True),
73 'Unable to register snap')
74
75 # Verify the registered snap via REST API
76 snaps = self.store.filter_snaps(name=snap_name)
77 self.assertEqual(1, len(snaps),
78 'Expected 1 snap with name %s but found %s'
79 % (snap_name, len(snaps)))
80 snap = snaps[0]
81 self.assertEqual(snap_name, snap.name)
82 self.assertTrue(snap.is_private())
83
84 def test_register_public_snap_name_using_api(self):
85 """Verify that snapcraft lists a new snap registered via
86 RESTful API when using the command snapcraft list-registered"""
87 # Register snap via API
88 snap_name = self._get_random_snap_name()
89 self.assertTrue(self.store.register(snap_name),
90 'Unable to register snap')
91
92 # Verify the registered snap via Snapcraft
93 snaps = self.snapcraft.filter_snaps(name=snap_name)
94 self.assertEqual(1, len(snaps),
95 'Expected 1 snap with name %s but found %s'
96 % (snap_name, len(snaps)))
97 snap = snaps[0]
98 self.assertEqual(snap_name, snap.name)
99 self.assertFalse(snap.is_private())
100
101 def test_register_private_snap_name_using_api(self):
102 """Verify that snapcraft lists a new private snap registered via
103 RESTful API when using the command snapcraft list-registered"""
104 # Register snap via API
105 snap_name = self._get_random_snap_name()
106 self.assertTrue(self.store.register(snap_name, private=True),
107 'Unable to register snap')
108
109 # Verify the registered snap via Snapcraft
110 snaps = self.snapcraft.filter_snaps(name=snap_name)
111 self.assertEqual(1, len(snaps),
112 'Expected 1 snap with name %s but found %s'
113 % (snap_name, len(snaps)))
114 snap = snaps[0]
115 self.assertEqual(snap_name, snap.name)
116 self.assertTrue(snap.is_private())
0117
=== added file 'snappy_ecosystem_tests/unittests/test_filters.py'
--- snappy_ecosystem_tests/unittests/test_filters.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/unittests/test_filters.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,113 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Unit tests cases for filter utils"""
22
23from testtools import (
24 TestCase,
25 ExpectedException
26)
27
28from snappy_ecosystem_tests.utils.filters import (
29 object_filter,
30 filter_list
31)
32
33
34class DummyObject: # pylint: disable=too-few-public-methods
35 """Dummy object to be used in unit tests"""
36
37 def __init__(self, **kwargs):
38 for _k, _v in kwargs.items():
39 setattr(self, _k, _v)
40
41
42class FilterTestCase(TestCase):
43
44 def setUp(self):
45 super().setUp()
46 self.obj = DummyObject(name='dummy', desc='this is dummy')
47 self.obj_2 = DummyObject(name='another-dummy',
48 desc='this is another dummy')
49 self.objects = [self.obj, self.obj_2]
50
51 def test_object_filter_with_single_argument(self):
52 """Filter successfully passing one argument"""
53 objects = list(filter(object_filter(name='dummy'), self.objects))
54 self.assertIsNotNone(objects)
55 self.assertEqual(len(objects), 1)
56 self.assertEqual(objects[0], self.obj)
57
58 def test_object_filter_with_multiple_arguments(self):
59 """Filter successfully passing two arguments"""
60 objects = list(filter(object_filter(name='dummy',
61 desc='this is dummy'),
62 self.objects))
63 self.assertIsNotNone(objects)
64 self.assertEqual(len(objects), 1)
65 self.assertEqual(objects[0], self.obj)
66
67 def test_object_filter_does_not_match(self):
68 """Return empty list when no object match criteria"""
69 objects = list(filter(object_filter(name='dummy',
70 desc='any desc'),
71 self.objects))
72 self.assertEqual([], objects)
73
74 def test_object_filter_return_all(self):
75 """Get all objects when no filter is provided"""
76 objects = list(filter(object_filter(), self.objects))
77 self.assertEqual(len(objects), len(self.objects))
78
79 def test_object_filter_raises_attribute_error_if_invalid_filter_name(self):
80 """Object filter raises AttributeError when invalid filter
81 is provided"""
82 with ExpectedException(AttributeError):
83 list(filter(object_filter(invalid='dummy'), self.objects))
84
85 def test_filter_list_with_single_argument(self):
86 """Filter List successfully passing one argument"""
87 objects = filter_list(self.objects, name='dummy')
88 self.assertIsNotNone(objects)
89 self.assertEqual(len(objects), 1)
90 self.assertEqual(objects[0], self.obj)
91
92 def test_filter_list_with_multiple_arguments(self):
93 """Filter List successfully passing multiple argument"""
94 objects = filter_list(self.objects, name='another-dummy',
95 desc='this is another dummy')
96 self.assertIsNotNone(objects)
97 self.assertEqual(len(objects), 1)
98 self.assertEqual(objects[0], self.obj_2)
99
100 def test_filter_list_does_not_match(self):
101 """Filter List returns empty list when no object match criteria"""
102 objects = filter_list(self.objects, desc='desc does not match')
103 self.assertEqual([], objects)
104
105 def test_filter_list_return_all(self):
106 """Filter list returns all objects when no filter is provided"""
107 objects = filter_list(self.objects)
108 self.assertEqual(len(objects), len(self.objects))
109
110 def test_filter_list_raises_attribute_error_if_invalid_filter_name(self):
111 """Filter list raises AttributeError when invalid filter is provided"""
112 with ExpectedException(AttributeError):
113 filter_list(self.objects, invalid='invalid filter')
0114
=== removed file 'snappy_ecosystem_tests/unittests/test_snapcraft.py'
--- snappy_ecosystem_tests/unittests/test_snapcraft.py 2017-02-13 16:00:04 +0000
+++ snappy_ecosystem_tests/unittests/test_snapcraft.py 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Unit tests cases for snapcraft"""
22
23from unittest2 import TestCase
24
25
26class SnapcraftTestCase(TestCase):
27
28 def test_snapcraft_dummy_test(self):
29 """Dummy test case"""
30 _a = True
31 self.assertTrue(_a)
320
=== added file 'snappy_ecosystem_tests/utils/commands.py'
--- snappy_ecosystem_tests/utils/commands.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/utils/commands.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,31 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Manage commands to be executed in a shell"""
22
23
24def build_command(command, *args):
25 """
26 Build a command with arguments
27 :param command: the executable that is going to be used
28 :param args: list of arguments for the command
29 :return: the command ready to be executed
30 """
31 return'{c} {a}'.format(c=command, a=' '.join(args)).strip()
032
=== added file 'snappy_ecosystem_tests/utils/filters.py'
--- snappy_ecosystem_tests/utils/filters.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/utils/filters.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,51 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Filter utils"""
22
23
24def object_filter(**predicates):
25 """
26 Higher-order function to build and return an object filter function
27 :param predicates: key/values that represent
28 the conditions to look for in the object instance.
29 :return: a function to be used with filter or lambda expressions.
30 :raise: AttributeError if any of the attributes provided in predicates
31 does not exists
32 """
33 def wrapped_filter(instance):
34 """wrapped function to be returned when calling object_filter"""
35 return all(getattr(instance,
36 param) == val for param, val in predicates.items())
37 return wrapped_filter
38
39
40def filter_list(objects_list, **predicates):
41 """
42 Filter a list of objects with the given predicates
43 :param objects_list: the target list that contains
44 the objects to be filtered
45 :param predicates: key/values that represent
46 the conditions to look for in the object list.
47 :return: A list with the objects that match all the predicates
48 :raise: AttributeError if any of the attributes provided in predicates
49 does not exists
50 """
51 return list(filter(object_filter(**predicates), objects_list))
052
=== modified file 'snappy_ecosystem_tests/utils/ssh.py'
--- snappy_ecosystem_tests/utils/ssh.py 2017-02-22 18:56:04 +0000
+++ snappy_ecosystem_tests/utils/ssh.py 2017-03-02 10:45:12 +0000
@@ -23,6 +23,8 @@
23import paramiko23import paramiko
2424
25from snappy_ecosystem_tests.utils.user import get_remote_host_credentials25from snappy_ecosystem_tests.utils.user import get_remote_host_credentials
26from snappy_ecosystem_tests.helpers.snapd.staging_builder import (
27 STAGING_VARIABLES)
2628
2729
28class SSHManager:30class SSHManager:
@@ -83,10 +85,13 @@
83 :raises ValueError: if command exits with non-zero status.85 :raises ValueError: if command exits with non-zero status.
84 :return: the stdout of the command.86 :return: the stdout of the command.
85 """87 """
86 _hostname, _username, _port = get_remote_host_credentials()88 # Take snapd remote credentials as default if they are not provided.
89 # Just arbitrary... Could have been other ones.
90 _hostname, _username, _port = get_snapd_remote_host_credentials()
87 ssh = SSHManager.get_instance(91 ssh = SSHManager.get_instance(
88 hostname or _hostname, username or _username, port or _port)92 hostname or _hostname, username or _username, port or _port)
89 _, stdout, stderr = ssh.exec_command(command)93 _, stdout, stderr = ssh.exec_command(
94 command, environment=STAGING_VARIABLES)
90 if stdout.channel.recv_exit_status() != 0:95 if stdout.channel.recv_exit_status() != 0:
91 raise ValueError(stderr.read().decode())96 raise ValueError(stderr.read().decode())
92 return stdout.read().decode()97 return stdout.read().decode()
9398
=== added file 'snappy_ecosystem_tests/utils/store_versions.py'
--- snappy_ecosystem_tests/utils/store_versions.py 1970-01-01 00:00:00 +0000
+++ snappy_ecosystem_tests/utils/store_versions.py 2017-03-02 10:45:12 +0000
@@ -0,0 +1,74 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Snappy Ecosystem Tests
5# Copyright (C) 2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21"""Utility for printing Store versions of: CPI, SCA and SSO.
22To be called as a standalone script.
23"""
24
25import requests
26
27DEFAULT_HEADER = "X-BZR-REVISION-NUMBER"
28
29SERVICES_INFO = dict(
30 CPI=('https://search.apps.ubuntu.com/api/v1',
31 'https://search.apps.staging.ubuntu.com/api/v1'),
32 SCA=('https://myapps.developer.ubuntu.com/',
33 'https://myapps.developer.staging.ubuntu.com/'),
34 SSO=('https://login.ubuntu.com/',
35 'https://login.staging.ubuntu.com/'),
36)
37
38
39def get_deployed_revno(service, environment):
40 """Get revno from service."""
41 prod, stag = SERVICES_INFO[service]
42 if environment == 'staging':
43 url = stag
44 else:
45 url = prod
46 with requests.Session() as session:
47 resp = session.get(url)
48 if resp.status_code == 200:
49 revno = resp.headers[DEFAULT_HEADER]
50 else:
51 print("{} 500'ed: {}".format(service, resp.text))
52 revno = 0
53 return service, environment, revno
54
55
56def print_versions():
57 """Print Store components version"""
58 coros = []
59 for service in SERVICES_INFO:
60 coro = get_deployed_revno(service, 'staging')
61 coros.append(coro)
62 coro = get_deployed_revno(service, 'production')
63 coros.append(coro)
64
65 data = {(service, kind): value for service, kind, value in coros}
66 print("#########################-STORE VERSIONS-#########################")
67 for service in sorted(SERVICES_INFO):
68 print("{}: Staging: {:>5}".format(service,
69 data[(service, 'staging')]))
70 print("{}: Production: {:>5}".format(service,
71 data[(service, 'production')]))
72
73if __name__ == '__main__':
74 print_versions()
075
=== modified file 'snappy_ecosystem_tests/utils/storeconfig.py'
--- snappy_ecosystem_tests/utils/storeconfig.py 2017-02-15 19:14:19 +0000
+++ snappy_ecosystem_tests/utils/storeconfig.py 2017-03-02 10:45:12 +0000
@@ -27,8 +27,8 @@
27 USER_CONFIG_STACK27 USER_CONFIG_STACK
28)28)
2929
30URL_WEB_STORE_PRODUCTION = CONFIG_STACK.get('web-ui', 'production_url')30URL_WEB_STORE_PRODUCTION = CONFIG_STACK.get('production_urls', 'web')
31URL_WEB_STORE_STAGING = CONFIG_STACK.get('web-ui', 'stage_url')31URL_WEB_STORE_STAGING = CONFIG_STACK.get('staging_urls', 'web')
3232
3333
34def get_store_credentials():34def get_store_credentials():
3535
=== modified file 'snappy_ecosystem_tests/utils/user.py'
--- snappy_ecosystem_tests/utils/user.py 2017-02-22 15:39:40 +0000
+++ snappy_ecosystem_tests/utils/user.py 2017-03-02 10:45:12 +0000
@@ -23,13 +23,34 @@
23import os23import os
2424
25from snappy_ecosystem_tests.commons.config import USER_CONFIG_STACK25from snappy_ecosystem_tests.commons.config import USER_CONFIG_STACK
2626from snappy_ecosystem_tests.environment.managers import get_manager
2727
28def get_remote_host_credentials():28MANAGER = get_manager(os.environ['target'])
29 """Return credentials for remote machine, to run commands on."""29
30 return (USER_CONFIG_STACK.get('user', 'hostname_remote',30
31 default=os.environ.get('hostname_remote')),31def get_snapd_remote_host_credentials():
32 USER_CONFIG_STACK.get('user', 'username_remote',32 """Return credentials for snapd remote machine, to run commands on."""
33 default=os.environ.get('username_remote')),33 _ip = MANAGER.get_ip(USER_CONFIG_STACK.get(
34 USER_CONFIG_STACK.get('user', 'port_remote',34 'user', 'snapd_hostname_remote',
35 default=os.environ.get('port_remote')))35 default=os.environ.get('snapd_hostname_remote')))
36 return (_ip,
37 USER_CONFIG_STACK.get('user', 'snapd_username_remote',
38 default=os.environ.get(
39 'snapd_username_remote')),
40 USER_CONFIG_STACK.get('user', 'snapd_port_remote',
41 default=os.environ.get(
42 'snapd_port_remote')))
43
44
45def get_snapcraft_remote_host_credentials():
46 """Return credentials for snapcraft remote machine, to run commands on."""
47 _ip = MANAGER.get_ip(USER_CONFIG_STACK.get(
48 'user', 'snapcraft_hostname_remote',
49 default=os.environ.get('snapcraft_snapcraft_remote')))
50 return (_ip,
51 USER_CONFIG_STACK.get('user', 'snapcraft_username_remote',
52 default=os.environ.get(
53 'snapcraft_username_remote')),
54 USER_CONFIG_STACK.get('user', 'snapcraft_port_remote',
55 default=os.environ.get(
56 'snapcraft_port_remote')))

Subscribers

People subscribed via source and target branches