Merge lp:~hopem/charm-helpers/lp1257763 into lp:charm-helpers

Proposed by Edward Hope-Morley
Status: Work in progress
Proposed branch: lp:~hopem/charm-helpers/lp1257763
Merge into: lp:charm-helpers
Diff against target: 164 lines (+74/-30)
6 files modified
.bzrignore (+1/-0)
Makefile (+19/-8)
README.test (+8/-8)
test-requirements-precise.txt (+15/-0)
test-requirements-trusty.txt (+8/-14)
tox.ini (+23/-0)
To merge this branch: bzr merge lp:~hopem/charm-helpers/lp1257763
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Needs Resubmitting
Liam Young Pending
James Page Pending
Jorge Niedbalski Pending
Cory Johns Pending
Kapil Thangavelu Pending
Benjamin Saller Pending
Review via email: mp+233685@code.launchpad.net

This proposal supersedes a proposal from 2014-09-01.

Description of the change

Resubmitting with reviewer changes applied.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote : Posted in a previous version of this proposal

Interestingly I start seeing errors when using tox - lists seem to be out of order...

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

Hmm dep versions need tweaking perhaps. Will dig...

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

Should be working better now, tested on Trusty. I had to apt-get build-dep a could of dependencies to get it to work tho (see commit message).

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

@jamespage quick thought, which version of tox are you using? I am using tox==1.6.1 since newer versions seem to flake out with openstack.

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

So, some more info. I have now tested this on precise, trusty, utopic and all work fine with tox==1.6.1 (incidentally the version used with openstack since never versions seem to break) but if I use latest i.e. tox==1.7.2 I get a bunch of unit test errors where lists have reversed order.

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

Adding in support dist-specific deps i.e. precise, trusty...

Revision history for this message
Benjamin Saller (bcsaller) wrote : Posted in a previous version of this proposal

Thanks for this.

If you agree with the following I'm +1 on this.

=== modified file 'tox.ini'
--- tox.ini 2014-08-07 10:24:25 +0000
+++ tox.ini 2014-08-18 17:06:39 +0000
@@ -17,7 +17,7 @@

 [testenv:pep8]
 deps = -r{toxinidir}/test-requirements-trusty.txt
-commands = flake8 --ignore=E123,E501 {posargs}
+commands = flake8 --ignore=E123,E501 {posargs} charmhelpers

 [testenv:venv]
 commands = {posargs}

Currently it runs pep8 on the whole stdlib making its long and the feedback ignorable.

review: Needs Fixing
Revision history for this message
Jorge Niedbalski (niedbalski) wrote : Posted in a previous version of this proposal

Hello,

I am more than happy to see this change set landing on charmhelpers. I will second the change proposed by @bcsaller.

With that fixed, LGTM.

review: Needs Fixing
Revision history for this message
Cory Johns (johnsca) wrote : Posted in a previous version of this proposal

> Interestingly I start seeing errors when using tox - lists seem to be out of
> order...

I had proposed another tox merge with fixes for the fragile tests: https://code.launchpad.net/~johnsca/charm-helpers/tox/+merge/226180 (lines 157 through 266 in that diff).

However, that merge stalled because it contained wheel files for some of the dependencies, so maybe the test fixes could be ported to this MP and I could retire mine?

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

> > Interestingly I start seeing errors when using tox - lists seem to be out of
> > order...
>
> I had proposed another tox merge with fixes for the fragile tests:
> https://code.launchpad.net/~johnsca/charm-helpers/tox/+merge/226180 (lines 157
> through 266 in that diff).
>
> However, that merge stalled because it contained wheel files for some of the
> dependencies, so maybe the test fixes could be ported to this MP and I could
> retire mine?

Cory, I am concerned that the test errors (list inversions) caused by newer versions of tox are a result of tox causing some unexpected side effects in the tests, the scope of which is unclear. It is partially for this reason that I decided to pin tox to 1.6.1 which incidentally is the same rule currently used in upstream openstack.

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

> Thanks for this.
>
> If you agree with the following I'm +1 on this.
>
> === modified file 'tox.ini'
> --- tox.ini 2014-08-07 10:24:25 +0000
> +++ tox.ini 2014-08-18 17:06:39 +0000
> @@ -17,7 +17,7 @@
>
> [testenv:pep8]
> deps = -r{toxinidir}/test-requirements-trusty.txt
> -commands = flake8 --ignore=E123,E501 {posargs}
> +commands = flake8 --ignore=E123,E501 {posargs} charmhelpers
>
> [testenv:venv]
> commands = {posargs}
>
>
> Currently it runs pep8 on the whole stdlib making its long and the feedback
> ignorable.

Agreed, will fix. Thanks for reviewing.

Revision history for this message
Cory Johns (johnsca) wrote : Posted in a previous version of this proposal

> Cory, I am concerned that the test errors (list inversions) caused by newer
> versions of tox are a result of tox causing some unexpected side effects in
> the tests, the scope of which is unclear. It is partially for this reason that
> I decided to pin tox to 1.6.1 which incidentally is the same rule currently
> used in upstream openstack.

The failures that I fixed in my merge are just tests relying on the ordering of of keyword args (i.e., dict items), which is undefined and subject to change at any time. My fixes just remove the strict ordering dependencies by replacing, e.g., assertEqual() with assertItemsEqual(). Without those changes, these tests are pretty much guaranteed to fail at some point.

I'm not averse to pinning the version of tox, but I think those test fixes should be made regardless.

Revision history for this message
Corey Bryant (corey.bryant) wrote : Posted in a previous version of this proposal

For the most part this looks good to me and works well. I added a few minor suggestions inline. Also, is README.tests out of date? It seems like it could be updated or removed.

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

@corey.bryant - changes applied

@corey.johnsca - sounds like the newer versions of tox are just stricter in which case it is not a bug and you are absolutely correct. Could we possibly apply your suggested fixes as part of a separate patchset in order to avoid bloating this one? (if you agree i'll raise a seperate bug to get it fixed).

Revision history for this message
Corey Bryant (corey.bryant) wrote : Posted in a previous version of this proposal

Sorry, a few more comments inline below.

Revision history for this message
Cory Johns (johnsca) wrote : Posted in a previous version of this proposal

> @corey.johnsca - sounds like the newer versions of tox are just stricter in
> which case it is not a bug and you are absolutely correct. Could we possibly
> apply your suggested fixes as part of a separate patchset in order to avoid
> bloating this one? (if you agree i'll raise a seperate bug to get it fixed).

The problem is that the tox version only incidentally fixes the tests, because the ordering of dict items is arbitrary, even though it is mostly consistent. The docs (https://docs.python.org/2/library/stdtypes.html#dict.items) describe it as:

> CPython implementation detail: Keys and values are listed in an arbitrary
> order which is non-random, varies across Python implementations, and
> depends on the dictionary’s history of insertions and deletions.

Obviously, it's consistent enough that it hasn't been a big concern before now, but if we get these tests running under CI, as should be done, they will likely fail again at some point, even with the fixed version of tox.

That said, I'm fine with making the test fixes as part of a separate MP since they're not exactly related to the tox change and they pass most of the time. I'll go ahead and create the separate MP with just the test fixes.

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

@johnsca sure, let me know if/when you do this.

@corey.bryant i resubmitted this proposal after you added your last comments. I will address them now and resubmit.

Revision history for this message
Stuart Bishop (stub) wrote :

This branch has grown a pile of conflicts and alas needs to be reworked to support both Python 2 and Python 3.

review: Needs Resubmitting

Unmerged revisions

194. By Edward Hope-Morley

* allow DIST to be set in env
* added extra deps to README.test

193. By Edward Hope-Morley

applied corey.bryant changes

192. By Edward Hope-Morley

synced lp:charm-helpers

191. By Edward Hope-Morley

synced trunk

190. By Edward Hope-Morley

added specific dirs to pep8 tox run

189. By Edward Hope-Morley

added tox version check

188. By Edward Hope-Morley

pep8/lint should always be trusty

187. By Edward Hope-Morley

synced trunk and resolved merge conflicts

186. By Edward Hope-Morley

Added support for distribition specific dependencies

We now default to current LTS but can switch to other dist deps if needed.

185. By Edward Hope-Morley

* don't use site-packages
* set versions to trusty
* need to do this prior run:
    sudo apt-get build-dep python-launchpadlib
    sudo apt-get build-dep python-apt

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-06-09 14:56:35 +0000
3+++ .bzrignore 2014-09-08 09:30:18 +0000
4@@ -7,3 +7,4 @@
5 .env/
6 coverage.xml
7 docs/_build
8+.tox
9
10=== modified file 'Makefile'
11--- Makefile 2014-07-30 13:30:43 +0000
12+++ Makefile 2014-09-08 09:30:18 +0000
13@@ -1,7 +1,10 @@
14-PROJECT=charmhelpers
15 PYTHON := /usr/bin/env python
16 SUITE=unstable
17-TESTS=tests/
18+# Default to current LTS. Supported envs are [precise,trusty].
19+ifndef DIST
20+ DIST=trusty
21+endif
22+TOXVER=$(shell pip show tox| grep "^Version:"| awk '{print $$2}')
23
24 all:
25 @echo "make source - Create source package"
26@@ -33,17 +36,25 @@
27 scripts/update-revno
28 python setup.py install --user
29
30-test:
31+# Newer versions of tox break the tests. Upstream Openstack also pin to this
32+# version since newer versions seem to break backwards-compatibilty.
33+assert_tox_ver:
34+ifneq ($(TOXVER),1.6.1)
35+ @echo "ERROR: tox==1.6.1 required (currently '$(TOXVER)') - try 'sudo pip install tox==1.6.1'"
36+ exit 1
37+endif
38+
39+test: assert_tox_ver
40 @echo Starting tests...
41- @$(PYTHON) /usr/bin/nosetests -s --nologcapture tests/
42+ @tox -epy27-$(DIST) -- -s
43
44-ftest:
45+ftest: assert_tox_ver
46 @echo Starting fast tests...
47- @$(PYTHON) /usr/bin/nosetests --attr '!slow' --nologcapture tests/
48+ @tox -epy27-$(DIST) -- --attr '!slow'
49
50-lint:
51+lint: assert_tox_ver
52 @echo Checking for Python syntax...
53- @flake8 --ignore=E123,E501 $(PROJECT) $(TESTS) && echo OK
54+ @tox -epep8
55
56 docs:
57 - [ -z "`dpkg -l | grep python-sphinx`" ] && sudo apt-get install python-sphinx -y
58
59=== modified file 'README.test'
60--- README.test 2014-07-30 13:30:43 +0000
61+++ README.test 2014-09-08 09:30:18 +0000
62@@ -1,12 +1,12 @@
63 Required Packages for Running Tests
64 -----------------------------------
65-python-shelltoolbox
66-python-tempita
67+make
68 python-nose
69-python-mock
70-python-testtools
71-python-jinja2
72-python-coverage
73-python-netifaces
74-python-netaddr
75+python-pip
76+tox==1.6.1
77+python-dev
78+libapt-pkg-dev
79 zip
80+
81+NOTE: the first time tests are run it is usually necessary to install some build
82+ dependencies for some of the test-requirements (apt-get build-dep).
83
84=== added file 'test-requirements-precise.txt'
85--- test-requirements-precise.txt 1970-01-01 00:00:00 +0000
86+++ test-requirements-precise.txt 2014-09-08 09:30:18 +0000
87@@ -0,0 +1,15 @@
88+coverage==3.7.1
89+launchpadlib==1.10.2
90+mock==1.0.1
91+nose==1.1.2
92+PyYAML==3.10
93+python-apt==0.8.5
94+simplejson==3.3.1
95+testtools==0.9.35
96+Tempita==0.5.1
97+bzr+http://bazaar.launchpad.net/~yellow/python-shelltoolbox/trunk@17#egg=shelltoolbox
98+netifaces==0.8
99+netaddr==0.7.10
100+bzr==2.6.0
101+Jinja2==2.6
102+flake8==2.1.0
103
104=== renamed file 'test_requirements.txt' => 'test-requirements-trusty.txt'
105--- test_requirements.txt 2014-07-09 15:58:35 +0000
106+++ test-requirements-trusty.txt 2014-09-08 09:30:18 +0000
107@@ -1,21 +1,15 @@
108-# If you don't have the required packages on your system and prefer
109-# to keep your system clean, you can do the following to run the
110-# charm-helper test suite:
111-# $ virtualenv .env
112-# $ . .env/bin/activate
113-# $ pip install -r test_requirements.txt
114-# NOTE: python-apt is compiled and will require libapt-pkg-dev for headers.
115-# Then `make test` should find all its dependencies.
116-coverage==3.6
117+coverage==3.7.1
118 launchpadlib==1.10.2
119 mock==1.0.1
120 nose==1.3.1
121 PyYAML==3.10
122-python-apt
123-simplejson==3.3.0
124-testtools
125-Tempita==0.5.1
126+python-apt==0.8.5
127+simplejson==3.3.1
128+testtools==0.9.35
129+Tempita==0.5.2
130 bzr+http://bazaar.launchpad.net/~yellow/python-shelltoolbox/trunk@17#egg=shelltoolbox
131-http://alastairs-place.net/projects/netifaces/netifaces-0.6.tar.gz
132+netifaces==0.8
133+netaddr==0.7.10
134 bzr==2.6.0
135 Jinja2==2.7.2
136+flake8==2.1.0
137
138=== added file 'tox.ini'
139--- tox.ini 1970-01-01 00:00:00 +0000
140+++ tox.ini 2014-09-08 09:30:18 +0000
141@@ -0,0 +1,23 @@
142+[tox]
143+# Default to current LTS
144+envlist = pep8,py27-trusty
145+skipsdist = True
146+
147+[testenv]
148+install_command = pip install --allow-unverified launchpadlib --allow-unverified lazr.authentication --allow-unverified python-apt {opts} {packages}
149+commands = nosetests --nologcapture {posargs:tests} tests
150+
151+[testenv:py27-precise]
152+basepython = python2.7
153+deps = -r{toxinidir}/test-requirements-precise.txt
154+
155+[testenv:py27-trusty]
156+basepython = python2.7
157+deps = -r{toxinidir}/test-requirements-trusty.txt
158+
159+[testenv:pep8]
160+deps = -r{toxinidir}/test-requirements-trusty.txt
161+commands = flake8 --ignore=E123,E501 {posargs} charmhelpers tests
162+
163+[testenv:venv]
164+commands = {posargs}

Subscribers

People subscribed via source and target branches