Skip to content
Newer
Older
100644 1132 lines (1022 sloc) 50.1 KB
91b2c03 @markrcote Initial commit.
markrcote authored
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
4
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
5 import ConfigParser
b6dc95d @bclary Bug 1119654 - Autophone - separate installation specific settings, r=…
bclary authored
6 import datetime
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
7 import glob
91b2c03 @markrcote Initial commit.
markrcote authored
8 import logging
cfce5c6 @bclary Bug 851288 - Use quitter.xpi for terminating fennec in autophone s1s2…
bclary authored
9 import os
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
10 import posixpath
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
11 import re
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
12 import sys
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
13 import shutil
14 import tempfile
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
15
16 from time import sleep
91b2c03 @markrcote Initial commit.
markrcote authored
17
96834af @markrcote Can create, push, and use custom profiles. Some pulse support.
markrcote authored
18 from mozprofile import FirefoxProfile
91b2c03 @markrcote Initial commit.
markrcote authored
19
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
20 import utils
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
21 from autophonecrash import AutophoneCrashProcessor
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
22 from adb import ADBError
23 from logdecorator import LogDecorator
24 from phonestatus import PhoneStatus
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
25 from sensitivedatafilter import SensitiveDataFilter
91b2c03 @markrcote Initial commit.
markrcote authored
26
cd7c3c5 @bclary Bug 1161631 - Autophone - part 2 - revamp logging, r=gbrown.
bclary authored
27 # Set the logger globally in the file, but this must be reset when
28 # used in a child process.
29 logger = logging.getLogger()
30
9763447 @bclary Bug 1229807 - Autophone - install and uninstall Flash for the Autopho…
bclary authored
31 # Define the Adobe Flash Player package name as a constant for reuse.
32 FLASH_PACKAGE = 'com.adobe.flashplayer'
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
33
34 class Logcat(object):
3d076b9 @bclary Bug 1209675 - Autophone - Logcat should use PhoneTest loggerdeco, r=j…
bclary authored
35 def __init__(self, phonetest, logger):
5df25aa @bclary Bug 1205388 - Autophone - better handle logcat collection, r=gbrown.
bclary authored
36 logger.debug('Logcat()')
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
37 self.phonetest = phonetest
3d076b9 @bclary Bug 1209675 - Autophone - Logcat should use PhoneTest loggerdeco, r=j…
bclary authored
38 self.logger = logger
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
39 self._accumulated_logcat = []
40
41 def get(self, full=False):
42 """Return the contents of logcat as list of strings.
43
44 :param full: optional boolean which defaults to False. If full
45 is False, then get() will only return logcat
46 output since the last call to clear(). If
47 full is True, then get() will return all
48 logcat output since the test was initialized or
49 teardown_job was last called.
50 """
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
51
52 # Get the datetime from the last logcat message
53 # previously collected. Note that with the time
54 # format, logcat lines begin with a date time of the
55 # form: 09-17 16:45:04.370 which is the first 18
56 # characters of the line.
57 if self._accumulated_logcat:
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
58 logcat_datestr = self._accumulated_logcat[-1][:18]
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
59 else:
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
60 logcat_datestr = '00-00 00:00:00.000'
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
61
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
62 self.logger.debug('Logcat.get() since %s' % logcat_datestr)
63
64 # adb logcat can return lines with bogus dates where the MM-DD
65 # is not correct. This in particular has happened on a Samsung
66 # Galaxy S3 where Vold emits lines with the fixed date
67 # 11-30. It is not known if this is a general problem with
68 # other devices.
69
70 # This incorrect date causes problems when attempting to use
71 # the logcat dates to eliminate duplicates. It also conflicts
72 # with the strategy used in analyze_logcat to determine a
73 # potential year change during a test run. To distinguish
74 # between false year changes, we can decide that if the
75 # previous date and the current date are different by more
76 # than an hour, a decision must be made on which date is
77 # legitimate.
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
78
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
79 for attempt in range(1, self.phonetest.options.phone_retry_limit+1):
80 try:
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
81 raw_logcat = [
82 unicode(x, 'UTF-8', errors='replace').strip()
83 for x in self.phonetest.dm.get_logcat(filter_specs=['*:V'])]
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
84 break
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
85 except ADBError:
3d076b9 @bclary Bug 1209675 - Autophone - Logcat should use PhoneTest loggerdeco, r=j…
bclary authored
86 self.logger.exception('Attempt %d get logcat' % attempt)
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
87 if attempt == self.phonetest.options.phone_retry_limit:
88 raise
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
89 sleep(self.phonetest.options.phone_retry_wait)
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
90
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
91 current_logcat = []
92 prev_line_date = None
93 curr_line_date = None
94 curr_year = datetime.datetime.now().year
95 hour = datetime.timedelta(hours=1)
96
97 for line in raw_logcat:
98 try:
99 curr_line_date = datetime.datetime.strptime('%4d-%s' % (
100 curr_year, line[:18]), '%Y-%m-%d %H:%M:%S.%f')
101 except ValueError:
102 curr_line_date = None
103 if curr_line_date and prev_line_date:
104 delta = curr_line_date - prev_line_date
105 prev_line_datestr = prev_line_date.strftime('%m-%d %H:%M:%S.%f')
106 if delta <= -hour:
107 # The previous line's date is one or more hours in
108 # the future compared to the current line. Keep
109 # the current lines which are before the previous
110 # line's date.
111 new_current_logcat = []
112 for x in current_logcat:
113 if x < prev_line_datestr:
114 self.logger.debug('Logcat.get(): Discarding future line: %s' % x)
115 else:
116 self.logger.debug('Logcat.get(): keeping line: %s' % x)
117 new_current_logcat.append(x)
118 current_logcat = new_current_logcat
119 elif delta >= hour:
120 # The previous line's date is one or more hours in
121 # the past compared to the current line. Keep the
122 # current lines which are after the previous
123 # line's date.
124 new_current_logcat = []
125 for x in current_logcat:
126 if x > prev_line_datestr:
127 self.logger.debug('Logcat.get(): Discarding past line: %s' % x)
128 else:
129 self.logger.debug('Logcat.get(): keeping line: %s' % x)
130 new_current_logcat.append(x)
131 current_logcat = new_current_logcat
132 # Keep the messages which are on or after the last accumulated
133 # logcat date.
134 if line >= logcat_datestr:
135 current_logcat.append(line)
136 prev_line_date = curr_line_date
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
137
138 # In order to eliminate the possible duplicate
139 # messages, partition the messages by before, on and
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
140 # after the logcat_datestr.
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
141 accumulated_logcat_before = []
142 accumulated_logcat_now = []
143 for x in self._accumulated_logcat:
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
144 if x < logcat_datestr:
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
145 accumulated_logcat_before.append(x)
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
146 elif x[:18] == logcat_datestr:
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
147 accumulated_logcat_now.append(x)
148
149 current_logcat_now = []
150 current_logcat_after = []
151 for x in current_logcat:
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
152 if x[:18] == logcat_datestr:
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
153 current_logcat_now.append(x)
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
154 elif x > logcat_datestr:
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
155 current_logcat_after.append(x)
156
157 # Remove any previously received messages from
27e01f8 @bclary Bug 1209691 - Autophone - handle incorrect logcat dates emitted by de…
bclary authored
158 # current_logcat_now for the logcat_datestr.
4e18f7b @bclary Bug 1205864 - Autophone - eliminate spurious duplicate logcat message…
bclary authored
159 current_logcat_now = set(current_logcat_now).difference(
160 set(accumulated_logcat_now))
161 current_logcat_now = list(current_logcat_now)
162 current_logcat_now.sort()
163
164 current_logcat = current_logcat_now + current_logcat_after
165 self._accumulated_logcat += current_logcat
166
167 if full:
168 return self._accumulated_logcat
169 return current_logcat
170
5df25aa @bclary Bug 1205388 - Autophone - better handle logcat collection, r=gbrown.
bclary authored
171 def reset(self):
172 """Clears the Logcat buffers and the device's logcat buffer."""
3d076b9 @bclary Bug 1209675 - Autophone - Logcat should use PhoneTest loggerdeco, r=j…
bclary authored
173 self.logger.debug('Logcat.reset()')
174 self.__init__(self.phonetest, self.logger)
5df25aa @bclary Bug 1205388 - Autophone - better handle logcat collection, r=gbrown.
bclary authored
175 self.phonetest.dm.clear_logcat()
176
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
177 def clear(self):
5df25aa @bclary Bug 1205388 - Autophone - better handle logcat collection, r=gbrown.
bclary authored
178 """Accumulates current logcat buffers, then clears the device's logcat
179 buffers. clear() is used to prevent the device's logcat buffer
180 from overflowing while not losing any output.
181 """
3d076b9 @bclary Bug 1209675 - Autophone - Logcat should use PhoneTest loggerdeco, r=j…
bclary authored
182 self.logger.debug('Logcat.clear()')
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
183 self.get()
184 self.phonetest.dm.clear_logcat()
185
186
91b2c03 @markrcote Initial commit.
markrcote authored
187 class PhoneTest(object):
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
188 # Use instances keyed on phoneid+':'config_file+':'+str(chunk)
189 # to lookup tests.
190
191 instances = {}
192
193 @classmethod
194 def lookup(cls, phoneid, config_file, chunk):
195 key = '%s:%s:%s' % (phoneid, config_file, chunk)
196 if key in PhoneTest.instances:
197 return PhoneTest.instances[key]
198 return None
199
200 @classmethod
201 def match(cls, tests=None, test_name=None, phoneid=None,
202 config_file=None, chunk=None, job_guid=None,
cd7c3c5 @bclary Bug 1161631 - Autophone - part 2 - revamp logging, r=gbrown.
bclary authored
203 build_url=None):
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
204
205 logger.debug('PhoneTest.match(tests: %s, test_name: %s, phoneid: %s, '
206 'config_file: %s, chunk: %s, job_guid: %s, '
207 'build_url: %s' % (tests, test_name, phoneid,
208 config_file, chunk, job_guid,
209 build_url))
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
210 matches = []
211 if not tests:
212 tests = [PhoneTest.instances[key] for key in PhoneTest.instances.keys()]
213
214 for test in tests:
215 if test_name and test_name != test.name:
216 continue
217
218 if phoneid and phoneid != test.phone.id:
219 continue
220
221 if config_file and config_file != test.config_file:
222 continue
223
224 if chunk and chunk != test.chunk:
225 continue
226
227 if job_guid and job_guid != test.job_guid:
228 continue
229
230 if build_url:
231 abi = test.phone.abi
232 sdk = test.phone.sdk
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
233 # First assume the test and build are compatible.
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
234 incompatible_job = False
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
235 # x86 devices can only test x86 builds and non-x86
236 # devices can not test x86 builds.
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
237 if abi == 'x86':
238 if 'x86' not in build_url:
239 incompatible_job = True
240 else:
241 if 'x86' in build_url:
242 incompatible_job = True
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
243 # If the build_url does not contain an sdk level, then
244 # assume this is an build from before the split sdk
4f81851 @bclary Bug 1244032 - Autophone - support new api-15 build directories, r=gbr…
bclary authored
245 # builds were first created.
246 re_api = re.compile(r'api-(9|10|11|15)')
247 match = re_api.search(build_url)
248 if not match:
249 pass
250 elif sdk == 'api-15' and 'api-11' in build_url:
251 # The change to a build api level of 15 in build
252 # urls means that we must adjust the match in the
253 # event we are attempting to test older builds for
254 # api-11.
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
255 pass
256 elif sdk not in build_url:
4f81851 @bclary Bug 1244032 - Autophone - support new api-15 build directories, r=gbr…
bclary authored
257 # Otherwise the device's sdk must match the
258 # build's sdk.
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
259 incompatible_job = True
260
261 if incompatible_job:
262 continue
263
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
264 # The test may be defined for multiple repositories.
265 # We are interested if this particular build is
266 # supported by this test. First assume it is
267 # incompatible, and only accept it if the build_url is
268 # from one of the supported repositories.
5788485 @bclary Bug 1164505 - Autophone - handle no device/repos in test manifest, r=…
bclary authored
269 if test.repos:
270 incompatible_job = True
271 for repo in test.repos:
272 if repo in build_url:
273 incompatible_job = False
274 break
275 if incompatible_job:
276 continue
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
277
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
278 matches.append(test)
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
279
280 logger.debug('PhoneTest.match = %s' % matches)
281
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
282 return matches
283
7358c98 @bclary Bug 1161631 - Autophone - part 6 - reuse ADBDevice instances, r=gbrown.
bclary authored
284 def __init__(self, dm=None, phone=None, options=None, config_file=None, chunk=1, repos=[]):
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
285 # Ensure that repos is a list and that it is sorted in order
286 # for comparisons with the tests loaded from the jobs database
287 # to work.
288 assert type(repos) == list, 'PhoneTest repos argument must be a list'
289 repos.sort()
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
290 self._add_instance(phone.id, config_file, chunk)
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
291 # The default preferences and environment for running fennec
292 # are set here in PhoneTest. Tests which subclass PhoneTest can
293 # add or override these preferences during their
294 # initialization.
295 self._preferences = None
296 self._environment = None
91b2c03 @markrcote Initial commit.
markrcote authored
297 self.config_file = config_file
b6dc95d @bclary Bug 1119654 - Autophone - separate installation specific settings, r=…
bclary authored
298 self.cfg = ConfigParser.ConfigParser()
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
299 # Make the values in the config file case-sensitive
300 self.cfg.optionxform = str
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
301 self.cfg.read(self.config_file)
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
302 self.enable_unittests = False
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
303 self.chunk = chunk
304 self.chunks = 1
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
305 self.update_status_cb = None
7358c98 @bclary Bug 1161631 - Autophone - part 6 - reuse ADBDevice instances, r=gbrown.
bclary authored
306 self.dm = dm
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
307 self.phone = phone
308 self.worker_subprocess = None
309 self.options = options
cd7c3c5 @bclary Bug 1161631 - Autophone - part 2 - revamp logging, r=gbrown.
bclary authored
310 self.loggerdeco = LogDecorator(logger,
1414831 @bclary Bug 1161631 - Autophone - part 1 - implement shutdown command, r=gbrown.
bclary authored
311 {'phoneid': self.phone.id},
312 '%(phoneid)s|%(message)s')
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
313 self.loggerdeco_original = None
314 self.dm_logger_original = None
1102e03 @bclary bug 853961 - revamp logging, r=mcote.
bclary authored
315 self.loggerdeco.info('init autophone.phonetest')
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
316 # test_logfilehandler is used by running tests to save log
317 # messages to a separate file which can be reset at the
318 # beginning of each test independently of the worker's log.
319 self.test_logfilehandler = None
96834af @markrcote Can create, push, and use custom profiles. Some pulse support.
markrcote authored
320 self._base_device_path = ''
4b0e4f1 @bclary Bug 1214812 - Autophone - add configurable test_root, r=gbrown.
bclary authored
321 if self.dm:
322 self.profile_path = '%s/profile' % self.base_device_path
323 else:
324 self.profile_path = '/data/local/tests/autophone/profile'
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
325 self.repos = repos
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
326 self.test_logfile = None
327 self.unittest_logpath = None
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
328 # Treeherder related items.
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
329 self._job_name = None
330 self._job_symbol = None
331 self._group_name = None
332 self._group_symbol = None
333 self.test_result = PhoneTestResult()
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
334 self.message = None
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
335 # A unique consistent guid is necessary for identifying the
336 # test job in treeherder. The test job_guid is updated when a
337 # test is added to the pending jobs/tests in the jobs
338 # database.
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
339 self.job_guid = None
340 self.job_details = []
341 self.submit_timestamp = None
342 self.start_timestamp = None
343 self.end_timestamp = None
3d076b9 @bclary Bug 1209675 - Autophone - Logcat should use PhoneTest loggerdeco, r=j…
bclary authored
344 self.logcat = Logcat(self, self.loggerdeco)
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
345 self.loggerdeco.debug('PhoneTest: %s, cfg sections: %s' % (self.__dict__, self.cfg.sections()))
df44529 @bclary Bug 1037067 - Improve initial setup and docs, r=gbrown, r=mcote.
bclary authored
346 if not self.cfg.sections():
347 self.loggerdeco.warning('Test configuration not found. '
348 'Will use defaults.')
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
349 # upload_dir will hold ANR traces, tombstones and other files
350 # pulled from the device.
351 self.upload_dir = None
352 # crash_processor is an instance of AutophoneCrashProcessor that
353 # is used by non-unittests to process device errors and crashes.
354 self.crash_processor = None
b6dc95d @bclary Bug 1119654 - Autophone - separate installation specific settings, r=…
bclary authored
355 # Instrument running time
356 self.start_time = None
357 self.stop_time = None
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
358 # Perform initial configuration. For tests which do not
359 # specify all config options, reasonable defaults will be
360 # chosen.
361
362 # [paths]
363 self.autophone_directory = os.path.dirname(os.path.abspath(sys.argv[0]))
364 self._paths = {}
365 self._paths['dest'] = posixpath.join(self.base_device_path,
366 self.__class__.__name__)
367 try:
368 sources = self.cfg.get('paths', 'sources').split()
369 self._paths['sources'] = []
370 for source in sources:
371 if not source.endswith('/'):
372 source += '/'
373 self._paths['sources'].append(source)
374 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
375 self._paths['sources'] = [
376 os.path.join(self.autophone_directory, 'files/base/')]
377 try:
378 self._paths['dest'] = self.cfg.get('paths', 'dest')
379 if not self._paths['dest'].endswith('/'):
380 self._paths['dest'] += '/'
381 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
382 pass
383 try:
384 self._paths['profile'] = self.cfg.get('paths', 'profile')
385 if not self._paths['profile'].endswith('/'):
386 self._paths['profile'] += '/'
387 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
388 pass
389 if 'profile' in self._paths:
390 self.profile_path = self._paths['profile']
391 # _pushes = {'sourcepath' : 'destpath', ...}
392 self._pushes = {}
393 for source in self._paths['sources']:
394 for push in glob.glob(source + '*'):
395 if push.endswith('~') or push.endswith('.bak'):
396 continue
dcd0c8a @bclary Bug 1239989 - Autophone - change file paths to include full path, syn…
bclary authored
397 push_file_name = os.path.basename(push)
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
398 push_dest = posixpath.join(self._paths['dest'],
dcd0c8a @bclary Bug 1239989 - Autophone - change file paths to include full path, syn…
bclary authored
399 source,
400 push_file_name)
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
401 self._pushes[push] = push_dest
dcd0c8a @bclary Bug 1239989 - Autophone - change file paths to include full path, syn…
bclary authored
402 if push_file_name == 'initialize_profile.html':
af4126e @bclary Bug 1237755 - Autophone - use explicit file: scheme for local paths, …
bclary authored
403 self._initialize_url = 'file://' + push_dest
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
404 # [tests]
405 self._tests = {}
406 try:
407 for t in self.cfg.items('tests'):
408 self._tests[t[0]] = t[1]
409 except ConfigParser.NoSectionError:
410 self._tests['blank'] = 'blank.html'
411
cd7c3c5 @bclary Bug 1161631 - Autophone - part 2 - revamp logging, r=gbrown.
bclary authored
412 self.loggerdeco.info('PhoneTest: Connected.')
c433f56 @markrcote Bug 776737 Replaced all adb usage with DeviceManagerSUT. r=wlach
markrcote authored
413
f306708 @bclary Bug 1162514 - Autophone - fix device repo mapping, r=gbrown.
bclary authored
414 def __str__(self):
415 return '%s(%s, config_file=%s, chunk=%s)' % (type(self).__name__,
416 self.phone,
417 self.config_file,
418 self.chunk)
419
420 def __repr__(self):
421 return self.__str__()
422
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
423 def _add_instance(self, phoneid, config_file, chunk):
424 key = '%s:%s:%s' % (phoneid, config_file, chunk)
425 assert key not in PhoneTest.instances, 'Duplicate PhoneTest %s' % key
426 PhoneTest.instances[key] = self
427
a0bb699 @bclary Bug 1161631 - Autophone - part 3 -implement help and device commands,…
bclary authored
428 def remove(self):
429 key = '%s:%s:%s' % (self.phone.id, self.config_file, self.chunk)
430 if key in PhoneTest.instances:
431 del PhoneTest.instances[key]
432
c433f56 @markrcote Bug 776737 Replaced all adb usage with DeviceManagerSUT. r=wlach
markrcote authored
433 @property
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
434 def preferences(self):
435 # https://dxr.mozilla.org/mozilla-central/source/mobile/android/app/mobile.js
436 # https://dxr.mozilla.org/mozilla-central/source/browser/app/profile/firefox.js
437 # https://dxr.mozilla.org/mozilla-central/source/addon-sdk/source/test/preferences/no-connections.json
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
438 # https://dxr.mozilla.org/mozilla-central/source/testing/profiles/prefs_general.js
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
439
440 if not self._preferences:
441 self._preferences = {
bbc8809 @bclary Bug 1241584 - Autophone - moar preferences to disable external networ…
bclary authored
442 'app.support.baseURL': 'http://localhost/support-dummy/',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
443 'app.update.auto': False,
444 'app.update.certs.1.commonName': '',
445 'app.update.certs.2.commonName': '',
446 'app.update.enabled': False,
447 'app.update.staging.enabled': False,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
448 'app.update.url': 'http://localhost/app-dummy/update',
449 'app.update.url.android': 'http://localhost/app-dummy/update',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
450 'beacon.enabled': False,
451 'browser.EULA.override': True,
452 'browser.aboutHomeSnippets.updateUrl': '',
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
453 'browser.contentHandlers.types.0.uri': 'http://localhost/rss?url=%%s',
454 'browser.contentHandlers.types.1.uri': 'http://localhost/rss?url=%%s',
455 'browser.contentHandlers.types.2.uri': 'http://localhost/rss?url=%%s',
456 'browser.contentHandlers.types.3.uri': 'http://localhost/rss?url=%%s',
457 'browser.contentHandlers.types.4.uri': 'http://localhost/rss?url=%%s',
458 'browser.contentHandlers.types.5.uri': 'http://localhost/rss?url=%%s',
b793f5b @bclary Bug 1196123 - Autophone smoketest does not use default preferences, r…
bclary authored
459 'browser.firstrun.show.localepicker': False,
460 'browser.firstrun.show.uidiscovery': False,
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
461 'browser.newtab.url': '',
462 'browser.newtabpage.directory.ping': '',
463 'browser.newtabpage.directory.source': 'data:application/json,{"dummy":1}',
bbc8809 @bclary Bug 1241584 - Autophone - moar preferences to disable external networ…
bclary authored
464 'browser.newtabpage.remote': False,
465 'browser.push.warning.infoURL': 'http://localhost/alerts-dummy/infoURL',
466 'browser.push.warning.migrationURL': 'http://localhost/alerts-dummy/migrationURL',
fde25b1 @bclary Bug 1205389 - Autophone - Update preferences for new SafeBrowsing pre…
bclary authored
467 'browser.safebrowsing.appRepURL': '',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
468 'browser.safebrowsing.downloads.enabled': False,
469 'browser.safebrowsing.downloads.remote.enabled': False,
bbc8809 @bclary Bug 1241584 - Autophone - moar preferences to disable external networ…
bclary authored
470 'browser.safebrowsing.downloads.remote.url': 'http://localhost/safebrowsing-dummy/update',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
471 'browser.safebrowsing.enabled': False,
472 'browser.safebrowsing.gethashURL': '',
473 'browser.safebrowsing.malware.enabled': False,
474 'browser.safebrowsing.malware.reportURL': '',
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
475 'browser.safebrowsing.provider.google.appRepURL': 'http://localhost/safebrowsing-dummy/update',
476 'browser.safebrowsing.provider.google.gethashURL': 'http://localhost/safebrowsing-dummy/gethash',
477 'browser.safebrowsing.provider.google.updateURL': 'http://localhost/safebrowsing-dummy/update',
478 'browser.safebrowsing.provider.mozilla.gethashURL': 'http://localhost/safebrowsing-dummy/gethash',
479 'browser.safebrowsing.provider.mozilla.updateURL': 'http://localhost/safebrowsing-dummy/update',
480 'browser.safebrowsing.updateURL': 'http://localhost/safebrowsing-dummy/update',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
481 'browser.search.countryCode': 'US',
e24c297 @bclary Bug 1182802 - Autophone - set browser.search.geoSpecificDefaults fals…
bclary authored
482 'browser.search.geoSpecificDefaults': False,
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
483 'browser.search.geoip.url': '',
484 'browser.search.isUS': True,
485 'browser.search.suggest.enabled': False,
486 'browser.search.update': False,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
487 'browser.selfsupport.url': 'https://localhost/selfsupport-dummy/',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
488 'browser.sessionstore.resume_from_crash': False,
489 'browser.snippets.enabled': False,
490 'browser.snippets.firstrunHomepage.enabled': False,
491 'browser.snippets.syncPromo.enabled': False,
492 'browser.snippets.updateUrl': '',
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
493 'browser.tiles.reportURL': 'http://localhost/tests/robocop/robocop_tiles.sjs',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
494 'browser.trackingprotection.gethashURL': '',
495 'browser.trackingprotection.updateURL': '',
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
496 'browser.translation.bing.authURL': 'http://localhost/browser/browser/components/translation/test/bing.sjs',
497 'browser.translation.bing.translateArrayURL': 'http://localhost/browser/browser/components/translation/test/bing.sjs',
498 'browser.translation.yandex.translateURLOverride': 'http://localhost/browser/browser/components/translation/test/yandex.sjs',
499 'browser.uitour.pinnedTabUrl': 'http://localhost/uitour-dummy/pinnedTab',
500 'browser.uitour.url': 'http://localhost/uitour-dummy/tour',
bbc8809 @bclary Bug 1241584 - Autophone - moar preferences to disable external networ…
bclary authored
501 'browser.urlbar.suggest.searches': False,
502 'browser.urlbar.userMadeSearchSuggestionsChoice': True,
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
503 'browser.warnOnQuit': False,
504 'browser.webapps.apkFactoryUrl': '',
505 'browser.webapps.checkForUpdates': 0,
506 'browser.webapps.updateCheckUrl': '',
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
507 'datareporting.healthreport.about.reportUrl': 'http://localhost/abouthealthreport/',
508 'datareporting.healthreport.about.reportUrlUnified': 'http://localhost/abouthealthreport/v4/',
509 'datareporting.healthreport.documentServerURI': 'http://localhost/healthreport/',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
510 'datareporting.healthreport.service.enabled': False,
511 'datareporting.healthreport.uploadEnabled': False,
512 'datareporting.policy.dataSubmissionEnabled': False,
513 'datareporting.policy.dataSubmissionPolicyBypassAcceptance': True,
514 'dom.ipc.plugins.flash.subprocess.crashreporter.enabled': False,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
515 'experiments.manifest.uri': 'http://localhost/experiments-dummy/manifest',
516 'extensions.autoDisableScopes': 0,
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
517 'extensions.blocklist.enabled': False,
518 'extensions.blocklist.interval': 172800,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
519 'extensions.blocklist.url': 'http://localhost/extensions-dummy/blocklistURL',
520 'extensions.enabledScopes': 5,
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
521 'extensions.getAddons.cache.enabled': False,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
522 'extensions.getAddons.get.url': 'http://localhost/extensions-dummy/repositoryGetURL',
523 'extensions.getAddons.getWithPerformance.url': 'http://localhost/extensions-dummy/repositoryGetWithPerformanceURL',
524 'extensions.getAddons.search.browseURL': 'http://localhost/extensions-dummy/repositoryBrowseURL',
525 'extensions.getAddons.search.url': 'http://localhost/extensions-dummy/repositorySearchURL',
526 'extensions.hotfix.url': 'http://localhost/extensions-dummy/hotfixURL',
bbc8809 @bclary Bug 1241584 - Autophone - moar preferences to disable external networ…
bclary authored
527 'extensions.systemAddon.update.url': 'data:application/xml,<updates></updates>',
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
528 'extensions.update.autoUpdateDefault': False,
529 'extensions.update.background.url': 'http://localhost/extensions-dummy/updateBackgroundURL',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
530 'extensions.update.enabled': False,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
531 'extensions.update.interval': 172800,
532 'extensions.update.url': 'http://localhost/extensions-dummy/updateURL',
533 'extensions.webservice.discoverURL': 'http://localhost/extensions-dummy/discoveryURL',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
534 'general.useragent.updates.enabled': False,
535 'geo.wifi.scan': False,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
536 'geo.wifi.uri': 'http://localhost/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs',
537 'identity.fxaccounts.auth.uri': 'https://localhost/fxa-dummy/',
538 'identity.fxaccounts.remote.force_auth.uri': 'https://localhost/fxa-force-auth',
539 'identity.fxaccounts.remote.signin.uri': 'https://localhost/fxa-signin',
540 'identity.fxaccounts.remote.signup.uri': 'https://localhost/fxa-signup',
541 'identity.fxaccounts.remote.webchannel.uri': 'https://localhost/',
542 'identity.fxaccounts.settings.uri': 'https://localhost/fxa-settings',
bbc8809 @bclary Bug 1241584 - Autophone - moar preferences to disable external networ…
bclary authored
543 'identity.fxaccounts.skipDeviceRegistration': True,
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
544 'media.autoplay.enabled': True,
545 'media.gmp-gmpopenh264.autoupdate': False,
546 'media.gmp-manager.cert.checkAttributes': False,
547 'media.gmp-manager.cert.requireBuiltIn': False,
548 'media.gmp-manager.certs.1.commonName': '',
549 'media.gmp-manager.certs.2.commonName': '',
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
550 'media.gmp-manager.secondsBetweenChecks': 172800,
551 'media.gmp-manager.url': 'http://localhost/media-dummy/gmpmanager',
552 'media.gmp-manager.url.override': 'data:application/xml,<updates></updates>',
4e9a4ba @bclary Bug 1196115 - Autophone - re-enable flash now that bug 1200361 has re…
bclary authored
553 'plugin.state.flash': 2,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
554 'plugins.update.url': 'http://localhost/plugins-dummy/updateCheckURL',
555 'privacy.trackingprotection.introURL': 'http://localhost/trackingprotection/tour',
556 'security.ssl.errorReporting.url': 'https://localhost/browser/browser/base/content/test/general/pinning_reports.sjs?succeed',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
557 'shell.checkDefaultClient': False,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
558 'toolkit.telemetry.cachedClientID': 'dddddddd-dddd-dddd-dddd-dddddddddddd', # https://dxr.mozilla.org/mozilla-central/source/toolkit/modules/ClientID.jsm#40
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
559 'toolkit.telemetry.enabled': False,
560 'toolkit.telemetry.notifiedOptOut': 999,
561 'toolkit.telemetry.prompted': 999,
562 'toolkit.telemetry.rejected': True,
b2bbbab @bclary Bug 1205836 - Autophone - suppress errors due to invalid values in pr…
bclary authored
563 'toolkit.telemetry.server': 'https://localhost/telemetry-dummy/',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
564 'toolkit.telemetry.unified': False,
565 'urlclassifier.updateinterval': 172800,
566 'webapprt.app_update_interval': 172800,
567 'xpinstall.signatures.required': False,
568 }
569 if self.cfg.has_section('preferences'):
570 overrides = self.cfg.options('preferences')
571 for name in overrides:
572 value = self.cfg.get('preferences', name)
573 if value.lower() == 'true':
574 value = True
575 elif value.lower() == 'false':
576 value = False
577 elif re.match('\d+$', value):
578 value = int(value)
579 self._preferences[name] = value
580 return self._preferences
581
582 @property
583 def environment(self):
584 if not self._environment:
585 # https://developer.mozilla.org/en-US/docs/Environment_variables_affecting_crash_reporting
586 self._environment = {
587 'MOZ_CRASHREPORTER': '1',
aacba4b @bclary Bug 1205394 - Set MOZ_CRASHREPORTER_NO_REPORT in environment to suppr…
bclary authored
588 'MOZ_CRASHREPORTER_NO_REPORT': '1',
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
589 'MOZ_CRASHREPORTER_SHUTDOWN': '1',
590 'MOZ_DISABLE_NONLOCAL_CONNECTIONS': '1',
591 'NO_EM_RESTART': '1',
592 #'NSPR_LOG_MODULES': 'all:5',
593 }
594 if self.cfg.has_section('environment'):
595 overrides = self.cfg.options('environment')
596 for name in overrides:
597 value = self.cfg.get('environment', name)
598 if value.lower() == 'true':
599 value = True
600 elif value.lower() == 'false':
601 value = False
602 elif re.match('\d+$', value):
603 value = int(value)
604 self._environment[name] = value
605 return self._environment
606
607 @property
fadc14c @bclary Bug 1118758 - Autophone - add support for job specific tests, r=mcote.
bclary authored
608 def name_suffix(self):
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
609 return '-%s' % self.chunk if self.chunks > 1 else ''
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
610
611 @property
fadc14c @bclary Bug 1118758 - Autophone - add support for job specific tests, r=mcote.
bclary authored
612 def name(self):
613 return 'autophone-%s%s' % (self.__class__.__name__, self.name_suffix)
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
614
615 @property
96834af @markrcote Can create, push, and use custom profiles. Some pulse support.
markrcote authored
616 def base_device_path(self):
617 if self._base_device_path:
618 return self._base_device_path
059aef2 @bclary bug 852264 - Autophone - modify configuration to improve flexibility,…
bclary authored
619 success = False
620 e = None
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
621 for attempt in range(1, self.options.phone_retry_limit+1):
8bddba3 @bclary Bug 990601 - Autophone - use adb instead of tcp/ip to control devices…
bclary authored
622 self._base_device_path = self.dm.test_root + '/autophone'
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
623 self.loggerdeco.debug('Attempt %d creating base device path %s' % (
624 attempt, self._base_device_path))
059aef2 @bclary bug 852264 - Autophone - modify configuration to improve flexibility,…
bclary authored
625 try:
4b0e4f1 @bclary Bug 1214812 - Autophone - add configurable test_root, r=gbrown.
bclary authored
626 if not self.dm.is_dir(self._base_device_path, root=True):
627 self.dm.mkdir(self._base_device_path, parents=True, root=True)
628 self.dm.chmod(self._base_device_path, recursive=True, root=True)
059aef2 @bclary bug 852264 - Autophone - modify configuration to improve flexibility,…
bclary authored
629 success = True
630 break
92416ce @bclary Bug 1007220 - Add webapp startup test, r=mcote.
bclary authored
631 except ADBError:
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
632 self.loggerdeco.exception('Attempt %d creating base device '
633 'path %s' % (
634 attempt, self._base_device_path))
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
635 sleep(self.options.phone_retry_wait)
405135e Correctly push profile and runbrowserprofile.sh to phone
Clint Talbert authored
636
059aef2 @bclary bug 852264 - Autophone - modify configuration to improve flexibility,…
bclary authored
637 if not success:
638 raise e
639
8bddba3 @bclary Bug 990601 - Autophone - use adb instead of tcp/ip to control devices…
bclary authored
640 self.loggerdeco.debug('base_device_path is %s' % self._base_device_path)
641
059aef2 @bclary bug 852264 - Autophone - modify configuration to improve flexibility,…
bclary authored
642 return self._base_device_path
91b2c03 @markrcote Initial commit.
markrcote authored
643
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
644 @property
0a55fdb @bclary Bug 1172489 - Autophone - email notifications should include link to …
bclary authored
645 def job_url(self):
646 if not self.options.treeherder_url:
647 return None
6dfff92 @bclary Bug 1241125 - Autophone - include tiers in Treeherder result links, r…
bclary authored
648 job_url = ('%s/#/jobs?filter-searchStr=autophone&' +
649 'exclusion_profile=false&' +
650 'filter-tier=1&filter-tier=2&filter-tier=3&' +
651 'repo=%s&revision=%s')
0a55fdb @bclary Bug 1172489 - Autophone - email notifications should include link to …
bclary authored
652 return job_url % (self.options.treeherder_url,
653 self.build.tree,
db3e749 @bclary Bug 1205396 - Autophone - limit revision to 12 characters in job url …
bclary authored
654 os.path.basename(self.build.revision)[:12])
0a55fdb @bclary Bug 1172489 - Autophone - email notifications should include link to …
bclary authored
655
656 @property
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
657 def job_name(self):
658 if not self.options.treeherder_url:
659 return None
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
660 if not self._job_name:
661 self._job_name = self.cfg.get('treeherder', 'job_name')
662 return self._job_name
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
663
664 @property
665 def job_symbol(self):
666 if not self.options.treeherder_url:
667 return None
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
668 if not self._job_symbol:
669 self._job_symbol = self.cfg.get('treeherder', 'job_symbol')
670 if self.chunks > 1:
671 self._job_symbol = "%s%s" %(self._job_symbol, self.chunk)
672 return self._job_symbol
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
673
674 @property
675 def group_name(self):
676 if not self.options.treeherder_url:
677 return None
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
678 if not self._group_name:
679 self._group_name = self.cfg.get('treeherder', 'group_name')
680 return self._group_name
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
681
682 @property
683 def group_symbol(self):
684 if not self.options.treeherder_url:
685 return None
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
686 if not self._group_symbol:
687 self._group_symbol = self.cfg.get('treeherder', 'group_symbol')
688 return self._group_symbol
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
689
690 @property
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
691 def build(self):
692 return self.worker_subprocess.build
693
ca87211 @bclary Bug 1158276 - Autophone - download test packages, r=gbrown.
bclary authored
694 def get_test_package_names(self):
695 """Return a set of test package names which need to be downloaded
696 along with the build in order to run the test. This set will
697 be passed to the BuildCache.get() method. Normally, this will
698 only need to be set for UnitTests.
699
700 See https://bugzilla.mozilla.org/show_bug.cgi?id=1158276
701 https://bugzilla.mozilla.org/show_bug.cgi?id=917999
702 """
703 return set()
704
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
705 def generate_guid(self):
706 self.job_guid = utils.generate_guid()
707
708 def get_buildername(self, tree):
6e8806f @bclary Bug 1153992 - Autophone - allow test manifest to include multiple sec…
bclary authored
709 return "%s %s opt %s" % (
710 self.phone.platform, tree, self.name)
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
711
3ae1b09 @bclary Bug 1155885 - Autophone - should automatically recover when devices a…
bclary authored
712 def handle_test_interrupt(self, reason, test_result):
713 self.test_failure(self.name, 'TEST-UNEXPECTED-FAIL', reason, test_result)
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
714
715 def test_pass(self, testpath):
716 self.test_result.add_pass(testpath)
717
718 def test_failure(self, testpath, status, message, testresult_status):
719 self.message = message
720 self.update_status(message=message)
721 self.test_result.add_failure(testpath, status, message, testresult_status)
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
722
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
723 def handle_crashes(self):
724 if not self.crash_processor:
725 return
726
727 for error in self.crash_processor.get_errors(self.build.symbols,
1496635 @bclary Bug 1118883 - Autophone - upload crash dmp files to S3, r=mcote.
bclary authored
728 self.options.minidump_stackwalk,
729 clean=False):
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
730 if error['reason'] == 'java-exception':
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
731 self.test_failure(
732 self.name, 'PROCESS-CRASH',
733 error['signature'],
734 PhoneTestResult.EXCEPTION)
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
735 elif error['reason'] == 'PROFILE-ERROR':
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
736 self.test_failure(
737 self.name,
738 error['reason'],
739 error['signature'],
740 PhoneTestResult.TESTFAILED)
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
741 elif error['reason'] == 'PROCESS-CRASH':
742 self.loggerdeco.info("PROCESS-CRASH | %s | "
743 "application crashed [%s]" % (self.name,
744 error['signature']))
745 self.loggerdeco.info(error['stackwalk_output'])
746 self.loggerdeco.info(error['stackwalk_errors'])
747
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
748 self.test_failure(self.name,
749 error['reason'],
750 'application crashed [%s]' % error['signature'],
751 PhoneTestResult.TESTFAILED)
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
752 else:
753 self.loggerdeco.warning('Unknown error reason: %s' % error['reason'])
754
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
755 def create_profile(self, custom_addons=[], custom_prefs=None, root=True):
756 # Create, install and initialize the profile to be
757 # used in the test.
758
759 temp_addons = ['quitter.xpi']
760 temp_addons.extend(custom_addons)
761 addons = ['%s/xpi/%s' % (os.getcwd(), addon) for addon in temp_addons]
762
763 # make sure firefox isn't running when we try to
764 # install the profile.
765
766 self.dm.pkill(self.build.app_name, root=root)
767 if isinstance(custom_prefs, dict):
768 prefs = dict(self.preferences.items() + custom_prefs.items())
769 else:
770 prefs = self.preferences
771 profile = FirefoxProfile(preferences=prefs, addons=addons)
772 if not self.install_profile(profile):
773 return False
774
775 success = False
776 for attempt in range(1, self.options.phone_retry_limit+1):
777 self.loggerdeco.debug('Attempt %d Initializing profile' % attempt)
778 self.run_fennec_with_profile(self.build.app_name, self._initialize_url)
779
780 if self.wait_for_fennec():
781 success = True
782 break
783 sleep(self.options.phone_retry_wait)
784
785 if not success:
786 msg = 'Aborting Test - Failure initializing profile.'
787 self.loggerdeco.error(msg)
788
789 return success
790
791 def wait_for_fennec(self, max_wait_time=60, wait_time=5,
792 kill_wait_time=20, root=True):
793 # Wait for up to a max_wait_time seconds for fennec to close
794 # itself in response to the quitter request. Check that fennec
795 # is still running every wait_time seconds. If fennec doesn't
796 # close on its own, attempt up to 3 times to kill fennec, waiting
797 # kill_wait_time seconds between attempts.
798 # Return True if fennec exits on its own, False if it needs to be killed.
799 # Re-raise the last exception if fennec can not be killed.
800 max_wait_attempts = max_wait_time / wait_time
801 for wait_attempt in range(1, max_wait_attempts+1):
802 if not self.dm.process_exist(self.build.app_name):
803 return True
804 sleep(wait_time)
805 self.loggerdeco.debug('killing fennec')
806 max_killattempts = 3
807 for kill_attempt in range(1, max_killattempts+1):
808 try:
809 self.dm.pkill(self.build.app_name, root=root)
810 break
811 except ADBError:
812 self.loggerdeco.exception('Attempt %d to kill fennec failed' %
813 kill_attempt)
814 if kill_attempt == max_killattempts:
815 raise
816 sleep(kill_wait_time)
817 return False
818
819 def install_local_pages(self):
820 success = False
821 for attempt in range(1, self.options.phone_retry_limit+1):
822 self.loggerdeco.debug('Attempt %d Installing local pages' % attempt)
823 try:
4b0e4f1 @bclary Bug 1214812 - Autophone - add configurable test_root, r=gbrown.
bclary authored
824 self.dm.rm(self._paths['dest'], recursive=True, force=True, root=True)
825 self.dm.mkdir(self._paths['dest'], parents=True, root=True)
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
826 for push_source in self._pushes:
827 push_dest = self._pushes[push_source]
828 if os.path.isdir(push_source):
829 self.dm.push(push_source, push_dest)
830 else:
831 self.dm.push(push_source, push_dest)
2043de9 @bclary Bug 1238450 - Autophone - make sure pushed directories are world acce…
bclary authored
832 self.dm.chmod(self._paths['dest'], recursive=True, root=True)
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
833 success = True
834 break
835 except ADBError:
836 self.loggerdeco.exception('Attempt %d Installing local pages' % attempt)
837 sleep(self.options.phone_retry_wait)
838
839 if not success:
840 self.loggerdeco.error('Failure installing local pages')
841
842 return success
843
844 def is_fennec_running(self, appname):
845 for attempt in range(1, self.options.phone_retry_limit+1):
846 try:
847 return self.dm.process_exist(appname)
848 except ADBError:
849 self.loggerdeco.exception('Attempt %d is fennec running' % attempt)
850 if attempt == self.options.phone_retry_limit:
851 raise
852 sleep(self.options.phone_retry_wait)
853
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
854 def setup_job(self):
5df25aa @bclary Bug 1205388 - Autophone - better handle logcat collection, r=gbrown.
bclary authored
855 # Log the current full contents of logcat, then clear the
856 # logcat buffers to help prevent the device's buffer from
857 # over flowing during the test.
b6dc95d @bclary Bug 1119654 - Autophone - separate installation specific settings, r=…
bclary authored
858 self.start_time = datetime.datetime.now()
0fcbbd3 @bclary Bug 1161631 - Autophone - fix possible uninitialized PhoneTest.start_…
bclary authored
859 self.stop_time = self.start_time
9e37b83 @bclary Bug 1147480 - Autophone - phonetest.setup_job - clear job_details, r=…
bclary authored
860 # Clear the Treeherder job details.
861 self.job_details = []
79bb3c4 @bclary Bug 1209651 - Autophone - do not allow logcat device error to prevent…
bclary authored
862 self.loggerdeco.debug('phonetest.setup_job: full logcat before job:')
047bfa7 @bclary Bug 1213868 - Autophone - catch device logcat exceptions in PhoneTest…
bclary authored
863 try:
864 self.loggerdeco.debug('\n'.join(self.logcat.get(full=True)))
865 except:
866 self.loggerdeco.exception('Exception getting logcat')
867 try:
868 self.logcat.reset()
869 except:
870 self.loggerdeco.exception('Exception resetting logcat')
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
871 self.worker_subprocess.treeherder.submit_running(
872 self.phone.id,
873 self.build.url,
874 self.build.tree,
875 self.build.revision_hash,
876 tests=[self])
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
877
0fcbbd3 @bclary Bug 1161631 - Autophone - fix possible uninitialized PhoneTest.start_…
bclary authored
878 self.loggerdeco_original = self.loggerdeco
879 # self.dm._logger can raise ADBTimeoutError due to the
880 # property dm therefore place it after the initialization.
881 self.dm_logger_original = self.dm._logger
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
882 # Create a test run specific logger which will propagate to
883 # the root logger in the worker which runs in the same
884 # process. This log will be uploaded to Treeherder if
885 # Treeherder submission is enabled and will be cleared at the
886 # beginning of each test run.
887 sensitive_data_filter = SensitiveDataFilter(self.options.sensitive_data)
888 logger = logging.getLogger('phonetest')
889 logger.addFilter(sensitive_data_filter)
890 logger.propagate = True
891 logger.setLevel(self.worker_subprocess.loglevel)
892 self.test_logfile = (self.worker_subprocess.logfile_prefix +
893 '-' + self.name + '.log')
894 self.test_logfilehandler = logging.FileHandler(
895 self.test_logfile, mode='w')
896 fileformatstring = ('%(asctime)s|%(process)d|%(threadName)s|%(name)s|'
897 '%(levelname)s|%(message)s')
898 fileformatter = logging.Formatter(fileformatstring)
899 self.test_logfilehandler.setFormatter(fileformatter)
900 logger.addHandler(self.test_logfilehandler)
901
cd7c3c5 @bclary Bug 1161631 - Autophone - part 2 - revamp logging, r=gbrown.
bclary authored
902 self.loggerdeco = LogDecorator(logger,
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
903 {'phoneid': self.phone.id,
904 'buildid': self.build.id,
905 'test': self.name},
1414831 @bclary Bug 1161631 - Autophone - part 1 - implement shutdown command, r=gbrown.
bclary authored
906 '%(phoneid)s|%(buildid)s|%(test)s|'
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
907 '%(message)s')
908 self.dm._logger = self.loggerdeco
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
909 self.loggerdeco.debug('PhoneTest.setup_job')
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
910 if self.unittest_logpath:
911 os.unlink(self.unittest_logpath)
912 self.unittest_logpath = None
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
913 self.upload_dir = tempfile.mkdtemp()
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
914 self.crash_processor = AutophoneCrashProcessor(self.dm,
915 self.profile_path,
0ec9ac8 @bclary Bug 1211227 - Autophone - work around webapp Crash Reporter moving dm…
bclary authored
916 self.upload_dir,
917 self.build.app_name)
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
918 self.crash_processor.clear()
fe24e2d @bclary bug 1080784 - Autophone - Reset the PhoneTest.test_result on setup_jo…
bclary authored
919 self.test_result = PhoneTestResult()
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
920 if not self.worker_subprocess.is_disabled():
921 self.update_status(phone_status=PhoneStatus.WORKING,
922 message='Setting up %s' % self.name)
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
923
924 def run_job(self):
91b2c03 @markrcote Initial commit.
markrcote authored
925 raise NotImplementedError
926
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
927 def teardown_job(self):
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
928 self.loggerdeco.debug('PhoneTest.teardown_job')
b6dc95d @bclary Bug 1119654 - Autophone - separate installation specific settings, r=…
bclary authored
929 self.stop_time = datetime.datetime.now()
930 self.loggerdeco.info('Test %s elapsed time: %s' % (
931 self.name, self.stop_time - self.start_time))
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
932 try:
3ae1b09 @bclary Bug 1155885 - Autophone - should automatically recover when devices a…
bclary authored
933 if self.worker_subprocess.is_ok():
934 # Do not attempt to process crashes if the device is
935 # in an error state.
936 self.handle_crashes()
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
937 except Exception, e:
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
938 self.loggerdeco.exception('Exception during crash processing')
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
939 self.test_failure(
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
940 self.name, 'TEST-UNEXPECTED-FAIL',
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
941 'Exception %s during crash processing' % e,
942 PhoneTestResult.EXCEPTION)
5df25aa @bclary Bug 1205388 - Autophone - better handle logcat collection, r=gbrown.
bclary authored
943 logger = logging.getLogger('phonetest')
944 if (logger.getEffectiveLevel() == logging.DEBUG and self.unittest_logpath and
945 os.path.exists(self.unittest_logpath)):
946 self.loggerdeco.debug(40 * '=')
947 try:
948 logfilehandle = open(self.unittest_logpath)
949 self.loggerdeco.debug(logfilehandle.read())
950 logfilehandle.close()
951 except Exception:
952 self.loggerdeco.exception('Exception %s loading log')
953 self.loggerdeco.debug(40 * '-')
954 # Log the current full contents of logcat, then reset the
955 # logcat buffers to help prevent the device's buffer from
956 # over flowing after the test.
957 self.loggerdeco.debug('phonetest.teardown_job full logcat after job:')
958 self.loggerdeco.debug('\n'.join(self.logcat.get(full=True)))
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
959 try:
960 if (self.worker_subprocess.is_disabled() and
961 self.test_result.status != PhoneTestResult.USERCANCEL):
962 # The worker was disabled while running one test of a job.
963 # Record the cancellation on any remaining tests in that job.
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
964 self.test_failure(self.name, 'TEST_UNEXPECTED_FAIL',
965 'The worker was disabled.',
966 PhoneTestResult.USERCANCEL)
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
967 self.worker_subprocess.treeherder.submit_complete(
968 self.phone.id,
969 self.build.url,
970 self.build.tree,
971 self.build.revision_hash,
972 tests=[self])
973 except:
974 self.loggerdeco.exception('Exception tearing down job')
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
975 finally:
1674eb1 @bclary Bug 1119457 - Autophone - upload device logs, r=mcote.
bclary authored
976 if self.upload_dir and os.path.exists(self.upload_dir):
977 shutil.rmtree(self.upload_dir)
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
978 self.upload_dir = None
979
da1800c @bclary Bug 1161631 - Autophone - reset PhoneTest.test_result.status after jo…
bclary authored
980 # Reset the tests' volatile members in order to prevent them
981 # from being reused after a test has completed.
982 self.test_result = PhoneTestResult()
983 self.message = None
984 self.job_guid = None
985 self.job_details = []
986 self.submit_timestamp = None
987 self.start_timestamp = None
988 self.end_timestamp = None
989 self.upload_dir = None
990 self.start_time = None
991 self.stop_time = None
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
992 self.unittest_logpath = None
5df25aa @bclary Bug 1205388 - Autophone - better handle logcat collection, r=gbrown.
bclary authored
993 self.logcat.reset()
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
994 if self.loggerdeco_original:
995 self.loggerdeco = self.loggerdeco_original
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
996 self.loggerdeco_original = None
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
997 if self.dm_logger_original:
998 self.dm._logger = self.dm_logger_original
0560fe7 @bclary Bug 1197374 - Autophone - create separate logs for devices and tests,…
bclary authored
999 self.dm_logger_original = None
1000
1001 self.test_logfilehandler.close()
1002 logger.removeHandler(self.test_logfilehandler)
1003 self.test_logfilehandler = None
1004 os.unlink(self.test_logfile)
1005 self.test_logfile = None
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
1006
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
1007 def update_status(self, phone_status=None, message=None):
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
1008 if self.update_status_cb:
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
1009 self.update_status_cb(build=self.build,
1010 phone_status=phone_status,
8292c84 @bclary Bug 1063886 - Autophone - paydown technical debt, r=mcote.
bclary authored
1011 message=message)
91b2c03 @markrcote Initial commit.
markrcote authored
1012
bd0ccdb @bclary Bug 1118751 - explicitly specify root=True in argument lists where ap…
bclary authored
1013 def install_profile(self, profile=None, root=True):
96834af @markrcote Can create, push, and use custom profiles. Some pulse support.
markrcote authored
1014 if not profile:
1015 profile = FirefoxProfile()
524b0db @markrcote Bug 790380 - Handle worker crashes and misc. other improvements and f…
markrcote authored
1016
8bddba3 @bclary Bug 990601 - Autophone - use adb instead of tcp/ip to control devices…
bclary authored
1017 profile_path_parent = os.path.split(self.profile_path)[0]
61f11d6 @bclary Bug 964645 - Autophone - improve logging, error recovery and throbber…
bclary authored
1018 success = False
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
1019 for attempt in range(1, self.options.phone_retry_limit+1):
61f11d6 @bclary Bug 964645 - Autophone - improve logging, error recovery and throbber…
bclary authored
1020 try:
1021 self.loggerdeco.debug('Attempt %d installing profile' % attempt)
03a4d05 @bclary Bug 1216690 - Autophone - audit and pass root to adb when function co…
bclary authored
1022 if self.dm.exists(self.profile_path, root=root):
8d62c88 @bclary Bug 1213879 - Autophone - worker harder to create clean profile direc…
bclary authored
1023 # If the profile already exists, chmod it to make sure
1024 # we have permission to delete it.
1025 self.dm.chmod(self.profile_path, recursive=True, root=root)
1026 self.dm.rm(self.profile_path, recursive=True,
1027 force=True, root=root)
bd0ccdb @bclary Bug 1118751 - explicitly specify root=True in argument lists where ap…
bclary authored
1028 self.dm.chmod(profile_path_parent, root=root)
1029 self.dm.mkdir(self.profile_path, root=root)
1030 self.dm.chmod(self.profile_path, root=root)
8bddba3 @bclary Bug 990601 - Autophone - use adb instead of tcp/ip to control devices…
bclary authored
1031 self.dm.push(profile.profile, self.profile_path)
bd0ccdb @bclary Bug 1118751 - explicitly specify root=True in argument lists where ap…
bclary authored
1032 self.dm.chmod(self.profile_path, recursive=True, root=root)
61f11d6 @bclary Bug 964645 - Autophone - improve logging, error recovery and throbber…
bclary authored
1033 success = True
1034 break
92416ce @bclary Bug 1007220 - Add webapp startup test, r=mcote.
bclary authored
1035 except ADBError:
5d020e1 @bclary Bug 1037077 - Report run status to treeherder, r=mcote.
bclary authored
1036 self.loggerdeco.exception('Attempt %d Exception installing '
1037 'profile to %s' % (
1038 attempt, self.profile_path))
a1584c9 @bclary Bug 1190912 - Autophone - refactor tests to remove necessity for dupl…
bclary authored
1039 sleep(self.options.phone_retry_wait)
61f11d6 @bclary Bug 964645 - Autophone - improve logging, error recovery and throbber…
bclary authored
1040
1041 if not success:
8bddba3 @bclary Bug 990601 - Autophone - use adb instead of tcp/ip to control devices…
bclary authored
1042 self.loggerdeco.error('Failure installing profile to %s' % self.profile_path)
61f11d6 @bclary Bug 964645 - Autophone - improve logging, error recovery and throbber…
bclary authored
1043
1044 return success
405135e Correctly push profile and runbrowserprofile.sh to phone
Clint Talbert authored
1045
1fa6160 @jmaher Bug 1172105 - write a tests/talostest.py to autophone for tp4m/tsvg
jmaher authored
1046 def run_fennec_with_profile(self, appname, url, extra_args=[]):
1047 self.loggerdeco.debug('run_fennec_with_profile: %s %s %s' %
1048 (appname, url, extra_args))
1049 local_extra_args = ['-profile', self.profile_path]
1050 local_extra_args.extend(extra_args)
1051
873caf0 @bclary bug 862508 - use mozdevice.DroidSUT.launchFennec
bclary authored
1052 try:
8bddba3 @bclary Bug 990601 - Autophone - use adb instead of tcp/ip to control devices…
bclary authored
1053 self.dm.pkill(appname, root=True)
1054 self.dm.launch_fennec(appname,
873caf0 @bclary bug 862508 - use mozdevice.DroidSUT.launchFennec
bclary authored
1055 intent="android.intent.action.VIEW",
2bcb211 @bclary Bug 1177491 - Autophone - standardize custom fennec preferences and e…
bclary authored
1056 moz_env=self.environment,
1fa6160 @jmaher Bug 1172105 - write a tests/talostest.py to autophone for tp4m/tsvg
jmaher authored
1057 extra_args=local_extra_args,
873caf0 @bclary bug 862508 - use mozdevice.DroidSUT.launchFennec
bclary authored
1058 url=url,
ee040e2 @bclary bug 866195 - Improve Autophone s1s2 test reproducibility followup, r=…
bclary authored
1059 wait=False,
8bddba3 @bclary Bug 990601 - Autophone - use adb instead of tcp/ip to control devices…
bclary authored
1060 fail_if_running=False)
873caf0 @bclary bug 862508 - use mozdevice.DroidSUT.launchFennec
bclary authored
1061 except:
1062 self.loggerdeco.exception('run_fennec_with_profile: Exception:')
1063 raise
405135e Correctly push profile and runbrowserprofile.sh to phone
Clint Talbert authored
1064
bd0ccdb @bclary Bug 1118751 - explicitly specify root=True in argument lists where ap…
bclary authored
1065 def remove_sessionstore_files(self, root=True):
1066 self.dm.rm(self.profile_path + '/sessionstore.js',
1067 force=True,
1068 root=root)
1069 self.dm.rm(self.profile_path + '/sessionstore.bak',
1070 force=True,
1071 root=root)
cfce5c6 @bclary Bug 851288 - Use quitter.xpi for terminating fennec in autophone s1s2…
bclary authored
1072
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
1073 @property
bd0ccdb @bclary Bug 1118751 - explicitly specify root=True in argument lists where ap…
bclary authored
1074 def fennec_crashed(self, root=True):
cfce5c6 @bclary Bug 851288 - Use quitter.xpi for terminating fennec in autophone s1s2…
bclary authored
1075 """
1076 Perform a quick check for crashes by checking
1077 self.profile_path/minidumps for dump files.
1078
1079 """
bd0ccdb @bclary Bug 1118751 - explicitly specify root=True in argument lists where ap…
bclary authored
1080 if self.dm.exists(os.path.join(self.profile_path, 'minidumps', '*.dmp'),
1081 root=root):
7fb94b3 @bclary bug 1080783 - Autophone - process crash dumps, r=mcote.
bclary authored
1082 self.loggerdeco.info('fennec crashed')
cfce5c6 @bclary Bug 851288 - Use quitter.xpi for terminating fennec in autophone s1s2…
bclary authored
1083 return True
03a4d05 @bclary Bug 1216690 - Autophone - audit and pass root to adb when function co…
bclary authored
1084 if self.dm.exists(
1085 '/data/data/%s/files/mozilla/Crash\\ Reports/pending/*.dmp' % self.build.app_name,
1086 root=root):
0ec9ac8 @bclary Bug 1211227 - Autophone - work around webapp Crash Reporter moving dm…
bclary authored
1087 self.loggerdeco.info('fennec crashed, but minidumps are in Pending Crash Reports.')
1088 return True
cfce5c6 @bclary Bug 851288 - Use quitter.xpi for terminating fennec in autophone s1s2…
bclary authored
1089 return False
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
1090
1091 class PhoneTestResult(object):
1092 """PhoneTestResult encapsulates the data format used by logparser
1093 so we can have a uniform approach to recording test results between
1094 native Autophone tests and Unit tests.
1095 """
1096 #SKIPPED = 'skipped'
1097 BUSTED = 'busted'
1098 EXCEPTION = 'exception'
1099 TESTFAILED = 'testfailed'
1100 UNKNOWN = 'unknown'
1101 USERCANCEL = 'usercancel'
1102 RETRY = 'retry'
1103 SUCCESS = 'success'
1104
1105 def __init__(self):
161d7c4 @bclary Bug 1133580 - Autophone - incorporate job action processing in tests,…
bclary authored
1106 self.status = PhoneTestResult.SUCCESS
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
1107 self.passes = []
1108 self.failures = []
1109 self.todo = 0
1110
1111 def __str__(self):
1112 return "PhoneTestResult: passes: %s, failures: %s" % (self.passes, self.failures)
1113
1114 @property
1115 def passed(self):
1116 return len(self.passes)
1117
1118 @property
1119 def failed(self):
1120 return len(self.failures)
1121
1122 def add_pass(self, testpath):
1123 self.passes.append(testpath)
1124
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
1125 def add_failure(self, testpath, test_status, text, testresult_status):
1126 if testresult_status:
1127 self.status = testresult_status
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
1128 self.failures.append({
1129 "test": testpath,
287c3b8 @bclary Bug 1147480 - Autophone - Consolidate add test failure logic, fix reg…
bclary authored
1130 "status": test_status,
b8f2f26 @bclary Bug 1079923 - Autophone - update unittests to fix bitrot, r=mcote.
bclary authored
1131 "text": text})
Something went wrong with that request. Please try again.