Merge lp:~canonical-platform-qa/snappy-ecosystem-tests/fixing-proxy-issue-containers into lp:snappy-ecosystem-tests

Proposed by Heber Parrucci
Status: Merged
Approved by: Omer Akram
Approved revision: 58
Merged at revision: 46
Proposed branch: lp:~canonical-platform-qa/snappy-ecosystem-tests/fixing-proxy-issue-containers
Merge into: lp:snappy-ecosystem-tests
Diff against target: 155 lines (+30/-29)
6 files modified
run_setup (+7/-1)
snappy_ecosystem_tests/commons/config.py (+1/-2)
snappy_ecosystem_tests/environment/containers/lxd.py (+9/-19)
snappy_ecosystem_tests/environment/managers.py (+5/-4)
snappy_ecosystem_tests/environment/setup.py (+5/-3)
snappy_ecosystem_tests/run.py (+3/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/snappy-ecosystem-tests/fixing-proxy-issue-containers
Reviewer Review Type Date Requested Status
platform-qa-bot continuous-integration Approve
Omer Akram (community) Approve
Santiago Baldassin (community) Approve
Review via email: mp+320110@code.launchpad.net

Commit message

Fixing proxy in container for jenkins

Description of the change

Fixing proxy in container for jenkins

To post a comment you must log in.
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Looks great!

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

a comment inline

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

another comment

57. By Heber Parrucci

changes http key for http_proxy

Revision history for this message
Heber Parrucci (heber013) wrote :

reply inline

58. By Heber Parrucci

fix key

Revision history for this message
Heber Parrucci (heber013) wrote :

Reply inline

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

ok, looks good to me.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'run_setup'
2--- run_setup 2017-03-06 18:06:27 +0000
3+++ run_setup 2017-03-16 20:41:47 +0000
4@@ -49,7 +49,13 @@
5 if [ -z "$profile" ]; then
6 profile=staging
7 fi
8-ve/bin/python3 -m snappy_ecosystem_tests.environment.setup --mode ${mode} --profile ${profile}
9+
10+if [ -z "$proxy" ]; then
11+ ve/bin/python3 -m snappy_ecosystem_tests.environment.setup --mode ${mode} --profile ${profile}
12+else
13+ ve/bin/python3 -m snappy_ecosystem_tests.environment.setup --mode ${mode} --profile ${profile} --proxy ${proxy}
14+fi
15+
16
17 result=$?
18 deactivate
19
20=== modified file 'snappy_ecosystem_tests/commons/config.py'
21--- snappy_ecosystem_tests/commons/config.py 2017-02-15 19:14:19 +0000
22+++ snappy_ecosystem_tests/commons/config.py 2017-03-16 20:41:47 +0000
23@@ -39,8 +39,7 @@
24
25 def get_user_config_dir():
26 """Return the path to the user configuration directory."""
27- conf_dir = os.environ.get(
28- 'XDG_USER_CONFIG_HOME', os.path.expanduser('~/.config'))
29+ conf_dir = os.environ.get('config')
30 return conf_dir
31
32
33
34=== modified file 'snappy_ecosystem_tests/environment/containers/lxd.py'
35--- snappy_ecosystem_tests/environment/containers/lxd.py 2017-03-16 14:48:13 +0000
36+++ snappy_ecosystem_tests/environment/containers/lxd.py 2017-03-16 20:41:47 +0000
37@@ -32,8 +32,7 @@
38 DEFAULT_CONTAINER_CONFIG)
39
40 LOGGER = logging.getLogger(__name__)
41-DOMAIN_PING = 'ubuntu.com'
42-VARIABLES = ['https_proxy', 'http_proxy']
43+DOMAIN_PING = 'http://cloud-images.ubuntu.com/releases'
44
45
46 class LXDDriver:
47@@ -141,36 +140,27 @@
48 "The container {} does not have an IPV4 connection".format(
49 container.name))
50
51- def export_environment_variables(self, container, environment_variables):
52+ def export_environment_variables(self, container, environment_variables,
53+ proxy):
54 """Export permanent environment variables inside container."""
55 for key, value in environment_variables.items():
56 self._execute_command(
57 container,
58 'echo \'{}={}\' >> /etc/environment'.format(key, value))
59- self.set_variables(VARIABLES, container)
60-
61- def set_variables(self, variables, container):
62- """Read given environment variables in the host and set to
63- the container"""
64- for var in variables:
65- self._set_variable(var, container)
66-
67- def _set_variable(self, variable, container):
68- """Read the given variable in the host and set to the container"""
69- value = os.environ.get(variable)
70- if value:
71+ if proxy:
72+ key = 'https_proxy' if proxy.startswith('https') else 'http_proxy'
73 self._execute_command(
74 container,
75- 'echo \'{}={}\' >> /etc/environment'.format(variable,
76- value))
77+ 'echo \'{}={}\' >> /etc/environment'.format(key, proxy))
78+ container.restart(wait=True)
79
80 def wait_for_internet(self, container, attempts_count=30,
81 attempt_interval=1, ping_domain=DOMAIN_PING):
82 """Wait for internet connectivity in the container."""
83 for _ in range(attempts_count):
84 try:
85- self._execute_command(
86- container, 'curl -I {}'.format(ping_domain))
87+ command = 'curl -I {}'.format(ping_domain)
88+ self._execute_command(container, command)
89 break
90 except ValueError:
91 LOGGER.info('Sleeping for %s second(s)', attempt_interval)
92
93=== modified file 'snappy_ecosystem_tests/environment/managers.py'
94--- snappy_ecosystem_tests/environment/managers.py 2017-03-10 12:38:22 +0000
95+++ snappy_ecosystem_tests/environment/managers.py 2017-03-16 20:41:47 +0000
96@@ -39,14 +39,15 @@
97 def __init__(self):
98 self.driver = LXDDriver()
99
100- def setup(self, profile):
101+ def setup(self, profile, proxy=None):
102 """setup the container based on the profile"""
103 containers = self.driver.launch(CONTAINERS)
104 for cont in containers:
105+ self.driver.export_environment_variables(
106+ cont,
107+ PROFILES[profile][cont.name]["environment_variables"],
108+ proxy=proxy)
109 self.driver.wait_for_internet(cont)
110- self.driver.export_environment_variables(
111- cont,
112- PROFILES[profile][cont.name]["environment_variables"])
113 self.driver.add_ppas(
114 cont,
115 PROFILES[profile][cont.name]["ppas"])
116
117=== modified file 'snappy_ecosystem_tests/environment/setup.py'
118--- snappy_ecosystem_tests/environment/setup.py 2017-03-10 09:47:49 +0000
119+++ snappy_ecosystem_tests/environment/setup.py 2017-03-16 20:41:47 +0000
120@@ -42,10 +42,10 @@
121 raise RuntimeError("Mode: {} is not supported".format(mode))
122
123
124-def main(mode, profile):
125+def main(mode, profile, proxy):
126 """Main script"""
127 manager = get_manager(mode)
128- manager.setup(profile)
129+ manager.setup(profile, proxy)
130
131
132 if __name__ == '__main__':
133@@ -54,5 +54,7 @@
134 PARSER.add_argument('--mode', default="lxd", help='lxd')
135 PARSER.add_argument('--profile', default="staging",
136 help='Profile to configure the environment')
137+ PARSER.add_argument('--proxy', default=None,
138+ help='Proxy to use in the target machine/s')
139 ARGS = PARSER.parse_args()
140- main(ARGS.mode, ARGS.profile)
141+ main(ARGS.mode, ARGS.profile, ARGS.proxy)
142
143=== modified file 'snappy_ecosystem_tests/run.py'
144--- snappy_ecosystem_tests/run.py 2017-03-08 17:29:20 +0000
145+++ snappy_ecosystem_tests/run.py 2017-03-16 20:41:47 +0000
146@@ -36,6 +36,9 @@
147 required=False)
148 parser.add_argument('--target', default="lxd",
149 help='Target on which tests will be executed.')
150+ parser.add_argument('--config', default=os.path.expanduser(
151+ '~/.config/ecosystem_tests.cfg'),
152+ help='User config file.')
153 ecosystem_args, pytest_args = parser.parse_known_args()
154 _set_env_variables(ecosystem_args)
155 return pytest_args

Subscribers

People subscribed via source and target branches