Merge lp:~gary/charms/precise/juju-gui/download-cache into lp:~juju-gui/charms/precise/juju-gui/trunk

Proposed by Gary Poster
Status: Merged
Merged at revision: 133
Proposed branch: lp:~gary/charms/precise/juju-gui/download-cache
Merge into: lp:~juju-gui/charms/precise/juju-gui/trunk
Diff against target: 136 lines (+52/-6)
7 files modified
.bzrignore (+1/-0)
HACKING.md (+21/-0)
Makefile (+1/-0)
test-requirements.pip (+19/-0)
tests/00-setup (+8/-1)
tests/deploy.py (+1/-1)
tests/test_deploy.py (+1/-4)
To merge this branch: bzr merge lp:~gary/charms/precise/juju-gui/download-cache
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+195700@code.launchpad.net

Description of the change

Add a download cache for test dependencies

To QA, remove the .venv in your tests dir and try running make. It is a lot faster and more reliable for me. Testing make clean would be good too.

https://codereview.appspot.com/28770043/

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :
Download full text (4.8 KiB)

Reviewers: mp+195700_code.launchpad.net,

Message:
Please take a look.

Description:
Add a download cache for test dependencies

To QA, remove the .venv in your tests dir and try running make. It is a
lot faster and more reliable for me. Testing make clean would be good
too.

https://code.launchpad.net/~gary/charms/precise/juju-gui/download-cache/+merge/195700

(do not edit description out of merge proposal)

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

Affected files (+49, -1 lines):
   M .bzrignore
   M HACKING.md
   M Makefile
   A [revision details]
   M test-requirements.pip
   M tests/00-setup

Index: .bzrignore
=== modified file '.bzrignore'
--- .bzrignore 2013-07-17 15:23:10 +0000
+++ .bzrignore 2013-11-19 02:50:54 +0000
@@ -6,3 +6,4 @@
  server/dist
  server/MANIFEST
  tests/.venv
+tests/download-cache

Index: HACKING.md
=== modified file 'HACKING.md'
--- HACKING.md 2013-11-12 17:35:42 +0000
+++ HACKING.md 2013-11-19 02:50:54 +0000
@@ -185,3 +185,24 @@
  To upgrade the dependencies, add a tarball to the `deps` directory, remove
the
  old dependency if required, and update the `server-requirements.pip` file.
  At this point, running `make` should also update the virtualenv used for
tests.
+
+## Upgrading the test dependencies ##
+
+The tests also have a number of dependencies. For speed and reliability,
these
+are also in a directory. However, they are not necessary for normal use
of the
+charm, and so, unlike the server dependencies, they are not part of the
normal
+charm branch. The 00-setup script makes a lightweight checkout of the
branch
+lp:~juju-gui-charmers/juju-gui/charm-download-cache and then uses this to
build
+the test virtual environment.
+
+To take best advantage of this approach, either use the same charm branch
+repeatedly for development; or develop the charm within a parent directory
+in which you have run `bzr init-repo`, so that the different branches can
use
+the local cache; or both.
+
+To upgrade test dependencies, add them to the `test-requirements.pip` file
and
+add the tarballs to the download-cache branch. You may need to temporarily
+disable the `--no-allow-external` and `--no-index` flags in 00-setup to get
+new transitive dependencies. Once you do, run `pip freeze` to add the
+transitive dependencies to the `test-requirements.pip` file, and make sure
to
+add those tarballs to the download cache as well.

Index: Makefile
=== modified file 'Makefile'
--- Makefile 2013-11-14 08:52:35 +0000
+++ Makefile 2013-11-19 02:50:54 +0000
@@ -62,6 +62,7 @@
  clean:
   find . -name '*.pyc' -delete
   rm -rf $(VENV)
+ rm -rf tests/download-cache

  deploy: setup
   $(VENV)/bin/python ./tests/deploy.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: test-requirements.pip
=== modified file 'test-requirements.pip'
--- test-requirements.pip 2013-11-12 12:15:52 +0000
+++ test-requirements.pip 2013-11-19 0...

Read more...

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

A very nice improvement Gary, thank you!
Running "make" successfully checked out the download cache branch in my
sandbox/tests/ directory.
LGTM with two comments, one below, one here:

"make deploy" is implemented in tests/deploy.py. As you can see, it
creates a temporary charm repository where the charm is copied using
rsync, and two directories are excluded: .bzr and .venv. I'd be inclined
to also exclude the download cache branch: it's ~16MB and I presume it
would sensibly slows down the deployment process. FWIW, I think it
should work also excluding the whole tests/ directory (it shouldn't be
required in that context), I'll give it a try later.

https://codereview.appspot.com/28770043/diff/1/tests/00-setup
File tests/00-setup (right):

https://codereview.appspot.com/28770043/diff/1/tests/00-setup#newcode33
tests/00-setup:33: if [ ! -f "$ACTIVATE" -o "$TEST_REQUIREMENTS" -nt
"$ACTIVATE" -o "$SERVER_REQUIREMENTS" -nt "$ACTIVATE" ]; then
What do you think about updating the download cache branch when at least
one of the requirement files is outdated?

IIUC, if user X updated the requirements, it is likely that also the
download cache has been updated. In this case, user Y will just run make
to get the new cache branch revision. Subsequently "pip install" can
proceed correctly.

https://codereview.appspot.com/28770043/

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

FWIW, this diff here seems to work:
http://pastebin.ubuntu.com/6442036/

Note the leading slash in '/tests': that's important in order to only
exclude the tests directory in the branch root, and not, e.g., the
guiserver tests (which are required to setup.py install the builtin
server).

As mentioned, another possibility is to just exclude the download cache
directory. Another idea could be running "make clean" in the target
repository, so that the process is slightly automated. Unfortunately,
this would leave the .bzr directory in the temporary repository. <shrug>

https://codereview.appspot.com/28770043/

134. By Gary Poster

respond to review

135. By Gary Poster

update test per change

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

*** Submitted:

Add a download cache for test dependencies

To QA, remove the .venv in your tests dir and try running make. It is a
lot faster and more reliable for me. Testing make clean would be good
too.

R=frankban
CC=
https://codereview.appspot.com/28770043

https://codereview.appspot.com/28770043/

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

Thank you for the great review and suggestions, Francesco. I
implemented both, choosing to use the /tests approach you mentioned for
the first one.

https://codereview.appspot.com/28770043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2013-07-17 15:23:10 +0000
3+++ .bzrignore 2013-11-19 15:08:56 +0000
4@@ -6,3 +6,4 @@
5 server/dist
6 server/MANIFEST
7 tests/.venv
8+tests/download-cache
9
10=== modified file 'HACKING.md'
11--- HACKING.md 2013-11-12 17:35:42 +0000
12+++ HACKING.md 2013-11-19 15:08:56 +0000
13@@ -185,3 +185,24 @@
14 To upgrade the dependencies, add a tarball to the `deps` directory, remove the
15 old dependency if required, and update the `server-requirements.pip` file.
16 At this point, running `make` should also update the virtualenv used for tests.
17+
18+## Upgrading the test dependencies ##
19+
20+The tests also have a number of dependencies. For speed and reliability, these
21+are also in a directory. However, they are not necessary for normal use of the
22+charm, and so, unlike the server dependencies, they are not part of the normal
23+charm branch. The 00-setup script makes a lightweight checkout of the branch
24+lp:~juju-gui-charmers/juju-gui/charm-download-cache and then uses this to build
25+the test virtual environment.
26+
27+To take best advantage of this approach, either use the same charm branch
28+repeatedly for development; or develop the charm within a parent directory
29+in which you have run `bzr init-repo`, so that the different branches can use
30+the local cache; or both.
31+
32+To upgrade test dependencies, add them to the `test-requirements.pip` file and
33+add the tarballs to the download-cache branch. You may need to temporarily
34+disable the `--no-allow-external` and `--no-index` flags in 00-setup to get
35+new transitive dependencies. Once you do, run `pip freeze` to add the
36+transitive dependencies to the `test-requirements.pip` file, and make sure to
37+add those tarballs to the download cache as well.
38
39=== modified file 'Makefile'
40--- Makefile 2013-11-14 08:52:35 +0000
41+++ Makefile 2013-11-19 15:08:56 +0000
42@@ -62,6 +62,7 @@
43 clean:
44 find . -name '*.pyc' -delete
45 rm -rf $(VENV)
46+ rm -rf tests/download-cache
47
48 deploy: setup
49 $(VENV)/bin/python ./tests/deploy.py
50
51=== modified file 'test-requirements.pip'
52--- test-requirements.pip 2013-11-12 12:15:52 +0000
53+++ test-requirements.pip 2013-11-19 15:08:56 +0000
54@@ -45,3 +45,22 @@
55 # Charm tests.
56 selenium==2.34.0
57 xvfbwrapper==0.2.2
58+
59+
60+## The following requirements were added by pip --freeze:
61+argparse==1.2.1
62+httplib2==0.8
63+keyring==3.2.1
64+lazr.authentication==0.1.2
65+lazr.restfulclient==0.13.3
66+lazr.uri==1.0.3
67+mccabe==0.2.1
68+oauth==1.0.1
69+pep8==1.4.6
70+pyflakes==0.7.3
71+simplejson==3.3.1
72+testresources==0.2.7
73+wadllib==1.3.2
74+wsgi-intercept==0.6.0
75+wsgiref==0.1.2
76+zope.interface==4.0.5
77
78=== modified file 'tests/00-setup'
79--- tests/00-setup 2013-11-14 12:20:12 +0000
80+++ tests/00-setup 2013-11-19 15:08:56 +0000
81@@ -17,6 +17,7 @@
82 # along with this program. If not, see <http://www.gnu.org/licenses/>.
83
84 TESTDIR=`dirname $0`
85+DOWNLOADCACHE="$TESTDIR/download-cache"
86 VENV="$TESTDIR/.venv"
87 ACTIVATE="$VENV/bin/activate"
88 TEST_REQUIREMENTS="test-requirements.pip"
89@@ -26,11 +27,17 @@
90 createvenv() {
91 # Create a virtualenv if it does not exist, or it is older than requirements.
92 retcode=0
93+ updated_downloadcache=0
94+ if [ ! -d "$DOWNLOADCACHE" ]; then
95+ bzr co --lightweight lp:~juju-gui-charmers/juju-gui/charm-download-cache $DOWNLOADCACHE
96+ updated_downloadcache=1
97+ fi
98 if [ ! -f "$ACTIVATE" -o "$TEST_REQUIREMENTS" -nt "$ACTIVATE" -o "$SERVER_REQUIREMENTS" -nt "$ACTIVATE" ]; then
99+ [ $updated_downloadcache -eq 0 ] && bzr up $DOWNLOADCACHE
100 virtualenv --distribute $VENV
101 . $ACTIVATE && \
102 yes w | env BZR_PLUGIN_PATH='-user' \
103- pip install --use-mirrors -r $TEST_REQUIREMENTS --find-links deps
104+ pip install -r $TEST_REQUIREMENTS --find-links deps --find-links $DOWNLOADCACHE --no-allow-external --no-index
105 retcode=$?
106 [ $retcode -eq 0 ] && touch $ACTIVATE || touch $TEST_REQUIREMENTS
107 fi
108
109=== modified file 'tests/deploy.py'
110--- tests/deploy.py 2013-08-08 13:09:10 +0000
111+++ tests/deploy.py 2013-11-19 15:08:56 +0000
112@@ -30,7 +30,7 @@
113 )
114
115
116-rsync = command('rsync', '-a', '--exclude', '.bzr', '--exclude', '.venv')
117+rsync = command('rsync', '-a', '--exclude', '.bzr', '--exclude', '/tests')
118
119
120 def setup_repository(name, source, series='precise'):
121
122=== modified file 'tests/test_deploy.py'
123--- tests/test_deploy.py 2013-08-08 13:53:54 +0000
124+++ tests/test_deploy.py 2013-11-19 15:08:56 +0000
125@@ -94,11 +94,8 @@
126 # unwanted directories.
127 repo = setup_repository(self.name, self.source)
128 charm_dir = os.path.join(repo, 'precise', self.name)
129- test_dir_name = os.path.basename(self.tests_dir)
130 expected = set([
131- os.path.basename(self.root_file),
132- test_dir_name + os.path.sep,
133- os.path.join(test_dir_name, os.path.basename(self.tests_file))
134+ os.path.basename(self.root_file)
135 ])
136 self.assert_files_equal(expected, charm_dir)
137

Subscribers

People subscribed via source and target branches

to all changes: