Merge lp:~xnox/phablet-tools/py2-3 into lp:phablet-tools

Proposed by Dimitri John Ledkov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 248
Merged at revision: 242
Proposed branch: lp:~xnox/phablet-tools/py2-3
Merge into: lp:phablet-tools
Diff against target: 125 lines (+40/-11)
2 files modified
phablet-click-test-setup (+31/-10)
phablet-test-run (+9/-1)
To merge this branch: bzr merge lp:~xnox/phablet-tools/py2-3
Reviewer Review Type Date Requested Status
Martin Pitt Approve
Andy Doan (community) Approve
Sergio Schvezov Approve
PS Jenkins bot continuous-integration Approve
Nicholas Skaggs Pending
Review via email: mp+205608@code.launchpad.net

Commit message

Support python2 and python3 based autopilot tests.

Description of the change

Support python2 and python3 based autopilot tests.

To post a comment you must log in.
lp:~xnox/phablet-tools/py2-3 updated
241. By Dimitri John Ledkov

correct pythonpath

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

/home/autopilot/ can have python3 modules, or python3 & 2 bilingual modules (e.g. uitoolkit, unity8 emulators etc. are expected to be bilingual)

/home/autopilot/legacy-py2 can only have python2 modules.

I've modified get_bzr_tests to fetch into python2 location is autopilot_dir is not defined.
If autopilot_dir is defined, it's fetched into python3 location.

Ditto grabbing tests from binary packages, although that doesn't grab python3 tests yet.

The phablet-test-run portion, modifies how autopilot is launched to carefully set PYTHONPATH for python2-only (this is achieved by passing -E (ignore pythonpath) to python3, which is dropped if autopilot re-execs under python2)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

This branch should land ahead of https://code.launchpad.net/~barry/autopilot/reexec/+merge/203765 landing, such that phablet-test-run is prepared to handle the switch.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

@balloons can you make the rule xnox mentions something true for the core apps? Or provide a list of py3 ready clicks.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

60 + entry['x-source']['autopilot-dir'],

the autopilot extension I talked about was not part of x-source but part of a new node at the same lever of x-source called

"x-test": {
    "autopilot": "ubuntu_calendar_app"
}

so we can eventually just run the tests for a given package, whatever those tests are; if you want to change anything, we can; adding the autopilot-dir to x-source seems reasonable to me as well.

review: Needs Information
Revision history for this message
Andy Doan (doanac) wrote :

I noticed this requires "fromdos" which isn't installed by default for me

review: Needs Fixing
lp:~xnox/phablet-tools/py2-3 updated
242. By Dimitri John Ledkov

Add fromdos dependency.

243. By Dimitri John Ledkov

Correct click manifest key

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Addressed all review comments.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

69 + if entry['x-test'] and 'autopilot' in entry['x-test']:
70 + get_bzr_tests(entry['x-source']['vcs-bzr'],
71 + entry['x-source']['vcs-bzr-revno'],
72 + entry['x-test']['autopilot'],
73 + test_dir)

So here it would be called like:
def get_bzr_tests(branch=entry['x-source']['vcs-bzr'],
                  revision=entry['x-source']['vcs-bzr-revno'],
                  autopilot_dir=entry['x-test']['autopilot'],
                  target_dir=test_dir,
                  sub_dir=None
                  )

74 + else:
75 + get_bzr_tests(entry['x-source']['vcs-bzr'],
76 + entry['x-source']['vcs-bzr-revno'],
77 + 'tests/autopilot',
78 + test_dir,
79 + py2_subdir)

and here
def get_bzr_tests(branch=entry['x-source']['vcs-bzr'],
                  revision=entry['x-source']['vcs-bzr-revno'],
                  autopilot_dir='tests/autopilot',
                  target_dir=test_dir,
                  sub_dir=py2_subdir
                  )

Seems that in
47 +def get_bzr_tests(branch, revision, autopilot_dir, target_dir, sub_dir):

sub_dir needs a None or '' default

Second
test_dir='ubuntu_clock_app' for when autopilot_dir=entry['x-test']['autopilot'] exists
and
test_dir='tests/autopilot' when not.

I would just keep 'tests/autopilot' for both or add some prior check that applies to both to look for '[x-source']['autopilot-dir'] as you had or default to 'tests/autopilot'

review: Needs Fixing
lp:~xnox/phablet-tools/py2-3 updated
244. By Dimitri John Ledkov

Simplify get_bzr_tests call.

245. By Dimitri John Ledkov

pep8

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~xnox/phablet-tools/py2-3 updated
246. By Dimitri John Ledkov

Pick correct python ahead of execution

247. By Dimitri John Ledkov

Drop bogus depends

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~xnox/phablet-tools/py2-3 updated
248. By Dimitri John Ledkov

Add python3 modules

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve
Revision history for this message
Andy Doan (doanac) :
review: Approve
Revision history for this message
Martin Pitt (pitti) wrote :

Very nice, thanks Dimitri!

review: Approve
lp:~xnox/phablet-tools/py2-3 updated
249. By Dimitri John Ledkov

Merge trunk

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

With following two packages:
com.ubuntu.calendar 205 or better
com.ubuntu.music 370 or better

We can land this branch without regressing any test-results, and since unity8/ubuntu-ui-toolkit have landed with python3 support, we can test this branch as per test-plan out of silo against unmodified images.

Please allocate a silo / start landing this branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phablet-click-test-setup'
2--- phablet-click-test-setup 2013-10-21 18:14:51 +0000
3+++ phablet-click-test-setup 2014-03-06 13:08:36 +0000
4@@ -58,13 +58,15 @@
5
6 lp = None
7
8+py2_subdir = 'legacy-py2'
9+
10 basic_packages = (
11 {'source': 'unity8', 'binary': 'unity8'},
12 {'source': 'ubuntu-ui-toolkit',
13 'binary': 'qtdeclarative5-ubuntu-ui-toolkit-plugin'})
14
15 python_packages = (
16- 'python-mock', 'python-dateutil'
17+ 'python-mock', 'python-dateutil', 'python3-dateutil'
18 )
19
20
21@@ -111,6 +113,7 @@
22 def get_python_binary_package(package, target_dir):
23 tmp_dir = tempfile.mkdtemp()
24 atexit.register(cleanup, tmp_dir)
25+ python2_target_dir = os.path.join(target_dir, py2_subdir)
26 print('Fetching %s - into %s' % (package, tmp_dir))
27 bpph = lp.archive.getPublishedBinaries(
28 binary_name=package,
29@@ -134,12 +137,22 @@
30 'usr/lib/python2.7/dist-packages')
31 python_modules_dir = pyshared_path if os.path.exists(pyshared_path) \
32 else python2_7_path
33- for f in os.listdir(python_modules_dir):
34- source = path.join(python_modules_dir, f)
35- if path.islink(source):
36- source = path.join(python_modules_dir, os.readlink(source))
37- print('Moving %s to %s' % (source, target_dir))
38- shutil.move(source, target_dir)
39+ if os.path.exists(python_modules_dir):
40+ for f in os.listdir(python_modules_dir):
41+ source = path.join(python_modules_dir, f)
42+ if path.islink(source):
43+ source = path.join(python_modules_dir, os.readlink(source))
44+ print('Moving %s to %s' % (source, python2_target_dir))
45+ shutil.move(source, python2_target_dir)
46+ python3_modules_dir = os.path.join(extract_dir,
47+ 'usr/lib/python3/dist-packages')
48+ if os.path.exists(python3_modules_dir):
49+ for f in os.listdir(python3_modules_dir):
50+ source = path.join(python3_modules_dir, f)
51+ if path.islink(source):
52+ source = path.join(python3_modules_dir, os.readlink(source))
53+ print('Moving %s to %s' % (source, target_dir))
54+ shutil.move(source, target_dir)
55
56
57 def get_source_package_tests(package, version, target_dir):
58@@ -163,15 +176,17 @@
59 shutil.move(test_dir, target_dir)
60
61
62-def get_bzr_tests(branch, revision, target_dir):
63+def get_bzr_tests(branch, revision, autopilot_dir, target_dir, sub_dir):
64 tmp_dir = tempfile.mkdtemp()
65 atexit.register(cleanup, tmp_dir)
66 print('Checking out %s to %s' % (branch, path.join(tmp_dir, 'work')))
67 check_call(['bzr', 'checkout', '--lightweight', branch, '-r', revision,
68 'work'], cwd=tmp_dir)
69- test_base_dir = path.join(tmp_dir, 'work', 'tests', 'autopilot')
70+ test_base_dir = path.join(tmp_dir, 'work', autopilot_dir)
71 test_dirs = filter((lambda x: path.isdir(path.join(test_base_dir, x))),
72 os.listdir(test_base_dir))
73+ if sub_dir:
74+ target_dir = os.path.join(target_dir, sub_dir)
75 for test_dir in test_dirs:
76 test_dir = path.join(test_base_dir, test_dir)
77 print('Moving %s to %s' % (test_dir, target_dir))
78@@ -194,9 +209,14 @@
79 print('Only keeping entries with x-source')
80 manifest = [entry for entry in manifest if 'x-source' in entry]
81 for entry in manifest:
82+ subdir = py2_subdir
83+ if 'x-test' in entry and 'autopilot' in entry['x-test']:
84+ subdir = None
85 get_bzr_tests(entry['x-source']['vcs-bzr'],
86 entry['x-source']['vcs-bzr-revno'],
87- test_dir)
88+ 'tests/autopilot',
89+ test_dir,
90+ subdir)
91
92
93 def main():
94@@ -208,6 +228,7 @@
95 series = adb.shell('lsb_release -c -s').strip()
96 lp = LP(series, arch)
97 test_dir = tempfile.mkdtemp()
98+ os.mkdir(os.path.join(test_dir, py2_subdir))
99 atexit.register(cleanup, test_dir)
100 fetch_test_base(adb, test_dir)
101 fetch_click_tests(adb, test_dir, args.user, args.click)
102
103=== modified file 'phablet-test-run'
104--- phablet-test-run 2014-01-20 19:59:53 +0000
105+++ phablet-test-run 2014-03-06 13:08:36 +0000
106@@ -100,10 +100,18 @@
107
108 run_autopilot_test() {
109 exec_with_adb chmod 666 /dev/uinput
110+
111+ # First let's try python3, without python2 path
112+ defaultpy="/usr/bin/python3"
113+ import_error=$(adb shell "cd /home/phablet/autopilot; $defaultpy -c 'import $TESTSUITE'")
114+ if [ -n "$import_error" ]; then
115+ defaultpy="PYTHONPATH=/home/phablet/autopilot/legacy-py2:/home/phablet/autopilot /usr/bin/python"
116+ fi
117+
118 # adb shell always returns 0, so we have to do some hackery to get the
119 # actual RC from the test
120 {
121- apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; autopilot run $VERBOSE"
122+ apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; $defaultpy -m autopilot.run run $VERBOSE"
123 if [ "$RESULTDIR" ]; then
124 adb shell "$apbase -o /tmp/test_results.xml -f xml $TESTSUITE\"; echo ADB_RC=\$?"
125 echo "***** Test summary *****"

Subscribers

People subscribed via source and target branches