Merge lp:~frankban/charms/precise/juju-gui/new-requirements into lp:~juju-gui/charms/precise/juju-gui/trunk

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 126
Proposed branch: lp:~frankban/charms/precise/juju-gui/new-requirements
Merge into: lp:~juju-gui/charms/precise/juju-gui/trunk
Diff against target: 264 lines (+88/-34)
9 files modified
HACKING.md (+10/-0)
Makefile (+4/-1)
hooks/utils.py (+9/-17)
revision (+1/-1)
server-requirements.pip (+26/-0)
test-requirements.pip (+3/-7)
tests/00-setup (+4/-3)
tests/example.py (+2/-1)
tests/test_utils.py (+29/-4)
To merge this branch: bzr merge lp:~frankban/charms/precise/juju-gui/new-requirements
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+195100@code.launchpad.net

Description of the change

Update requirements and improve their handling.

Updated the juju-deployer and jujucleint
dependencies to the latest versions, which
include our recent fixes. This way we avoid
using our own forks of the projects.

Updated the code that installs the builtin
server dependencies: now a pip requirement
file is used, and the test requirement file
includes the former. The overall dependency
infrastructure should now be less confusing.

Also added documentation about how to update
the builtin server requirements.

Removed the no longer required --upload-tools
from the functional tests runner.

The deployer functional tests now also use
bundles including numunits > 1 and constraints.

QA:
- Bootstrap a Juju environment.
- Deploy and expose the GUI (make deploy).
- Wait for the GUI to be ready/started.
- Deploy this bundle: http://pastebin.ubuntu.com/6411548/
- Check everything is ok, xy annotations work (
  the services are vertically aligned), wordpress has
  customized constraints, mysql customized options and
  two units.
- No try to deploy the same bundle again, you
  will see a "services already there" kind of error.

https://codereview.appspot.com/26130043/

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

Reviewers: mp+195100_code.launchpad.net,

Message:
Please take a look.

Description:
Update requirements and improve their handling.

Updated the juju-deployer and jujucleint
dependencies to the latest versions, which
include our recent fixes. This way we avoid
using our own forks of the projects.

Updated the code that installs the builtin
server dependencies: now a pip requirement
file is used, and the test requirement file
includes the former. The overall dependency
infrastructure should now be less confusing.

Also added documentation about how to update
the builtin server requirements.

Removed the no longer required --upload-tools
from the functional tests runner.

The deployer functional tests now also use
bundles including numunits > 1 and constraints.

QA:
- Bootstrap a Juju environment.
- Deploy and expose the GUI (make deploy).
- Wait for the GUI to be ready/started.
- Deploy this bundle: http://pastebin.ubuntu.com/6411548/
- Check everything is ok, xy annotations work (
   the services are vertically aligned), wordpress has
   customized constraints, mysql customized options and
   two units.
- No try to deploy the same bundle again, you
   will see a "services already there" kind of error.

https://code.launchpad.net/~frankban/charms/precise/juju-gui/new-requirements/+merge/195100

(do not edit description out of merge proposal)

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

Affected files (+85, -30 lines):
   M HACKING.md
   M Makefile
   A [revision details]
   D deps/juju-deployer-0.2.8.tar.gz
   A deps/juju-deployer-0.2.9.tar.gz
   D deps/jujuclient-0.13.tar.gz
   A deps/jujuclient-0.15.tar.gz
   M hooks/utils.py
   M revision
   A server-requirements.pip
   M test-requirements.pip
   M tests/00-setup
   M tests/example.py
   M tests/test_utils.py

Revision history for this message
Gary Poster (gary) wrote :

LGTM with trivial comment request. Doing QA now.

https://codereview.appspot.com/26130043/diff/1/hooks/utils.py
File hooks/utils.py (right):

https://codereview.appspot.com/26130043/diff/1/hooks/utils.py#newcode550
hooks/utils.py:550: '--find-links', 'file:///{}'.format(deps), '-r',
requirements
yay, nice

https://codereview.appspot.com/26130043/diff/1/server-requirements.pip
File server-requirements.pip (right):

https://codereview.appspot.com/26130043/diff/1/server-requirements.pip#newcode19
server-requirements.pip:19: # Note: the order of the following
dependencies is important!
Would be nice to indicate why.

https://codereview.appspot.com/26130043/diff/1/test-requirements.pip
File test-requirements.pip (right):

https://codereview.appspot.com/26130043/diff/1/test-requirements.pip#newcode32
test-requirements.pip:32: -r server-requirements.pip
cool. I didn't know about this feature.

https://codereview.appspot.com/26130043/diff/1/tests/test_utils.py
File tests/test_utils.py (right):

https://codereview.appspot.com/26130043/diff/1/tests/test_utils.py#newcode1117
tests/test_utils.py:1117: mock.call(
wow. cool that you can do this.

https://codereview.appspot.com/26130043/

Revision history for this message
Gary Poster (gary) wrote :
139. By Francesco Banconi

Changes as per review.

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

*** Submitted:

Update requirements and improve their handling.

Updated the juju-deployer and jujucleint
dependencies to the latest versions, which
include our recent fixes. This way we avoid
using our own forks of the projects.

Updated the code that installs the builtin
server dependencies: now a pip requirement
file is used, and the test requirement file
includes the former. The overall dependency
infrastructure should now be less confusing.

Also added documentation about how to update
the builtin server requirements.

Removed the no longer required --upload-tools
from the functional tests runner.

The deployer functional tests now also use
bundles including numunits > 1 and constraints.

QA:
- Bootstrap a Juju environment.
- Deploy and expose the GUI (make deploy).
- Wait for the GUI to be ready/started.
- Deploy this bundle: http://pastebin.ubuntu.com/6411548/
- Check everything is ok, xy annotations work (
   the services are vertically aligned), wordpress has
   customized constraints, mysql customized options and
   two units.
- No try to deploy the same bundle again, you
   will see a "services already there" kind of error.

R=gary.poster
CC=
https://codereview.appspot.com/26130043

https://codereview.appspot.com/26130043/diff/1/server-requirements.pip
File server-requirements.pip (right):

https://codereview.appspot.com/26130043/diff/1/server-requirements.pip#newcode19
server-requirements.pip:19: # Note: the order of the following
dependencies is important!
On 2013/11/13 17:15:47, gary.poster wrote:
> Would be nice to indicate why.

Done.

https://codereview.appspot.com/26130043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'HACKING.md'
2--- HACKING.md 2013-10-08 15:30:04 +0000
3+++ HACKING.md 2013-11-13 17:46:04 +0000
4@@ -175,3 +175,13 @@
5 the local charm.
6 Note that at least one release must be always present in the repository,
7 otherwise the deployment process will fail.
8+
9+## Upgrading the builtin server dependencies ##
10+
11+The builtin server dependencies are stored in the `deps` directory located in
12+the branch source. This way, when the charm is deployed, the builtin server can
13+be set up without downloading dependencies from the network (pypi) and so the
14+charm deployment succeeds also behind a firewall.
15+To upgrade the dependencies, add a tarball to the `deps` directory, remove the
16+old dependency if required, and update the `server-requirements.pip` file.
17+At this point, running `make` should also update the virtualenv used for tests.
18
19=== modified file 'Makefile'
20--- Makefile 2013-11-12 16:38:27 +0000
21+++ Makefile 2013-11-13 17:46:04 +0000
22@@ -14,13 +14,16 @@
23 # You should have received a copy of the GNU Affero General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
26-JUJUTEST = juju-test --timeout=120m -v -e "$(JUJU_ENV)" --upload-tools
27+JUJUTEST = juju-test --timeout=120m -v -e "$(JUJU_ENV)"
28 VENV = ./tests/.venv
29 SYSDEPS = build-essential bzr libapt-pkg-dev python-pip python-virtualenv xvfb \
30 libpython-dev
31
32 all: setup
33
34+# The virtualenv is created by the 00-setup script and not here. This way we
35+# support the juju-test plugin, which calls the executable files in
36+# alphabetical order.
37 setup:
38 @./tests/00-setup
39
40
41=== removed file 'deps/juju-deployer-0.2.8.tar.gz'
42Binary files deps/juju-deployer-0.2.8.tar.gz 2013-11-07 11:45:47 +0000 and deps/juju-deployer-0.2.8.tar.gz 1970-01-01 00:00:00 +0000 differ
43=== added file 'deps/juju-deployer-0.2.9.tar.gz'
44Binary files deps/juju-deployer-0.2.9.tar.gz 1970-01-01 00:00:00 +0000 and deps/juju-deployer-0.2.9.tar.gz 2013-11-13 17:46:04 +0000 differ
45=== removed file 'deps/jujuclient-0.13.tar.gz'
46Binary files deps/jujuclient-0.13.tar.gz 2013-11-07 17:27:20 +0000 and deps/jujuclient-0.13.tar.gz 1970-01-01 00:00:00 +0000 differ
47=== added file 'deps/jujuclient-0.15.tar.gz'
48Binary files deps/jujuclient-0.15.tar.gz 1970-01-01 00:00:00 +0000 and deps/jujuclient-0.15.tar.gz 2013-11-13 17:46:04 +0000 differ
49=== modified file 'hooks/utils.py'
50--- hooks/utils.py 2013-11-07 17:27:20 +0000
51+++ hooks/utils.py 2013-11-13 17:46:04 +0000
52@@ -114,19 +114,6 @@
53 JUJU_AGENT_DIR = os.path.join(BASE_DIR, 'juju')
54 JUJU_GUI_DIR = os.path.join(BASE_DIR, 'juju-gui')
55 RELEASES_DIR = os.path.join(CURRENT_DIR, 'releases')
56-# Builtin server dependencies. The order of these requirements is important.
57-SERVER_DEPENDENCIES = (
58- 'futures-2.1.4.tar.gz',
59- 'tornado-3.1.1.tar.gz',
60- 'websocket-client-0.12.0.tar.gz',
61- # XXX frankban 2013-11-07: we are currently using a customized jujuclient
62- # version built from this branch:
63- # lp:~frankban/python-jujuclient/pickable-enverror.
64- 'jujuclient-0.13.tar.gz',
65- # XXX frankban 2013-11-07: we are currently using a customized deployer
66- # version built from this branch: lp:~frankban/juju-deployer/guienv-fixes.
67- 'juju-deployer-0.2.8.tar.gz',
68-)
69 SERVER_DIR = os.path.join(CURRENT_DIR, 'server')
70
71 APACHE_CFG_DIR = os.path.join(os.path.sep, 'etc', 'apache2')
72@@ -553,10 +540,15 @@
73 def install_builtin_server():
74 """Install the builtin server code."""
75 log('Installing the builtin server dependencies.')
76- for dependency_name in SERVER_DEPENDENCIES:
77- dependency = os.path.join(CURRENT_DIR, 'deps', dependency_name)
78- with su('root'):
79- cmd_log(run('pip', 'install', dependency))
80+ deps = os.path.join(CURRENT_DIR, 'deps')
81+ requirements = os.path.join(CURRENT_DIR, 'server-requirements.pip')
82+ # Install the builtin server dependencies avoiding to download requirements
83+ # from the network.
84+ with su('root'):
85+ cmd_log(run(
86+ 'pip', 'install', '--no-index', '--no-dependencies',
87+ '--find-links', 'file:///{}'.format(deps), '-r', requirements
88+ ))
89 log('Installing the builtin server.')
90 setup_cmd = os.path.join(SERVER_DIR, 'setup.py')
91 with su('root'):
92
93=== modified file 'revision'
94--- revision 2013-11-12 16:39:09 +0000
95+++ revision 2013-11-13 17:46:04 +0000
96@@ -1,1 +1,1 @@
97-96
98+97
99
100=== added file 'server-requirements.pip'
101--- server-requirements.pip 1970-01-01 00:00:00 +0000
102+++ server-requirements.pip 2013-11-13 17:46:04 +0000
103@@ -0,0 +1,26 @@
104+# Juju GUI server requirements.
105+
106+# This file is part of the Juju GUI, which lets users view and manage Juju
107+# environments within a graphical interface (https://launchpad.net/juju-gui).
108+# Copyright (C) 2012-2013 Canonical Ltd.
109+#
110+# This program is free software: you can redistribute it and/or modify it under
111+# the terms of the GNU Affero General Public License version 3, as published by
112+# the Free Software Foundation.
113+#
114+# This program is distributed in the hope that it will be useful, but WITHOUT
115+# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
116+# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
117+# Affero General Public License for more details.
118+#
119+# You should have received a copy of the GNU Affero General Public License
120+# along with this program. If not, see <http://www.gnu.org/licenses/>.
121+
122+# Note: the order of the following dependencies is important! The last ones
123+# depends on the previous.
124+
125+futures==2.1.4
126+tornado==3.1.1
127+websocket-client==0.12.0
128+jujuclient==0.15
129+juju-deployer==0.2.9
130
131=== renamed file 'tests/requirements.pip' => 'test-requirements.pip'
132--- tests/requirements.pip 2013-11-07 17:27:20 +0000
133+++ test-requirements.pip 2013-11-13 17:46:04 +0000
134@@ -24,18 +24,12 @@
135
136 # GUI server -> juju deployer.
137 bzr==2.6.0
138-jujuclient==0.13
139-
140-# Charm tests + juju deployer.
141-websocket-client==0.12.0
142
143 # Charm hooks + GUI server.
144 PyYAML==3.10
145
146 # GUI server.
147-futures==2.1.4
148-juju-deployer==0.2.8
149-tornado==3.1.1
150+-r server-requirements.pip
151
152 # Charm hooks.
153 launchpadlib==1.10.2
154@@ -43,6 +37,8 @@
155 Tempita==0.5.1
156
157 # Charm tests + GUI server tests.
158+# Note that websocket-client, required by charm integration tests,
159+# is already installed by server-requirements.
160 flake8==2.0
161 mock==1.0.1
162
163
164=== modified file 'tests/00-setup'
165--- tests/00-setup 2013-11-06 18:48:54 +0000
166+++ tests/00-setup 2013-11-13 17:46:04 +0000
167@@ -19,16 +19,17 @@
168 TESTDIR=`dirname $0`
169 VENV="$TESTDIR/.venv"
170 ACTIVATE="$VENV/bin/activate"
171-REQUIREMENTS="$TESTDIR/requirements.pip"
172+TEST_REQUIREMENTS="test-requirements.pip"
173+SERVER_REQUIREMENTS="server-requirements.pip"
174
175
176 createvenv() {
177 # Create a virtualenv if it does not exist, or it is older than requirements.
178- if [ ! -f "$ACTIVATE" -o "$REQUIREMENTS" -nt "$ACTIVATE" ]; then
179+ if [ ! -f "$ACTIVATE" -o "$TEST_REQUIREMENTS" -nt "$ACTIVATE" -o "$SERVER_REQUIREMENTS" -nt "$ACTIVATE" ]; then
180 virtualenv --distribute $VENV
181 . $VENV/bin/activate && \
182 yes w | env BZR_PLUGIN_PATH='-user' \
183- pip install --use-mirrors -r $REQUIREMENTS --find-links deps
184+ pip install --use-mirrors -r $TEST_REQUIREMENTS --find-links deps
185 touch $VENV/bin/activate
186 fi
187 }
188
189=== modified file 'tests/example.py'
190--- tests/example.py 2013-09-24 16:45:46 +0000
191+++ tests/example.py 2013-11-13 17:46:04 +0000
192@@ -29,12 +29,13 @@
193 engine: nginx
194 tuning: single
195 "wp-content": ""
196+ constraints: "cpu-cores=4,mem=4000"
197 annotations:
198 "gui-x": 313
199 "gui-y": 51
200 mysql:
201 charm: "cs:precise/mysql-26"
202- num_units: 1
203+ num_units: 2
204 options:
205 "binlog-format": MIXED
206 "block-size": "5"
207
208=== modified file 'tests/test_utils.py'
209--- tests/test_utils.py 2013-11-07 11:17:54 +0000
210+++ tests/test_utils.py 2013-11-13 17:46:04 +0000
211@@ -34,7 +34,6 @@
212 API_PORT,
213 JUJU_GUI_DIR,
214 JUJU_PEM,
215- SERVER_DEPENDENCIES,
216 WEB_PORT,
217 _get_by_attr,
218 cmd_log,
219@@ -978,9 +977,9 @@
220
221 def test_install_builtin_server(self):
222 install_builtin_server()
223- # The function executes one "pip install" call for each dependency, and
224- # a final "python setup.py" call for the GUI server itself.
225- self.assertEqual(self.run_call_count, len(SERVER_DEPENDENCIES) + 1)
226+ # Two run calls are executed: one for the dependencies, one for the
227+ # server itself.
228+ self.assertEqual(2, self.run_call_count)
229
230 def test_write_builtin_server_startup(self):
231 write_builtin_server_startup(
232@@ -1100,6 +1099,32 @@
233
234
235 @mock.patch('utils.run')
236+@mock.patch('utils.log')
237+@mock.patch('utils.cmd_log', mock.Mock())
238+@mock.patch('utils.su', mock.MagicMock())
239+class TestInstallBuiltinServer(unittest.TestCase):
240+
241+ def test_call(self, mock_log, mock_run):
242+ # The builtin server its correctly installed.
243+ install_builtin_server()
244+ charm_dir = os.path.abspath(
245+ os.path.join(os.path.dirname(__file__), '..'))
246+ mock_log.assert_has_calls([
247+ mock.call('Installing the builtin server dependencies.'),
248+ mock.call('Installing the builtin server.'),
249+ ])
250+ mock_run.assert_has_calls([
251+ mock.call(
252+ 'pip', 'install', '--no-index', '--no-dependencies',
253+ '--find-links', 'file:///{}/deps'.format(charm_dir),
254+ '-r', os.path.join(charm_dir, 'server-requirements.pip')),
255+ mock.call(
256+ '/usr/bin/python',
257+ os.path.join(charm_dir, 'server', 'setup.py'), 'install')
258+ ])
259+
260+
261+@mock.patch('utils.run')
262 @mock.patch('utils.cmd_log', mock.Mock())
263 @mock.patch('utils.log', mock.Mock())
264 @mock.patch('utils.su', mock.MagicMock())

Subscribers

People subscribed via source and target branches