Bug 989282 - [tps] Add debug mode for detailed inspection of Sync. r=jgriffin a=lsblakk DONTBUILD
authorHenrik Skupin <mail@hskupin.info>
Mon, 31 Mar 2014 20:17:09 +0200
changeset 185292 cb76d3bd48afcc455a9d8a04e6a6d6be31251d5f
parent 185291 b1b159c885cc0b1a74cae514e96e6289391cabce
child 185293 cc65c1da54e000db071d2e5f15853f9c08350a1c
push id5583
push userhskupin@mozilla.com
push dateWed, 02 Apr 2014 06:10:38 +0000
treeherdermozilla-aurora@cb76d3bd48af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin, lsblakk
bugs989282
milestone30.0a2
Bug 989282 - [tps] Add debug mode for detailed inspection of Sync. r=jgriffin a=lsblakk DONTBUILD
testing/tps/tps/cli.py
testing/tps/tps/testrunner.py
--- a/testing/tps/tps/cli.py
+++ b/testing/tps/tps/cli.py
@@ -9,66 +9,71 @@ import re
 import sys
 from threading import RLock
 
 from tps import TPSTestRunner
 
 
 def main():
     parser = optparse.OptionParser()
-    parser.add_option('--mobile',
-                      action='store_true',
-                      dest='mobile',
-                      default=False,
-                      help='run with mobile settings')
-    parser.add_option('--testfile',
-                      action='store',
-                      type='string',
-                      dest='testfile',
-                      default='../../services/sync/tests/tps/all_tests.json',
-                      help='path to the test file to run [default: %default]')
-    parser.add_option('--logfile',
-                      action='store',
-                      type='string',
-                      dest='logfile',
-                      default='tps.log',
-                      help='path to the log file [default: %default]')
-    parser.add_option('--resultfile',
-                      action='store',
-                      type='string',
-                      dest='resultfile',
-                      default='tps_result.json',
-                      help='path to the result file [default: %default]')
     parser.add_option('--binary',
                       action='store',
                       type='string',
                       dest='binary',
                       default=None,
                       help='path to the Firefox binary, specified either as '
                            'a local file or a url; if omitted, the PATH '
                            'will be searched;')
     parser.add_option('--configfile',
                       action='store',
                       type='string',
                       dest='configfile',
                       default=None,
                       help='path to the config file to use default: %default]')
+    parser.add_option('--debug',
+                      action='store_true',
+                      dest='debug',
+                      default=False,
+                      help='run in debug mode')
+    parser.add_option('--ignore-unused-engines',
+                       default=False,
+                       action='store_true',
+                       dest='ignore_unused_engines',
+                       help='If defined, do not load unused engines in individual tests.'
+                            ' Has no effect for pulse monitor.')
+    parser.add_option('--logfile',
+                      action='store',
+                      type='string',
+                      dest='logfile',
+                      default='tps.log',
+                      help='path to the log file [default: %default]')
+    parser.add_option('--mobile',
+                      action='store_true',
+                      dest='mobile',
+                      default=False,
+                      help='run with mobile settings')
     parser.add_option('--pulsefile',
                       action='store',
                       type='string',
                       dest='pulsefile',
                       default=None,
                       help='path to file containing a pulse message in '
                            'json format that you want to inject into the monitor')
-    parser.add_option('--ignore-unused-engines',
-                       default=False,
-                       action='store_true',
-                       dest='ignore_unused_engines',
-                       help='If defined, do not load unused engines in individual tests.'
-                            ' Has no effect for pulse monitor.')
+    parser.add_option('--resultfile',
+                      action='store',
+                      type='string',
+                      dest='resultfile',
+                      default='tps_result.json',
+                      help='path to the result file [default: %default]')
+    parser.add_option('--testfile',
+                      action='store',
+                      type='string',
+                      dest='testfile',
+                      default='../../services/sync/tests/tps/all_tests.json',
+                      help='path to the test file to run [default: %default]')
     (options, args) = parser.parse_args()
 
     configfile = options.configfile
     if configfile is None:
         if os.environ.get('VIRTUAL_ENV'):
             configfile = os.path.join(os.path.dirname(__file__), 'config.json')
         if configfile is None or not os.access(configfile, os.F_OK):
             raise Exception('Unable to find config.json in a VIRTUAL_ENV; you must '
@@ -92,20 +97,22 @@ def main():
         if sys.platform == 'win32':
             # replace msys-style paths with proper Windows paths
             m = re.match('^\/\w\/', extensionDir)
             if m:
                 extensionDir = '%s:/%s' % (m.group(0)[1:2], extensionDir[3:])
                 extensionDir = extensionDir.replace('/', '\\')
 
     TPS = TPSTestRunner(extensionDir,
-                        testfile=options.testfile,
-                        logfile=options.logfile,
                         binary=options.binary,
                         config=config,
-                        rlock=rlock,
+                        debug=options.debug,
+                        ignore_unused_engines=options.ignore_unused_engines,
+                        logfile=options.logfile,
                         mobile=options.mobile,
                         resultfile=options.resultfile,
-                        ignore_unused_engines=options.ignore_unused_engines)
+                        rlock=rlock,
+                        testfile=options.testfile,
+                      )
     TPS.run_tests()
 
 if __name__ == '__main__':
     main()
--- a/testing/tps/tps/testrunner.py
+++ b/testing/tps/tps/testrunner.py
@@ -41,80 +41,110 @@ class TempFile(object):
         if os.access(self.filename, os.F_OK):
             os.remove(self.filename)
 
     __del__ = cleanup
 
 
 class TPSTestRunner(object):
 
-    default_env = { 'MOZ_CRASHREPORTER_DISABLE': '1',
-                    'GNOME_DISABLE_CRASH_DIALOG': '1',
-                    'XRE_NO_WINDOWS_CRASH_DIALOG': '1',
-                    'MOZ_NO_REMOTE': '1',
-                    'XPCOM_DEBUG_BREAK': 'warn',
-                  }
-    default_preferences = { 'app.update.enabled' : False,
-                            'browser.dom.window.dump.enabled': True,
-                            'browser.sessionstore.resume_from_crash': False,
-                            'browser.shell.checkDefaultBrowser' : False,
-                            'browser.tabs.warnOnClose' : False,
-                            'browser.warnOnQuit': False,
-                            # Allow installing extensions dropped into the profile folder
-                            'extensions.autoDisableScopes': 10,
-                            'extensions.getAddons.get.url': 'http://127.0.0.1:4567/addons/api/%IDS%.xml',
-                            'extensions.update.enabled'    : False,
-                            # Don't open a dialog to show available add-on updates
-                            'extensions.update.notifyUser' : False,
-                            'services.sync.addons.ignoreRepositoryChecking': True,
-                            'services.sync.firstSync': 'notReady',
-                            'services.sync.lastversion': '1.0',
-                            'services.sync.log.rootLogger': 'Trace',
-                            'services.sync.log.logger.engine.addons': 'Trace',
-                            'services.sync.log.logger.service.main': 'Trace',
-                            'services.sync.log.logger.engine.bookmarks': 'Trace',
-                            'services.sync.log.appender.console': 'Trace',
-                            'services.sync.log.appender.debugLog.enabled': True,
-                            'toolkit.startup.max_resumed_crashes': -1,
-                          }
+    default_env = {
+        'MOZ_CRASHREPORTER_DISABLE': '1',
+        'GNOME_DISABLE_CRASH_DIALOG': '1',
+        'XRE_NO_WINDOWS_CRASH_DIALOG': '1',
+        'MOZ_NO_REMOTE': '1',
+        'XPCOM_DEBUG_BREAK': 'warn',
+    }
+
+    default_preferences = {
+        'app.update.enabled': False,
+        'browser.dom.window.dump.enabled': True,
+        'browser.sessionstore.resume_from_crash': False,
+        'browser.shell.checkDefaultBrowser': False,
+        'browser.tabs.warnOnClose': False,
+        'browser.warnOnQuit': False,
+        # Allow installing extensions dropped into the profile folder
+        'extensions.autoDisableScopes': 10,
+        'extensions.getAddons.get.url': 'http://127.0.0.1:4567/addons/api/%IDS%.xml',
+        'extensions.update.enabled': False,
+        # Don't open a dialog to show available add-on updates
+        'extensions.update.notifyUser': False,
+        'services.sync.addons.ignoreRepositoryChecking': True,
+        'services.sync.firstSync': 'notReady',
+        'services.sync.lastversion': '1.0',
+        'toolkit.startup.max_resumed_crashes': -1,
+    }
+
+    debug_preferences = {
+        'services.sync.log.appender.console': 'Trace',
+        'services.sync.log.appender.dump': 'Trace',
+        'services.sync.log.appender.file.level': 'Trace',
+        'services.sync.log.appender.file.logOnSuccess': True,
+        'services.sync.log.rootLogger': 'Trace',
+        'services.sync.log.logger.addonutils': 'Trace',
+        'services.sync.log.logger.declined': 'Trace',
+        'services.sync.log.logger.service.main': 'Trace',
+        'services.sync.log.logger.status': 'Trace',
+        'services.sync.log.logger.authenticator': 'Trace',
+        'services.sync.log.logger.network.resources': 'Trace',
+        'services.sync.log.logger.service.jpakeclient': 'Trace',
+        'services.sync.log.logger.engine.bookmarks': 'Trace',
+        'services.sync.log.logger.engine.clients': 'Trace',
+        'services.sync.log.logger.engine.forms': 'Trace',
+        'services.sync.log.logger.engine.history': 'Trace',
+        'services.sync.log.logger.engine.passwords': 'Trace',
+        'services.sync.log.logger.engine.prefs': 'Trace',
+        'services.sync.log.logger.engine.tabs': 'Trace',
+        'services.sync.log.logger.engine.addons': 'Trace',
+        'services.sync.log.logger.engine.apps': 'Trace',
+        'services.sync.log.logger.identity': 'Trace',
+        'services.sync.log.logger.userapi': 'Trace',
+    }
 
     syncVerRe = re.compile(
         r'Sync version: (?P<syncversion>.*)\n')
     ffVerRe = re.compile(
         r'Firefox version: (?P<ffver>.*)\n')
     ffDateRe = re.compile(
         r'Firefox builddate: (?P<ffdate>.*)\n')
 
     def __init__(self, extensionDir,
-                 testfile='sync.test',
-                 binary=None, config=None, rlock=None, mobile=False,
-                 logfile='tps.log', resultfile='tps_result.json',
-                 ignore_unused_engines=False):
+                 binary=None,
+                 config=None,
+                 debug=False,
+                 ignore_unused_engines=False,
+                 logfile='tps.log',
+                 mobile=False,
+                 rlock=None,
+                 resultfile='tps_result.json',
+                 testfile=None):
+        self.binary = binary
+        self.config = config if config else {}
+        self.debug = debug
         self.extensions = []
-        self.testfile = testfile
+        self.ignore_unused_engines = ignore_unused_engines
         self.logfile = os.path.abspath(logfile)
+        self.mobile = mobile
+        self.rlock = rlock
         self.resultfile = resultfile
-        self.binary = binary
-        self.ignore_unused_engines = ignore_unused_engines
-        self.config = config if config else {}
-        self.repo = None
+        self.testfile = testfile
+
+        self.addonversion = None
+        self.branch = None
         self.changeset = None
-        self.branch = None
+        self.errorlogs = {}
+        self.extensionDir = extensionDir
+        self.firefoxRunner = None
+        self.nightly = False
         self.numfailed = 0
         self.numpassed = 0
-        self.nightly = False
-        self.rlock = rlock
-        self.mobile = mobile
+        self.postdata = {}
+        self.productversion = None
+        self.repo = None
         self.tpsxpi = None
-        self.firefoxRunner = None
-        self.extensionDir = extensionDir
-        self.productversion = None
-        self.addonversion = None
-        self.postdata = {}
-        self.errorlogs = {}
 
     @property
     def mobile(self):
         return self._mobile
 
     @mobile.setter
     def mobile(self, value):
         self._mobile = value
@@ -296,34 +326,41 @@ class TPSTestRunner(object):
         self.log(logstr, True)
         for phase in phaselist:
             print "\t%s: %s" % (phase.phase, phase.status)
             if phase.status == 'FAIL':
                 break
 
         return resultdata
 
-    def run_tests(self):
-        # delete the logfile if it already exists
-        if os.access(self.logfile, os.F_OK):
-            os.remove(self.logfile)
+    def update_preferences(self):
+        self.preferences = self.default_preferences.copy()
 
-        # Make a copy of the default env variables and preferences, and update
-        # them for mobile settings if needed.
-        self.env = self.default_env.copy()
-        self.preferences = self.default_preferences.copy()
         if self.mobile:
             self.preferences.update({'services.sync.client.type' : 'mobile'})
 
         # Set a dummy username to force the correct authentication type. For the
         # old sync, the username is not allowed to contain a '@'.
         dummy = {'fx_account': 'dummy@somewhere', 'sync_account': 'dummy'}
         auth_type = self.config.get('auth_type', 'fx_account')
         self.preferences.update({'services.sync.username': dummy[auth_type]})
 
+        if self.debug:
+            self.preferences.update(self.debug_preferences)
+
+    def run_tests(self):
+        # delete the logfile if it already exists
+        if os.access(self.logfile, os.F_OK):
+            os.remove(self.logfile)
+
+        # Make a copy of the default env variables and preferences, and update
+        # them for custom settings
+        self.env = self.default_env.copy()
+        self.update_preferences()
+
         # Acquire a lock to make sure no other threads are running tests
         # at the same time.
         if self.rlock:
             self.rlock.acquire()
 
         try:
             # Create the Firefox runner, which will download and install the
             # build, as needed.