Merge lp:~frankban/charms/trusty/juju-gui/new-test-and-server-deps into lp:~juju-gui/charms/trusty/juju-gui/trunk

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 199
Proposed branch: lp:~frankban/charms/trusty/juju-gui/new-test-and-server-deps
Merge into: lp:~juju-gui/charms/trusty/juju-gui/trunk
Diff against target: 277 lines (+58/-41)
5 files modified
server-requirements.pip (+5/-3)
test-requirements.pip (+1/-1)
tests/20-functional.test (+17/-13)
tests/helpers.py (+17/-7)
tests/test_helpers.py (+18/-17)
To merge this branch: bzr merge lp:~frankban/charms/trusty/juju-gui/new-test-and-server-deps
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+234469@code.launchpad.net

Description of the change

Update dependencies + other fixes.

Update the GUI server dependencies:
websocket-client, jujuclient, juju=deployer.
Also included in the dependencies repo
the new websocket-client requirements.

Update selenium to the latest version
(2.43.0) so that the functional tests
pass on Firefox 32. The download cache
has been updated accordingly.

Fix how the suite detects if it is running
on a local environment: do not use the
environment name (unreliable), but retrieve
the environment type instead.

Fix the WebSocket client used when running
functional tests to reflect changes in the
new websocket-client.

QA:
run the test suite on precise and trusty:
assuming your ec2 trusty environment is
called ec2-trusty and your ec2 precise one
is called ec2-precise, run the following:

    make test JUJU_ENV=ec2-trusty
    make test JUJU_ENV=ec2-precise

As you already know, the functional tests
take a while.

https://codereview.appspot.com/136570043/

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :
Download full text (12.7 KiB)

Reviewers: mp+234469_code.launchpad.net,

Message:
Please take a look.

Description:
Update dependencies + other fixes.

Update the GUI server dependencies:
websocket-client, jujuclient, juju=deployer.
Also included in the dependencies repo
the new websocket-client requirements.

Update selenium to the latest version
(2.43.0) so that the functional tests
pass on Firefox 32. The download cache
has been updated accordingly.

Fix how the suite detects if it is running
on a local environment: do not use the
environment name (unreliable), but retrieve
the environment type instead.

Fix the WebSocket client used when running
functional tests to reflect changes in the
new websocket-client.

QA:
run the test suite on precise and trusty:
assuming your ec2 trusty environment is
called ec2-trusty and your ec2 precise one
is called ec2-precise, run the following:

     make test JUJU_ENV=ec2-trusty
     make test JUJU_ENV=ec2-precise

As you already know, the functional tests
take a while.

https://code.launchpad.net/~frankban/charms/trusty/juju-gui/new-test-and-server-deps/+merge/234469

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/136570043/

Affected files (+52, -33 lines):
   A [revision details]
   A deps/backports.ssl_match_hostname-3.4.0.2.tar.gz
   D deps/juju-deployer-0.3.9.tar.gz
   A deps/juju-deployer-0.4.0.tar.gz
   D deps/jujuclient-0.17.5.tar.gz
   A deps/jujuclient-0.18.4.tar.gz
   A deps/six-1.8.0.tar.gz
   D deps/websocket-client-0.12.0.tar.gz
   A deps/websocket-client-0.18.0.tar.gz
   M server-requirements.pip
   M test-requirements.pip
   M tests/20-functional.test
   M tests/helpers.py
   M tests/test_helpers.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision:
<email address hidden>
+New revision:
<email address hidden>

Index: deps/backports.ssl_match_hostname-3.4.0.2.tar.gz
=== added file 'deps/backports.ssl_match_hostname-3.4.0.2.tar.gz'
Binary files deps/backports.ssl_match_hostname-3.4.0.2.tar.gz 1970-01-01
00:00:00 +0000 and deps/backports.ssl_match_hostname-3.4.0.2.tar.gz
2014-09-12 11:00:01 +0000 differ

Index: deps/juju-deployer-0.3.9.tar.gz
=== removed file 'deps/juju-deployer-0.3.9.tar.gz'
Binary files deps/juju-deployer-0.3.9.tar.gz 2014-08-28 20:23:34 +0000 and
deps/juju-deployer-0.3.9.tar.gz 1970-01-01 00:00:00 +0000 differ

Index: deps/juju-deployer-0.4.0.tar.gz
=== added file 'deps/juju-deployer-0.4.0.tar.gz'
Binary files deps/juju-deployer-0.4.0.tar.gz 1970-01-01 00:00:00 +0000 and
deps/juju-deployer-0.4.0.tar.gz 2014-09-12 11:00:01 +0000 differ

Index: deps/jujuclient-0.17.5.tar.gz
=== removed file 'deps/jujuclient-0.17.5.tar.gz'
Binary files deps/jujuclient-0.17.5.tar.gz 2014-03-17 11:16:15 +0000 and
deps/jujuclient-0.17.5.tar.gz 1970-01-01 00:00:00 +0000 differ

Index: deps/jujuclient-0.18.4.tar.gz
=== added file 'deps/jujuclient-0.18.4.tar.gz'
Binary files deps/jujuclient-0.18.4.tar.gz 1970-01-01 00:00:00 +0000 and
de...

Revision history for this message
Richard Harding (rharding) wrote :

code looks good, starting up a QA/test run on trusty if the other
reviewer could do precise that'd be great.

https://codereview.appspot.com/136570043/

Revision history for this message
Richard Harding (rharding) wrote :

Ran 12 tests in 1809.282s

QA good on trusty LGTM

https://codereview.appspot.com/136570043/

Revision history for this message
Madison Scott-Clary (makyo) wrote :
Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Update dependencies + other fixes.

Update the GUI server dependencies:
websocket-client, jujuclient, juju=deployer.
Also included in the dependencies repo
the new websocket-client requirements.

Update selenium to the latest version
(2.43.0) so that the functional tests
pass on Firefox 32. The download cache
has been updated accordingly.

Fix how the suite detects if it is running
on a local environment: do not use the
environment name (unreliable), but retrieve
the environment type instead.

Fix the WebSocket client used when running
functional tests to reflect changes in the
new websocket-client.

QA:
run the test suite on precise and trusty:
assuming your ec2 trusty environment is
called ec2-trusty and your ec2 precise one
is called ec2-precise, run the following:

     make test JUJU_ENV=ec2-trusty
     make test JUJU_ENV=ec2-precise

As you already know, the functional tests
take a while.

R=rharding, matthew.scott
CC=
https://codereview.appspot.com/136570043

https://codereview.appspot.com/136570043/

Revision history for this message
Francesco Banconi (frankban) wrote :

Thank you both for the reviews!

https://codereview.appspot.com/136570043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'deps/backports.ssl_match_hostname-3.4.0.2.tar.gz'
2Binary files deps/backports.ssl_match_hostname-3.4.0.2.tar.gz 1970-01-01 00:00:00 +0000 and deps/backports.ssl_match_hostname-3.4.0.2.tar.gz 2014-09-12 13:47:41 +0000 differ
3=== removed file 'deps/juju-deployer-0.3.9.tar.gz'
4Binary files deps/juju-deployer-0.3.9.tar.gz 2014-08-28 20:23:34 +0000 and deps/juju-deployer-0.3.9.tar.gz 1970-01-01 00:00:00 +0000 differ
5=== added file 'deps/juju-deployer-0.4.0.tar.gz'
6Binary files deps/juju-deployer-0.4.0.tar.gz 1970-01-01 00:00:00 +0000 and deps/juju-deployer-0.4.0.tar.gz 2014-09-12 13:47:41 +0000 differ
7=== removed file 'deps/jujuclient-0.17.5.tar.gz'
8Binary files deps/jujuclient-0.17.5.tar.gz 2014-03-17 11:16:15 +0000 and deps/jujuclient-0.17.5.tar.gz 1970-01-01 00:00:00 +0000 differ
9=== added file 'deps/jujuclient-0.18.4.tar.gz'
10Binary files deps/jujuclient-0.18.4.tar.gz 1970-01-01 00:00:00 +0000 and deps/jujuclient-0.18.4.tar.gz 2014-09-12 13:47:41 +0000 differ
11=== added file 'deps/six-1.8.0.tar.gz'
12Binary files deps/six-1.8.0.tar.gz 1970-01-01 00:00:00 +0000 and deps/six-1.8.0.tar.gz 2014-09-12 13:47:41 +0000 differ
13=== removed file 'deps/websocket-client-0.12.0.tar.gz'
14Binary files deps/websocket-client-0.12.0.tar.gz 2013-10-04 12:53:53 +0000 and deps/websocket-client-0.12.0.tar.gz 1970-01-01 00:00:00 +0000 differ
15=== added file 'deps/websocket-client-0.18.0.tar.gz'
16Binary files deps/websocket-client-0.18.0.tar.gz 1970-01-01 00:00:00 +0000 and deps/websocket-client-0.18.0.tar.gz 2014-09-12 13:47:41 +0000 differ
17=== modified file 'server-requirements.pip'
18--- server-requirements.pip 2014-08-28 20:23:34 +0000
19+++ server-requirements.pip 2014-09-12 13:47:41 +0000
20@@ -25,7 +25,9 @@
21
22 futures==2.1.4
23 tornado==3.1.1
24-websocket-client==0.12.0
25-jujuclient==0.17.5
26-juju-deployer==0.3.9
27+six==1.8.0
28+backports.ssl_match_hostname==3.4.0.2
29+websocket-client==0.18.0
30+jujuclient==0.18.4
31+juju-deployer==0.4.0
32 charmworldlib==0.3.0
33
34=== modified file 'test-requirements.pip'
35--- test-requirements.pip 2014-01-09 13:51:29 +0000
36+++ test-requirements.pip 2014-09-12 13:47:41 +0000
37@@ -43,7 +43,7 @@
38 mock==1.0.1
39
40 # Charm tests.
41-selenium==2.39.0
42+selenium==2.43.0
43 xvfbwrapper==0.2.2
44
45
46
47=== modified file 'tests/20-functional.test'
48--- tests/20-functional.test 2014-07-10 18:59:23 +0000
49+++ tests/20-functional.test 2014-09-12 13:47:41 +0000
50@@ -34,7 +34,7 @@
51 # DeployTestMixin.juju_deploy instead. See comment in the method.
52 from deploy import juju_deploy
53 from helpers import (
54- get_admin_secret,
55+ get_env_attr,
56 juju_destroy_service,
57 juju_status,
58 make_service_name,
59@@ -45,22 +45,26 @@
60 JUJU_GUI_TEST_BRANCH = 'https://github.com/juju/juju-gui.git master'
61
62 try:
63- admin_secret = get_admin_secret()
64+ admin_secret = get_env_attr('admin-secret')
65 except ValueError as err:
66 admin_secret = None
67 print(err)
68+
69+# If the suite is using a local environment, then the charm cannot be
70+# co-located to machine 0, and a new machine must be created for each charm
71+# deployment.
72+try:
73+ env_type = get_env_attr('type')
74+except ValueError as err:
75+ # This should never happen, but if it does, defensively assume a new
76+ # machine is always required.
77+ force_machine = None
78+ print(err)
79+else:
80+ force_machine = None if env_type == 'local' else 0
81+
82 bootstrap_node_series = juju_status()['machines']['0']['series']
83
84-"""
85-If JUJU_ENV is defined to local, then the --to is not
86-used as it is not needed in the local env. Otherwise, the
87-default placing of the deployed GUI charm is on machine 0
88-with a --to 0
89-"""
90-forced_machine = 0
91-env_par = os.getenv('JUJU_ENV')
92-if env_par == "local":
93- forced_machine = None
94
95 def juju_deploy_gui(options=None):
96 """Deploy the Juju GUI charm with the given options.
97@@ -73,7 +77,7 @@
98 service_name = make_service_name(prefix='juju-gui-')
99 unit_info = juju_deploy(
100 'juju-gui', service_name=service_name, options=options,
101- force_machine=forced_machine, series=bootstrap_node_series)
102+ force_machine=force_machine, series=bootstrap_node_series)
103 return service_name, unit_info
104
105
106
107=== modified file 'tests/helpers.py'
108--- tests/helpers.py 2014-01-14 23:57:37 +0000
109+++ tests/helpers.py 2014-09-12 13:47:41 +0000
110@@ -23,6 +23,7 @@
111 import random
112 import string
113 import subprocess
114+import ssl
115 import time
116
117 import websocket
118@@ -106,10 +107,13 @@
119 return decorator
120
121
122-def get_admin_secret():
123- """Return the admin secret for the current environment.
124+def get_env_attr(attr):
125+ """Return the requested attribute for the current environment.
126
127+ The attr argument is the key included in the current environment section
128+ in ~/.juju/environments.yaml.
129 The environment name must be present in the JUJU_ENV env variable.
130+
131 Raise a ValueError if the environment is not found in the context or the
132 given environment name is not included in ~/.juju/environments.yaml.
133 """
134@@ -134,10 +138,10 @@
135 raise ValueError('Invalid YAML contents: {}'.format(environments))
136 if environment is None:
137 raise ValueError('Environment {} not found'.format(env))
138- admin_secret = environment.get('admin-secret')
139- if admin_secret is None:
140- raise ValueError('Admin secret not found')
141- return admin_secret
142+ value = environment.get(attr)
143+ if value is None:
144+ raise ValueError('Attribute {} not found'.format(attr))
145+ return value
146
147
148 @retry(ProcessError)
149@@ -210,6 +214,12 @@
150 return unit
151
152
153+SSLOPT = {
154+ 'cert_reqs': ssl.CERT_NONE,
155+ 'ssl_version': ssl.PROTOCOL_TLSv1,
156+}
157+
158+
159 class WebSocketClient(object):
160 """A simple blocking WebSocket client used in functional tests."""
161
162@@ -219,7 +229,7 @@
163
164 def connect(self):
165 """Connect to the WebSocket server."""
166- self._conn = websocket.create_connection(self._url)
167+ self._conn = websocket.create_connection(self._url, sslopt=SSLOPT)
168
169 def send(self, request):
170 """Send the given WebSocket request.
171
172=== modified file 'tests/test_helpers.py'
173--- tests/test_helpers.py 2014-01-14 23:57:37 +0000
174+++ tests/test_helpers.py 2014-09-12 13:47:41 +0000
175@@ -28,13 +28,14 @@
176
177 from helpers import (
178 command,
179- get_admin_secret,
180+ get_env_attr,
181 juju,
182 juju_destroy_service,
183 juju_env,
184 juju_status,
185 ProcessError,
186 retry,
187+ SSLOPT,
188 stop_services,
189 wait_for_unit,
190 WebSocketClient,
191@@ -270,11 +271,11 @@
192 self.assertGreater(mock_callable.call_count, 1)
193
194
195-class TestGetAdminSecret(unittest.TestCase):
196+class TestGetEnvAttr(unittest.TestCase):
197
198 def mock_environment_file(self, contents, juju_env=None):
199 """Create a mock environment file containing the given contents."""
200- # Create a temporary home that will be used by get_admin_secret().
201+ # Create a temporary home that will be used by get_env_attr().
202 home = tempfile.mkdtemp()
203 self.addCleanup(shutil.rmtree, home)
204 # Create a juju home.
205@@ -308,7 +309,7 @@
206 expected = 'Unable to retrieve the current environment name.'
207 with self.mock_environment_file(''):
208 with self.assert_error(expected):
209- get_admin_secret()
210+ get_env_attr('attr-name')
211
212 def test_no_file(self):
213 # A ValueError is raised if the environments file is not found.
214@@ -317,42 +318,42 @@
215 expected = 'Unable to open environments file: [Errno 2] No such file'
216 with mock.patch('os.environ', {'HOME': home, 'JUJU_ENV': 'ec2'}):
217 with self.assert_error(expected):
218- get_admin_secret()
219+ get_env_attr('attr-name')
220
221 def test_invalid_yaml(self):
222 # A ValueError is raised if the environments file is not well formed.
223 with self.mock_environment_file(':', juju_env='ec2'):
224 with self.assert_error('Unable to parse environments file:'):
225- get_admin_secret()
226+ get_env_attr('attr-name')
227
228 def test_invalid_yaml_contents(self):
229 # A ValueError is raised if the environments file is not well formed.
230 with self.mock_environment_file('a-string', juju_env='ec2'):
231 with self.assert_error('Invalid YAML contents: a-string'):
232- get_admin_secret()
233+ get_env_attr('attr-name')
234
235 def test_no_env(self):
236 # A ValueError is raised if the environment is not found in the YAML.
237 contents = yaml.safe_dump({'environments': {'local': {}}})
238 with self.mock_environment_file(contents, juju_env='ec2'):
239 with self.assert_error('Environment ec2 not found'):
240- get_admin_secret()
241+ get_env_attr('attr-name')
242
243- def test_no_admin_secret(self):
244- # A ValueError is raised if the admin secret is not included in the
245- # environment info.
246+ def test_attribute_not_found(self):
247+ # A ValueError is raised if the requested attribute is not included in
248+ # the environment info.
249 contents = yaml.safe_dump({'environments': {'ec2': {}}})
250 with self.mock_environment_file(contents, juju_env='ec2'):
251- with self.assert_error('Admin secret not found'):
252- get_admin_secret()
253+ with self.assert_error('Attribute attr-name not found'):
254+ get_env_attr('attr-name')
255
256 def test_ok(self):
257- # The environment admin secret is correctly returned.
258+ # The environment attribute value is correctly returned.
259 contents = yaml.safe_dump({
260- 'environments': {'ec2': {'admin-secret': 'Secret!'}},
261+ 'environments': {'ec2': {'attr-name': 'Value!'}},
262 })
263 with self.mock_environment_file(contents, juju_env='ec2'):
264- self.assertEqual('Secret!', get_admin_secret())
265+ self.assertEqual('Value!', get_env_attr('attr-name'))
266
267
268 @mock.patch('helpers.ssh')
269@@ -468,7 +469,7 @@
270 def test_connect(self, mock_create_connection):
271 # The WebSocket connection is correctly established.
272 self.client.connect()
273- mock_create_connection.assert_called_once_with(self.url)
274+ mock_create_connection.assert_called_once_with(self.url, sslopt=SSLOPT)
275
276 def test_send(self, mock_create_connection):
277 # A request is correctly sent, and a response is returned.

Subscribers

People subscribed via source and target branches