Merge lp:~gocept/landscape-client/test-python3-ported into lp:~landscape/landscape-client/trunk

Proposed by Steffen Allner
Status: Merged
Approved by: Данило Шеган
Approved revision: 956
Merged at revision: 953
Proposed branch: lp:~gocept/landscape-client/test-python3-ported
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 65 lines (+35/-2)
2 files modified
Makefile (+13/-2)
py3_ready_tests (+22/-0)
To merge this branch: bzr merge lp:~gocept/landscape-client/test-python3-ported
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
🤖 Landscape Builder test results Approve
Daniel Havlik (community) Approve
Landscape Pending
Review via email: mp+319686@code.launchpad.net

Commit message

Run partial python3 tests (listed in file "py3_ready_tests") along with full python2 test run as part of "make check".

Description of the change

While we are porting more and more modules, we need a way to ensure, that already ported modules are not broken again. This MP introduces an additional trial run with using Python 3 in the normal check. The test which should be executed can be listed in a separate file.

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make check
Result: Fail
Revno: 952
Branch: lp:~gocept/landscape-client/test-python3-ported
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3607/

review: Needs Fixing (test results)
Revision history for this message
Steffen Allner (sallner) wrote :

It seems, that the build system is not set up with the necessary packages to test under Python 3. It would be good to have the required packages installed, so that a failure of in already ported modules can be detected.

Revision history for this message
Данило Шеган (danilo) wrote :

The best way to ensure deps are available on all the builder slaves is to introduce a Makefile "depends" (make it .PHONY too) rule that simply does a "sudo apt install python3-twisted ...", and depend on that in the "check" rule.

Revision history for this message
Данило Шеган (danilo) wrote :

Great that you put this up: it's about time we start tracking python3 tests too!

Other than the above, a few nits on the makefile rules. However, I am also having trouble getting trial3 to work with -j4 on my system (which is what the CI builder will pass on): seems python-twisted package might be missing twisted.trial._dist module :/

For now, if CI fails with something like http://paste.ubuntu.com/24175376/, you can prepend TRIAL_ARGS= to the trial3 run.

review: Needs Fixing
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make check
Result: Fail
Revno: 953
Branch: lp:~gocept/landscape-client/test-python3-ported
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3613/

review: Needs Fixing (test results)
Revision history for this message
Steffen Allner (sallner) wrote :

For the distributed tests, it looks like the setup3.py of Twisted does not pack the trial._dist module. With version 16.x it seems Twisted has two different setup.py and the python3 one does not include it. In 17.x there is again only one, so you either patch that somehow or we live with the fact, that the Python 3 tests are not parallelised.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make check
Result: Fail
Revno: 954
Branch: lp:~gocept/landscape-client/test-python3-ported
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3614/

review: Needs Fixing (test results)
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make check
Result: Success
Revno: 955
Branch: lp:~gocept/landscape-client/test-python3-ported
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3616/

review: Approve (test results)
Revision history for this message
Данило Шеган (danilo) wrote :

Right, let's ignore parallelisation of test runs in Python3 for now. We can work on that independently (probably just an omission in twisted).

As for the test, try by exporting an env var with UTF-8 locally before running a test:

  UNICODE_TEST=проба trial3 landscape/lib/tests/test_sysstats.py

I wonder if landscape-client will ever run in an environment containing non-ASCII strings, but I imagine it could. Note that this works in python2, so it's strictly an issue with Python 3 having os.environ as unicode strings instead of bytes (and it seems only when there is UTF-8 in the vars, otherwise they are bytes too).

Since the builder does not complain, we can get this landed, but it would be a tricky bug to chase down later if it happens to our users.

(Yeah, I am heavily using Serbian Cyrillic in all of our projects to stress test the Unicode support :-))

review: Approve
Revision history for this message
Daniel Havlik (nilo) wrote :

+1

review: Approve
Revision history for this message
Steffen Allner (sallner) wrote :

Actually I needed

  UNICODE_TEST=проба LC_ALL=C trial3 landscape/lib/tests/test_sysstats.py

to reproduce it. Looking at https://github.com/twisted/twisted/blob/49365f5c51d0e2dd6a808bfc7dee96946bba81a0/src/twisted/internet/base.py#L851 we really should enforce sending bytes in the environment.

One solution would be a try with sys.getdefaultencoding() as the twisted does it or with utf-8. If that fails an useful error message could be raised.

I would like to add this as a backlog item to the trello board of this project and resolve it in a separate branch. Is that okay for you? Then we can use the testing infrastructure already.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make check
Result: Success
Revno: 956
Branch: lp:~gocept/landscape-client/test-python3-ported
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3619/

review: Approve (test results)
Revision history for this message
Данило Шеган (danilo) wrote :

Yeah, it's fine to do that as a separate task: please add a backlog item.

review: Approve
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Voting does not meet specified criteria. Required: Approve >= 3, Disapprove == 0. Got: 2 Approve, 1 Pending.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2017-03-10 08:52:58 +0000
3+++ Makefile 2017-03-14 11:03:31 +0000
4@@ -4,6 +4,9 @@
5 TRIAL_ARGS ?=
6 TEST_COMMAND_PY2 = trial --unclean-warnings $(TRIAL_ARGS) landscape
7 TEST_COMMAND_PY3 = trial3 --unclean-warnings $(TRIAL_ARGS) landscape
8+READY_FILE := py3_ready_tests
9+PY3_READY := `cat $(READY_FILE)`
10+TEST_COMMAND_PY3_READY = TRIAL_ARGS= trial3 --unclean-warnings $(PY3_READY)
11 UBUNTU_RELEASE := $(shell lsb_release -cs)
12 # version in the code is authoritative
13 # Use := here, not =, it's really important, otherwise UPSTREAM_VERSION
14@@ -34,9 +37,17 @@
15 check3: build3
16 LC_ALL=C $(TEST_COMMAND_PY3)
17
18-check: build
19+check: check2 check3-ready
20+
21+check2: build
22 LC_ALL=C $(TEST_COMMAND_PY2)
23
24+check3-ready: depends3 build3
25+ LC_ALL=C $(TEST_COMMAND_PY3_READY)
26+
27+depends3:
28+ sudo apt -y install python3-twisted python3-distutils-extra python3-mock python3-configobj
29+
30 lint:
31 bzr ls-lint
32
33@@ -129,4 +140,4 @@
34 cd sdist && md5sum landscape-client-$(TARBALL_VERSION).tar.gz > landscape-client-$(TARBALL_VERSION).tar.gz.md5
35 rm -rf sdist/landscape-client-$(TARBALL_VERSION)
36
37-.PHONY: tags etags freshdata run freshrun package sourcepackage updateversion origtarball prepchangelog lint build check releasetarball
38+.PHONY: tags etags freshdata run freshrun package sourcepackage updateversion origtarball prepchangelog lint build build3 check check2 check3 check3-ready check5 depends3 releasetarball
39
40=== added file 'py3_ready_tests'
41--- py3_ready_tests 1970-01-01 00:00:00 +0000
42+++ py3_ready_tests 2017-03-14 11:03:31 +0000
43@@ -0,0 +1,22 @@
44+landscape/lib/tests/test_scriptcontent.py
45+landscape/lib/tests/test_amp.py
46+landscape/lib/tests/test_gpg.py
47+landscape/lib/tests/test_sequenceranges.py
48+landscape/lib/tests/test_bootstrap.py
49+landscape/lib/tests/test_juju.py
50+landscape/lib/tests/test_sysstats.py
51+landscape/lib/tests/test_bpickle.py
52+landscape/lib/tests/test_lock.py
53+landscape/lib/tests/test_tag.py
54+landscape/lib/tests/test_lsb_release.py
55+landscape/lib/tests/test_timestamp.py
56+landscape/lib/tests/test_disk.py
57+landscape/lib/tests/test_monitor.py
58+landscape/lib/tests/test_encoding.py
59+landscape/lib/tests/test_versioning.py
60+landscape/lib/tests/test_fd.py
61+landscape/lib/tests/test_persist.py
62+landscape/lib/tests/test_vm_info.py
63+landscape/lib/tests/test_fetch.py
64+landscape/lib/tests/test_process.py
65+landscape/lib/tests/test_warning.py

Subscribers

People subscribed via source and target branches

to all changes: