Merge lp:~nskaggs/ubuntu-calendar-app/fix-ap-jenkins-runs into lp:ubuntu-calendar-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Mihir Soni
Approved revision: 539
Merged at revision: 539
Proposed branch: lp:~nskaggs/ubuntu-calendar-app/fix-ap-jenkins-runs
Merge into: lp:ubuntu-calendar-app
Diff against target: 138 lines (+39/-57)
1 file modified
tests/autopilot/calendar_app/tests/__init__.py (+39/-57)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-calendar-app/fix-ap-jenkins-runs
Reviewer Review Type Date Requested Status
Mihir Soni Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+241143@code.launchpad.net

Commit message

Fix application launching as a stopgap solution to jenkins test failures until bug 1376423 is fixed.

Description of the change

Fix application launching as a stopgap solution to jenkins test failures until bug 1376423 is fixed.

To post a comment you must log in.
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
Mihir Soni (mihirsoni) wrote :

Looks good to me !!
Thanks a lot Nicholas :D

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/calendar_app/tests/__init__.py'
2--- tests/autopilot/calendar_app/tests/__init__.py 2014-09-30 00:38:14 +0000
3+++ tests/autopilot/calendar_app/tests/__init__.py 2014-11-07 21:02:05 +0000
4@@ -28,10 +28,7 @@
5 from autopilot import logging as autopilot_logging
6
7 import ubuntuuitoolkit
8-from ubuntuuitoolkit import (
9- base,
10- fixture_setup as toolkit_fixtures
11-)
12+from ubuntuuitoolkit import base
13
14 logger = logging.getLogger(__name__)
15
16@@ -62,7 +59,7 @@
17 def setUp(self):
18 super(BaseTestCaseWithPatchedHome, self).setUp()
19 self.launcher, self.test_type = self.get_launcher_and_type()
20- self.home_dir = self._patch_home()
21+ self.home_dir = self.patch_home()
22
23 @autopilot_logging.log_action(logger.info)
24 def launch_test_local(self):
25@@ -103,59 +100,17 @@
26 '.Xauthority')),
27 os.path.join(directory, '.Xauthority'))
28
29- def _patch_home(self):
30+ def patch_home(self):
31 """ mock /home for testing purposes to preserve user data
32 """
33- # click requires apparmor profile, and writing to special dir
34- # but the desktop can write to a traditional /tmp directory
35- if self.test_type == 'click':
36- env_dir = os.path.join(os.environ.get('HOME'), 'autopilot',
37- 'fakeenv')
38-
39- if not os.path.exists(env_dir):
40- os.makedirs(env_dir)
41-
42- temp_dir_fixture = fixtures.TempDir(env_dir)
43- self.useFixture(temp_dir_fixture)
44-
45- # apparmor doesn't allow the app to create needed directories,
46- # so we create them now
47- temp_dir = temp_dir_fixture.path
48- temp_dir_cache = os.path.join(temp_dir, '.cache')
49- temp_dir_cache_font = os.path.join(temp_dir_cache, 'fontconfig')
50- temp_dir_cache_media = os.path.join(temp_dir_cache, 'media-art')
51- temp_dir_cache_write = os.path.join(temp_dir_cache,
52- 'tncache-write-text.null')
53- temp_dir_config = os.path.join(temp_dir, '.config')
54- temp_dir_toolkit = os.path.join(temp_dir_config,
55- 'ubuntu-ui-toolkit')
56- temp_dir_font = os.path.join(temp_dir_cache, '.fontconfig')
57- temp_dir_local = os.path.join(temp_dir, '.local', 'share')
58- temp_dir_confined = os.path.join(temp_dir, 'confined')
59-
60- if not os.path.exists(temp_dir_cache):
61- os.makedirs(temp_dir_cache)
62- if not os.path.exists(temp_dir_cache_font):
63- os.makedirs(temp_dir_cache_font)
64- if not os.path.exists(temp_dir_cache_media):
65- os.makedirs(temp_dir_cache_media)
66- if not os.path.exists(temp_dir_cache_write):
67- os.makedirs(temp_dir_cache_write)
68- if not os.path.exists(temp_dir_config):
69- os.makedirs(temp_dir_config)
70- if not os.path.exists(temp_dir_toolkit):
71- os.makedirs(temp_dir_toolkit)
72- if not os.path.exists(temp_dir_font):
73- os.makedirs(temp_dir_font)
74- if not os.path.exists(temp_dir_local):
75- os.makedirs(temp_dir_local)
76- if not os.path.exists(temp_dir_confined):
77- os.makedirs(temp_dir_confined)
78-
79- # before we set fixture, copy xauthority if needed
80- self._copy_xauthority_file(temp_dir)
81- self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable(
82- HOME=temp_dir))
83+
84+ # if running on non-phablet device,
85+ # run in temp folder to avoid mucking up home
86+ # bug 1316746
87+ # bug 1376423
88+ if self.test_type is 'click':
89+ # just use home for now on devices
90+ temp_dir = os.environ.get('HOME')
91 else:
92 temp_dir_fixture = fixtures.TempDir()
93 self.useFixture(temp_dir_fixture)
94@@ -166,9 +121,34 @@
95 self.useFixture(fixtures.EnvironmentVariable('HOME',
96 newvalue=temp_dir))
97
98- logger.debug("Patched home to fake home directory %s" % temp_dir)
99+ logger.debug("Patched home to fake home directory %s" % temp_dir)
100+ self.setup_evolution()
101 return temp_dir
102
103+ def setup_evolution(self):
104+ """restart evolution under our fake home fixture
105+ so there are no pre-existing events """
106+
107+ if self.test_type is 'click':
108+ # do nothing for now on click
109+ return
110+ else:
111+ # from lp:qtorganizer5-eds
112+ # upstream patches XDG folders and other env vars
113+ # seems it's enough to kill the evolution daemons
114+ # they will restart when needed (during app launch)
115+ # to clean up we will again kill them
116+ # to restore proper function to host system
117+
118+ os.system('/usr/lib/evolution/evolution-calendar-factory &')
119+ os.system('/usr/lib/evolution/evolution-source-registry &')
120+
121+ self.addCleanup(os.system,
122+ '/usr/lib/evolution/evolution-calendar-factory &')
123+ self.addCleanup(os.system,
124+ '/usr/lib/evolution/evolution-source-registry &')
125+ logger.debug("Restarted evolution daemons")
126+
127
128 class CalendarAppTestCase(BaseTestCaseWithPatchedHome):
129
130@@ -181,6 +161,8 @@
131
132 class CalendarAppTestCaseWithVcard(BaseTestCaseWithPatchedHome):
133
134+ """Launch the calendar-app with vcard for contact support"""
135+
136 def setup_vcard(self):
137 if self.test_type is 'deb':
138 location = '/usr/lib/python3/dist-packages/calendar_app'

Subscribers

People subscribed via source and target branches

to status/vote changes: