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
=== modified file 'run_setup'
--- run_setup 2017-03-06 18:06:27 +0000
+++ run_setup 2017-03-16 20:41:47 +0000
@@ -49,7 +49,13 @@
49if [ -z "$profile" ]; then49if [ -z "$profile" ]; then
50 profile=staging50 profile=staging
51fi51fi
52ve/bin/python3 -m snappy_ecosystem_tests.environment.setup --mode ${mode} --profile ${profile}52
53if [ -z "$proxy" ]; then
54 ve/bin/python3 -m snappy_ecosystem_tests.environment.setup --mode ${mode} --profile ${profile}
55else
56 ve/bin/python3 -m snappy_ecosystem_tests.environment.setup --mode ${mode} --profile ${profile} --proxy ${proxy}
57fi
58
5359
54result=$?60result=$?
55deactivate61deactivate
5662
=== modified file 'snappy_ecosystem_tests/commons/config.py'
--- snappy_ecosystem_tests/commons/config.py 2017-02-15 19:14:19 +0000
+++ snappy_ecosystem_tests/commons/config.py 2017-03-16 20:41:47 +0000
@@ -39,8 +39,7 @@
3939
40def get_user_config_dir():40def get_user_config_dir():
41 """Return the path to the user configuration directory."""41 """Return the path to the user configuration directory."""
42 conf_dir = os.environ.get(42 conf_dir = os.environ.get('config')
43 'XDG_USER_CONFIG_HOME', os.path.expanduser('~/.config'))
44 return conf_dir43 return conf_dir
4544
4645
4746
=== modified file 'snappy_ecosystem_tests/environment/containers/lxd.py'
--- snappy_ecosystem_tests/environment/containers/lxd.py 2017-03-16 14:48:13 +0000
+++ snappy_ecosystem_tests/environment/containers/lxd.py 2017-03-16 20:41:47 +0000
@@ -32,8 +32,7 @@
32 DEFAULT_CONTAINER_CONFIG)32 DEFAULT_CONTAINER_CONFIG)
3333
34LOGGER = logging.getLogger(__name__)34LOGGER = logging.getLogger(__name__)
35DOMAIN_PING = 'ubuntu.com'35DOMAIN_PING = 'http://cloud-images.ubuntu.com/releases'
36VARIABLES = ['https_proxy', 'http_proxy']
3736
3837
39class LXDDriver:38class LXDDriver:
@@ -141,36 +140,27 @@
141 "The container {} does not have an IPV4 connection".format(140 "The container {} does not have an IPV4 connection".format(
142 container.name))141 container.name))
143142
144 def export_environment_variables(self, container, environment_variables):143 def export_environment_variables(self, container, environment_variables,
144 proxy):
145 """Export permanent environment variables inside container."""145 """Export permanent environment variables inside container."""
146 for key, value in environment_variables.items():146 for key, value in environment_variables.items():
147 self._execute_command(147 self._execute_command(
148 container,148 container,
149 'echo \'{}={}\' >> /etc/environment'.format(key, value))149 'echo \'{}={}\' >> /etc/environment'.format(key, value))
150 self.set_variables(VARIABLES, container)150 if proxy:
151151 key = 'https_proxy' if proxy.startswith('https') else 'http_proxy'
152 def set_variables(self, variables, container):
153 """Read given environment variables in the host and set to
154 the container"""
155 for var in variables:
156 self._set_variable(var, container)
157
158 def _set_variable(self, variable, container):
159 """Read the given variable in the host and set to the container"""
160 value = os.environ.get(variable)
161 if value:
162 self._execute_command(152 self._execute_command(
163 container,153 container,
164 'echo \'{}={}\' >> /etc/environment'.format(variable,154 'echo \'{}={}\' >> /etc/environment'.format(key, proxy))
165 value))155 container.restart(wait=True)
166156
167 def wait_for_internet(self, container, attempts_count=30,157 def wait_for_internet(self, container, attempts_count=30,
168 attempt_interval=1, ping_domain=DOMAIN_PING):158 attempt_interval=1, ping_domain=DOMAIN_PING):
169 """Wait for internet connectivity in the container."""159 """Wait for internet connectivity in the container."""
170 for _ in range(attempts_count):160 for _ in range(attempts_count):
171 try:161 try:
172 self._execute_command(162 command = 'curl -I {}'.format(ping_domain)
173 container, 'curl -I {}'.format(ping_domain))163 self._execute_command(container, command)
174 break164 break
175 except ValueError:165 except ValueError:
176 LOGGER.info('Sleeping for %s second(s)', attempt_interval)166 LOGGER.info('Sleeping for %s second(s)', attempt_interval)
177167
=== modified file 'snappy_ecosystem_tests/environment/managers.py'
--- snappy_ecosystem_tests/environment/managers.py 2017-03-10 12:38:22 +0000
+++ snappy_ecosystem_tests/environment/managers.py 2017-03-16 20:41:47 +0000
@@ -39,14 +39,15 @@
39 def __init__(self):39 def __init__(self):
40 self.driver = LXDDriver()40 self.driver = LXDDriver()
4141
42 def setup(self, profile):42 def setup(self, profile, proxy=None):
43 """setup the container based on the profile"""43 """setup the container based on the profile"""
44 containers = self.driver.launch(CONTAINERS)44 containers = self.driver.launch(CONTAINERS)
45 for cont in containers:45 for cont in containers:
46 self.driver.export_environment_variables(
47 cont,
48 PROFILES[profile][cont.name]["environment_variables"],
49 proxy=proxy)
46 self.driver.wait_for_internet(cont)50 self.driver.wait_for_internet(cont)
47 self.driver.export_environment_variables(
48 cont,
49 PROFILES[profile][cont.name]["environment_variables"])
50 self.driver.add_ppas(51 self.driver.add_ppas(
51 cont,52 cont,
52 PROFILES[profile][cont.name]["ppas"])53 PROFILES[profile][cont.name]["ppas"])
5354
=== modified file 'snappy_ecosystem_tests/environment/setup.py'
--- snappy_ecosystem_tests/environment/setup.py 2017-03-10 09:47:49 +0000
+++ snappy_ecosystem_tests/environment/setup.py 2017-03-16 20:41:47 +0000
@@ -42,10 +42,10 @@
42 raise RuntimeError("Mode: {} is not supported".format(mode))42 raise RuntimeError("Mode: {} is not supported".format(mode))
4343
4444
45def main(mode, profile):45def main(mode, profile, proxy):
46 """Main script"""46 """Main script"""
47 manager = get_manager(mode)47 manager = get_manager(mode)
48 manager.setup(profile)48 manager.setup(profile, proxy)
4949
5050
51if __name__ == '__main__':51if __name__ == '__main__':
@@ -54,5 +54,7 @@
54 PARSER.add_argument('--mode', default="lxd", help='lxd')54 PARSER.add_argument('--mode', default="lxd", help='lxd')
55 PARSER.add_argument('--profile', default="staging",55 PARSER.add_argument('--profile', default="staging",
56 help='Profile to configure the environment')56 help='Profile to configure the environment')
57 PARSER.add_argument('--proxy', default=None,
58 help='Proxy to use in the target machine/s')
57 ARGS = PARSER.parse_args()59 ARGS = PARSER.parse_args()
58 main(ARGS.mode, ARGS.profile)60 main(ARGS.mode, ARGS.profile, ARGS.proxy)
5961
=== modified file 'snappy_ecosystem_tests/run.py'
--- snappy_ecosystem_tests/run.py 2017-03-08 17:29:20 +0000
+++ snappy_ecosystem_tests/run.py 2017-03-16 20:41:47 +0000
@@ -36,6 +36,9 @@
36 required=False)36 required=False)
37 parser.add_argument('--target', default="lxd",37 parser.add_argument('--target', default="lxd",
38 help='Target on which tests will be executed.')38 help='Target on which tests will be executed.')
39 parser.add_argument('--config', default=os.path.expanduser(
40 '~/.config/ecosystem_tests.cfg'),
41 help='User config file.')
39 ecosystem_args, pytest_args = parser.parse_known_args()42 ecosystem_args, pytest_args = parser.parse_known_args()
40 _set_env_variables(ecosystem_args)43 _set_env_variables(ecosystem_args)
41 return pytest_args44 return pytest_args

Subscribers

People subscribed via source and target branches