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
=== modified file 'phablet-click-test-setup'
--- phablet-click-test-setup 2013-10-21 18:14:51 +0000
+++ phablet-click-test-setup 2014-03-06 13:08:36 +0000
@@ -58,13 +58,15 @@
5858
59lp = None59lp = None
6060
61py2_subdir = 'legacy-py2'
62
61basic_packages = (63basic_packages = (
62 {'source': 'unity8', 'binary': 'unity8'},64 {'source': 'unity8', 'binary': 'unity8'},
63 {'source': 'ubuntu-ui-toolkit',65 {'source': 'ubuntu-ui-toolkit',
64 'binary': 'qtdeclarative5-ubuntu-ui-toolkit-plugin'})66 'binary': 'qtdeclarative5-ubuntu-ui-toolkit-plugin'})
6567
66python_packages = (68python_packages = (
67 'python-mock', 'python-dateutil'69 'python-mock', 'python-dateutil', 'python3-dateutil'
68 )70 )
6971
7072
@@ -111,6 +113,7 @@
111def get_python_binary_package(package, target_dir):113def get_python_binary_package(package, target_dir):
112 tmp_dir = tempfile.mkdtemp()114 tmp_dir = tempfile.mkdtemp()
113 atexit.register(cleanup, tmp_dir)115 atexit.register(cleanup, tmp_dir)
116 python2_target_dir = os.path.join(target_dir, py2_subdir)
114 print('Fetching %s - into %s' % (package, tmp_dir))117 print('Fetching %s - into %s' % (package, tmp_dir))
115 bpph = lp.archive.getPublishedBinaries(118 bpph = lp.archive.getPublishedBinaries(
116 binary_name=package,119 binary_name=package,
@@ -134,12 +137,22 @@
134 'usr/lib/python2.7/dist-packages')137 'usr/lib/python2.7/dist-packages')
135 python_modules_dir = pyshared_path if os.path.exists(pyshared_path) \138 python_modules_dir = pyshared_path if os.path.exists(pyshared_path) \
136 else python2_7_path139 else python2_7_path
137 for f in os.listdir(python_modules_dir):140 if os.path.exists(python_modules_dir):
138 source = path.join(python_modules_dir, f)141 for f in os.listdir(python_modules_dir):
139 if path.islink(source):142 source = path.join(python_modules_dir, f)
140 source = path.join(python_modules_dir, os.readlink(source))143 if path.islink(source):
141 print('Moving %s to %s' % (source, target_dir))144 source = path.join(python_modules_dir, os.readlink(source))
142 shutil.move(source, target_dir)145 print('Moving %s to %s' % (source, python2_target_dir))
146 shutil.move(source, python2_target_dir)
147 python3_modules_dir = os.path.join(extract_dir,
148 'usr/lib/python3/dist-packages')
149 if os.path.exists(python3_modules_dir):
150 for f in os.listdir(python3_modules_dir):
151 source = path.join(python3_modules_dir, f)
152 if path.islink(source):
153 source = path.join(python3_modules_dir, os.readlink(source))
154 print('Moving %s to %s' % (source, target_dir))
155 shutil.move(source, target_dir)
143156
144157
145def get_source_package_tests(package, version, target_dir):158def get_source_package_tests(package, version, target_dir):
@@ -163,15 +176,17 @@
163 shutil.move(test_dir, target_dir)176 shutil.move(test_dir, target_dir)
164177
165178
166def get_bzr_tests(branch, revision, target_dir):179def get_bzr_tests(branch, revision, autopilot_dir, target_dir, sub_dir):
167 tmp_dir = tempfile.mkdtemp()180 tmp_dir = tempfile.mkdtemp()
168 atexit.register(cleanup, tmp_dir)181 atexit.register(cleanup, tmp_dir)
169 print('Checking out %s to %s' % (branch, path.join(tmp_dir, 'work')))182 print('Checking out %s to %s' % (branch, path.join(tmp_dir, 'work')))
170 check_call(['bzr', 'checkout', '--lightweight', branch, '-r', revision,183 check_call(['bzr', 'checkout', '--lightweight', branch, '-r', revision,
171 'work'], cwd=tmp_dir)184 'work'], cwd=tmp_dir)
172 test_base_dir = path.join(tmp_dir, 'work', 'tests', 'autopilot')185 test_base_dir = path.join(tmp_dir, 'work', autopilot_dir)
173 test_dirs = filter((lambda x: path.isdir(path.join(test_base_dir, x))),186 test_dirs = filter((lambda x: path.isdir(path.join(test_base_dir, x))),
174 os.listdir(test_base_dir))187 os.listdir(test_base_dir))
188 if sub_dir:
189 target_dir = os.path.join(target_dir, sub_dir)
175 for test_dir in test_dirs:190 for test_dir in test_dirs:
176 test_dir = path.join(test_base_dir, test_dir)191 test_dir = path.join(test_base_dir, test_dir)
177 print('Moving %s to %s' % (test_dir, target_dir))192 print('Moving %s to %s' % (test_dir, target_dir))
@@ -194,9 +209,14 @@
194 print('Only keeping entries with x-source')209 print('Only keeping entries with x-source')
195 manifest = [entry for entry in manifest if 'x-source' in entry]210 manifest = [entry for entry in manifest if 'x-source' in entry]
196 for entry in manifest:211 for entry in manifest:
212 subdir = py2_subdir
213 if 'x-test' in entry and 'autopilot' in entry['x-test']:
214 subdir = None
197 get_bzr_tests(entry['x-source']['vcs-bzr'],215 get_bzr_tests(entry['x-source']['vcs-bzr'],
198 entry['x-source']['vcs-bzr-revno'],216 entry['x-source']['vcs-bzr-revno'],
199 test_dir)217 'tests/autopilot',
218 test_dir,
219 subdir)
200220
201221
202def main():222def main():
@@ -208,6 +228,7 @@
208 series = adb.shell('lsb_release -c -s').strip()228 series = adb.shell('lsb_release -c -s').strip()
209 lp = LP(series, arch)229 lp = LP(series, arch)
210 test_dir = tempfile.mkdtemp()230 test_dir = tempfile.mkdtemp()
231 os.mkdir(os.path.join(test_dir, py2_subdir))
211 atexit.register(cleanup, test_dir)232 atexit.register(cleanup, test_dir)
212 fetch_test_base(adb, test_dir)233 fetch_test_base(adb, test_dir)
213 fetch_click_tests(adb, test_dir, args.user, args.click)234 fetch_click_tests(adb, test_dir, args.user, args.click)
214235
=== modified file 'phablet-test-run'
--- phablet-test-run 2014-01-20 19:59:53 +0000
+++ phablet-test-run 2014-03-06 13:08:36 +0000
@@ -100,10 +100,18 @@
100100
101run_autopilot_test() {101run_autopilot_test() {
102 exec_with_adb chmod 666 /dev/uinput102 exec_with_adb chmod 666 /dev/uinput
103
104 # First let's try python3, without python2 path
105 defaultpy="/usr/bin/python3"
106 import_error=$(adb shell "cd /home/phablet/autopilot; $defaultpy -c 'import $TESTSUITE'")
107 if [ -n "$import_error" ]; then
108 defaultpy="PYTHONPATH=/home/phablet/autopilot/legacy-py2:/home/phablet/autopilot /usr/bin/python"
109 fi
110
103 # adb shell always returns 0, so we have to do some hackery to get the111 # adb shell always returns 0, so we have to do some hackery to get the
104 # actual RC from the test112 # actual RC from the test
105 {113 {
106 apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; autopilot run $VERBOSE"114 apbase="sudo -iu $USER bash -ic \"cd /home/phablet/autopilot; $defaultpy -m autopilot.run run $VERBOSE"
107 if [ "$RESULTDIR" ]; then115 if [ "$RESULTDIR" ]; then
108 adb shell "$apbase -o /tmp/test_results.xml -f xml $TESTSUITE\"; echo ADB_RC=\$?"116 adb shell "$apbase -o /tmp/test_results.xml -f xml $TESTSUITE\"; echo ADB_RC=\$?"
109 echo "***** Test summary *****"117 echo "***** Test summary *****"

Subscribers

People subscribed via source and target branches