Merge lp:~canonical-platform-qa/reminders-app/fix1363599-upstart_and_sandbox into lp:reminders-app

Proposed by Leo Arias
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 254
Merged at revision: 247
Proposed branch: lp:~canonical-platform-qa/reminders-app/fix1363599-upstart_and_sandbox
Merge into: lp:reminders-app
Diff against target: 168 lines (+77/-27)
3 files modified
debian/control (+1/-0)
manifest.json (+1/-1)
tests/autopilot/reminders/tests/__init__.py (+75/-26)
To merge this branch: bzr merge lp:~canonical-platform-qa/reminders-app/fix1363599-upstart_and_sandbox
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Canonical Platform QA Team Pending
Review via email: mp+233832@code.launchpad.net

Commit message

Start the preinstalled click package using the sandbox. This requires a test desktop file.

Description of the change

I removed the home patching for now. It doesn't work, and I'm working on it, bug #1363601.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:246
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~canonical-platform-qa/reminders-app/fix1363599-upstart_and_sandbox/+merge/233832/+edit-commit-message

http://91.189.93.70:8080/job/reminders-app-ci/502/
Executed test runs:
    FAILURE: http://91.189.93.70:8080/job/generic-mediumtests-utopic/1951/console
    FAILURE: http://91.189.93.70:8080/job/reminders-app-utopic-amd64-ci/198/console

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/reminders-app-ci/502/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:247
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~canonical-platform-qa/reminders-app/fix1363599-upstart_and_sandbox/+merge/233832/+edit-commit-message

http://91.189.93.70:8080/job/reminders-app-ci/503/
Executed test runs:
    SUCCESS: http://91.189.93.70:8080/job/generic-mediumtests-utopic/1953
        deb: http://91.189.93.70:8080/job/generic-mediumtests-utopic/1953/artifact/work/output/*zip*/output.zip
    SUCCESS: http://91.189.93.70:8080/job/reminders-app-utopic-amd64-ci/199

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/reminders-app-ci/503/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Comments inline

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Does test_go_to_account_settings still need to be skipped?

I would setup the BaseTestCaseWithTempHome differently. In setUp, I would set:

self.launcher, self.test_type = self.get_launcher_and_type()

Then for RemindersAppTestCase,

    def setUp(self):
        super(RemindersAppTestCase, self).setUp()
        self.app = reminders.RemindersApp(self.launcher(), self.test_type)

Of course, your __init__() method should also include test_type.

I noticed you referenced https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1329141; I wonder if this is causing some of the random fails we see other places (music and filemanager both use random names amongst others perhaps).

Revision history for this message
Leo Arias (elopio) wrote :

> Does test_go_to_account_settings still need to be skipped?

Reported that one as bug 1367784.

> I would setup the BaseTestCaseWithTempHome differently. In setUp, I would set:
>
> self.launcher, self.test_type = self.get_launcher_and_type()
>
> Then for RemindersAppTestCase,
>
> def setUp(self):
> super(RemindersAppTestCase, self).setUp()
> self.app = reminders.RemindersApp(self.launcher(), self.test_type)
>
> Of course, your __init__() method should also include test_type.

This is the pattern I discussed with Victor, using a launcher fixture:
https://code.launchpad.net/~canonical-platform-qa/ubuntu-system-settings-online-accounts/launch_fixture/+merge/226851

Please take a look and leave your comments. I'm making a note to do the same for reminders and ask for your review.

> I noticed you referenced https://bugs.launchpad.net/ubuntu-ui-
> toolkit/+bug/1329141; I wonder if this is causing some of the random fails we
> see other places (music and filemanager both use random names amongst others
> perhaps).

The bug is worked around on the toolkit. It could affect other apps only if they are not using the toolkit helpers, which I don't think it's happening. Only on unity and on the toolkit, and now on reminders, we create test desktop files afaik.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I approve without a successful device run. I cannot make trunk nor this branch run successfully; instead it suffers from issue of hanging during credentials creation.

Anyways, on the MP itself launch_ubuntu_app and related methods should be rolled into a helper or even autopilot. This can serve as a testbed in the interim. Once you add back home patching on click I would be keen to see how we can appropriately bring app launching to the core apps. I'm keen to not overload too much into the UITK helpers, as I feel like some of this functionality is core to click apps and should be rolled into autopilot itself (otherwise, we would NEVER tell someone to use launch_test_click via autopilot, which would not be healthy).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-07-30 21:27:40 +0000
3+++ debian/control 2014-09-10 15:45:35 +0000
4@@ -65,6 +65,7 @@
5 reminders-app (>= ${source:Version}), reminders-app (<< ${source:Version}.1~),
6 account-plugin-evernote-sandbox,
7 libautopilot-qt,
8+ libclick-0.4-0,
9 libqt5test5,
10 python3-dbus,
11 python3-dbusmock,
12
13=== modified file 'manifest.json'
14--- manifest.json 2014-08-08 15:14:47 +0000
15+++ manifest.json 2014-09-10 15:45:35 +0000
16@@ -20,7 +20,7 @@
17 "x-test": {
18 "autopilot": {
19 "autopilot_module": "@AUTOPILOT_DIR@",
20- "depends": ["python3-dbus", "python3-dbusmock", "python3-fixtures", "python3-oauthlib", "python3-requests-oauthlib", "account-plugin-evernote-sandbox"]
21+ "depends": ["account-plugin-evernote-sandbox", "libclick-0.4-0", "python3-dbus", "python3-dbusmock", "python3-fixtures", "python3-oauthlib", "python3-requests-oauthlib"]
22 }
23 }
24 }
25
26=== modified file 'tests/autopilot/reminders/tests/__init__.py'
27--- tests/autopilot/reminders/tests/__init__.py 2014-07-25 16:43:59 +0000
28+++ tests/autopilot/reminders/tests/__init__.py 2014-09-10 15:45:35 +0000
29@@ -18,14 +18,15 @@
30
31 import logging
32 import os
33+import tempfile
34 import shutil
35 import subprocess
36
37 import fixtures
38+import ubuntuuitoolkit
39 from autopilot import logging as autopilot_logging
40 from autopilot.testcase import AutopilotTestCase
41-import ubuntuuitoolkit
42-from ubuntuuitoolkit import fixture_setup as toolkit_fixtures
43+from gi.repository import Click
44
45 import reminders
46
47@@ -69,7 +70,7 @@
48 launcher = self.launch_test_installed
49 test_type = 'deb'
50 else:
51- launcher = self.launch_test_click
52+ launcher = self.launch_ubuntu_app
53 test_type = 'click'
54 return launcher, test_type
55
56@@ -97,41 +98,89 @@
57 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
58
59 @autopilot_logging.log_action(logger.info)
60- def launch_test_click(self):
61- return self.launch_click_package(
62- 'com.ubuntu.reminders',
63- 'reminders',
64- '-s',
65+ def launch_ubuntu_app(self):
66+ # We need to pass the -s argument to the reminders binary, but
67+ # ubuntu-app-launch doesn't pass arguments to the exec line on the
68+ # desktop file. So instead of calling launch_click_application to
69+ # launch the installed click package, we make a test desktop file that
70+ # has the -s on the exec line.
71+ desktop_file_path = self.write_sandbox_desktop_file()
72+ desktop_file_name = os.path.basename(desktop_file_path)
73+ application_name, _ = os.path.splitext(desktop_file_name)
74+ return self.launch_upstart_application(
75+ application_name,
76 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
77
78+ def write_sandbox_desktop_file(self):
79+ desktop_file_dir = self.get_local_desktop_file_directory()
80+ desktop_file = self.get_named_temporary_file(
81+ suffix='.desktop', dir=desktop_file_dir)
82+ desktop_file.write('[Desktop Entry]\n')
83+ version, installed_path = self.get_installed_version_and_directory()
84+ reminders_sandbox_exec = (
85+ 'aa-exec-click -p com.ubuntu.reminders_reminders_{}'
86+ ' -- reminders -s'.format(version))
87+ desktop_file_dict = {
88+ 'Type': 'Application',
89+ 'Name': 'reminders',
90+ 'Exec': reminders_sandbox_exec,
91+ 'Icon': 'Not important',
92+ 'Path': installed_path
93+ }
94+ for key, value in desktop_file_dict.items():
95+ desktop_file.write('{key}={value}\n'.format(key=key, value=value))
96+ desktop_file.close()
97+ return desktop_file.name
98+
99+ def get_local_desktop_file_directory(self):
100+ return os.path.join(
101+ os.environ.get('HOME'), '.local', 'share', 'applications')
102+
103+ def get_named_temporary_file(
104+ self, dir=None, mode='w+t', delete=False, suffix=''):
105+ # Discard files with underscores which look like an APP_ID to Unity
106+ # See https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1329141
107+ chars = tempfile._RandomNameSequence.characters.strip("_")
108+ tempfile._RandomNameSequence.characters = chars
109+ return tempfile.NamedTemporaryFile(
110+ dir=dir, mode=mode, delete=delete, suffix=suffix)
111+
112+ def get_installed_version_and_directory(self):
113+ db = Click.DB()
114+ db.read()
115+ package_name = 'com.ubuntu.reminders'
116+ registry = Click.User.for_user(db, name=os.environ.get('USER'))
117+ version = registry.get_version(package_name)
118+ directory = registry.get_path(package_name)
119+ return version, directory
120+
121 def _patch_home(self, test_type):
122- temp_dir_fixture = fixtures.TempDir()
123- self.useFixture(temp_dir_fixture)
124- temp_dir = temp_dir_fixture.path
125- temp_xdg_config_home = os.path.join(temp_dir, '.config')
126-
127- # If running under xvfb, as jenkins does,
128- # xsession will fail to start without xauthority file
129- # Thus if the Xauthority file is in the home directory
130- # make sure we copy it to our temp home directory
131- self._copy_xauthority_file(temp_dir)
132-
133- # click requires using initctl env (upstart), but the desktop can set
134- # an environment variable instead
135 if test_type == 'click':
136- self.useFixture(
137- toolkit_fixtures.InitctlEnvironmentVariable(
138- HOME=temp_dir, XDG_CONFIG_HOME=temp_xdg_config_home))
139+ # The temp home directory is making the tests fail when running on
140+ # the phone with the preinstalled click. --elopio - 2014-09-08
141+ # Reported as bug here: http://pad.lv/1363601
142+ return os.environ.get('HOME')
143 else:
144+ temp_dir_fixture = fixtures.TempDir()
145+ self.useFixture(temp_dir_fixture)
146+ temp_dir = temp_dir_fixture.path
147+ temp_xdg_config_home = os.path.join(temp_dir, '.config')
148+
149+ # If running under xvfb, as jenkins does,
150+ # xsession will fail to start without xauthority file
151+ # Thus if the Xauthority file is in the home directory
152+ # make sure we copy it to our temp home directory
153+ self._copy_xauthority_file(temp_dir)
154+
155 self.useFixture(
156 fixtures.EnvironmentVariable('HOME', newvalue=temp_dir))
157 self.useFixture(
158 fixtures.EnvironmentVariable(
159 'XDG_CONFIG_HOME', newvalue=temp_xdg_config_home))
160
161- logger.debug('Patched home to fake home directory ' + temp_dir)
162+ logger.debug('Patched home to fake home directory ' + temp_dir)
163
164- return temp_dir
165+ return temp_dir
166
167 def _copy_xauthority_file(self, directory):
168 """Copy .Xauthority file to directory, if it exists in /home."""

Subscribers

People subscribed via source and target branches