- Revision
- 92772
- Author
- [email protected]
- Date
- 2011-08-10 08:49:40 -0700 (Wed, 10 Aug 2011)
Log Message
Leaks bot shows python logging prefixes as part of summary display
https://bugs.webkit.org/show_bug.cgi?id=65931
Reviewed by Adam Barth.
The big part of this change is adding a unittesting system for
master.cfg, so mere-mortals can make changes to build.webkit.org
with greatly-reduced risk of breaking the world.
Turns out that in typing up my trival logging fix I made 2 typos,
so hopefully the hour spent getting master.cfg to load was worth it. :)
I also tried to make mastercfg_unittest run as part of test-webkitpy
but right now test-webkitpy requires that unittest files be located in
a module-name-compatible directory. 'build.webkit.org-config' is not
a valid module name.
* BuildSlaveSupport/build.webkit.org-config/master.cfg:
- Fixed _parseNewRunWebKitTestsOutput to strip NRWT's python formatter prefix
by using a new _strip_python_logging_prefix function.
- Also fixed this function to file to work with a more modern
simplejson version (which returns unicode objects instead of str objects)
and filed a related bug with buildbot.net due to their handling of unicode builder names.
* BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py: Added.
- BuildBotConfigLoader is a huge pile of code just to get master.cfg to load.
- The actual tiny unittest of the new _parseNewRunWebKitTestsOutput logic.
* Scripts/webkitpy/thirdparty/__init__.py:
- Add autoinstallation of buildbot (and jinja2) for use by mastercfg_unittest.py
Modified Paths
Added Paths
Diff
Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/master.cfg (92771 => 92772)
--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/master.cfg 2011-08-10 15:43:49 UTC (rev 92771)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/master.cfg 2011-08-10 15:49:40 UTC (rev 92772)
@@ -261,6 +261,15 @@
self.incorrectLayoutLines = incorrectLayoutLines
+ # FIXME: This will break if new-run-webkit-tests changes its default log formatter.
+ nrwt_log_message_regexp = re.compile(r'(?P<log_prefix>.*) (?P<log_level>DEBUG|INFO) (?P<message>.*)')
+
+ def _strip_python_logging_prefix(self, line):
+ match_object = self.nrwt_log_message_regexp.match(line)
+ if match_object:
+ return match_object.group('message')
+ return line
+
def _parseNewRunWebKitTestsOutput(self, logText):
incorrectLayoutLines = []
expressions = [
@@ -273,7 +282,7 @@
for line in logText.splitlines():
if line.find('Exiting early') >= 0 or line.find('leaks found') >= 0:
- incorrectLayoutLines.append(line)
+ incorrectLayoutLines.append(self._strip_python_logging_prefix(line))
continue
for name, _expression_ in expressions:
match = _expression_.search(line)
@@ -716,6 +725,14 @@
if "change_filter" in scheduler:
scheduler["change_filter"] = globals()[scheduler["change_filter"]]
kls = globals()[scheduler.pop('type')]
+ # Python 2.6 can't handle unicode keys as keyword arguments:
+ # http://bugs.python.org/issue2646. Modern versions of simplejson return
+ # unicode strings from simplejson.load, so we map all keys to str objects.
+ scheduler = dict(map(lambda key_value_pair: (str(key_value_pair[0]), key_value_pair[1]), scheduler.items()))
+
+ # BaseScheduler asserts if given unicode objects instead of strs.
+ # http://trac.buildbot.net/ticket/2075
+ scheduler['builderNames'] = map(str, scheduler['builderNames'])
c['schedulers'].append(kls(**scheduler))
c['builders'] = []
Added: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py (0 => 92772)
--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py (rev 0)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py 2011-08-10 15:49:40 UTC (rev 92772)
@@ -0,0 +1,74 @@
+#! /usr/bin/python
+
+import sys
+import os
+import StringIO
+import unittest
+
+
+class BuildBotConfigLoader(object):
+ def _add_webkitpy_to_sys_path(self):
+ # When files are passed to the python interpreter on the command line (e.g. python test.py) __file__ is a relative path.
+ absolute_file_path = os.path.abspath(__file__)
+ webkit_org_config_dir = os.path.dirname(absolute_file_path)
+ build_slave_support_dir = os.path.dirname(webkit_org_config_dir)
+ webkit_tools_dir = os.path.dirname(build_slave_support_dir)
+ scripts_dir = os.path.join(webkit_tools_dir, 'Scripts')
+ sys.path.append(scripts_dir)
+
+ def _create_mock_passwords_dict(self):
+ config_dict = simplejson.load(open('config.json'))
+ return dict([(slave['name'], '1234') for slave in config_dict['slaves']])
+
+ def _mock_open(self, filename):
+ if filename == 'passwords.json':
+ # FIXME: This depends on _add_dependant_modules_to_sys_modules imported simplejson.
+ return StringIO.StringIO(simplejson.dumps(self._create_mock_passwords_dict()))
+ return __builtins__.open(filename)
+
+ def _add_dependant_modules_to_sys_modules(self):
+ from webkitpy.thirdparty.autoinstalled import buildbot
+ from webkitpy.thirdparty import simplejson
+
+ sys.modules['buildbot'] = buildbot
+ sys.modules['simplejson'] = simplejson
+
+ def load_config(self, master_cfg_path):
+ # Before we can use webkitpy.thirdparty, we need to fix our path to include webkitpy.
+ # FIXME: If we're ever run by test-webkitpy we won't need this step.
+ self._add_webkitpy_to_sys_path()
+ # master.cfg expects the buildbot and simplejson modules to be in sys.path.
+ self._add_dependant_modules_to_sys_modules()
+
+ # master.cfg expects a passwords.json file which is not checked in. Fake it by mocking open().
+ globals()['open'] = self._mock_open
+ # Because the master_cfg_path may have '.' in its name, we can't just use import, we have to use execfile.
+ # We pass globals() as both the globals and locals to mimic exectuting in the global scope, so
+ # that globals defined in master.cfg will be global to this file too.
+ execfile(master_cfg_path, globals(), globals())
+ globals()['open'] = __builtins__.open # Stop mocking open().
+
+
+class MasterCfgTest(unittest.TestCase):
+ def test_nrwt_leaks_parsing(self):
+ run_webkit_tests = RunWebKitTests()
+ log_text = """
+2011-08-09 10:05:18,580 29486 mac.py:275 INFO leaks found for a total of 197,936 bytes!
+2011-08-09 10:05:18,580 29486 mac.py:276 INFO 1 unique leaks found!
+"""
+ expected_incorrect_lines = [
+ 'leaks found for a total of 197,936 bytes!',
+ '1 unique leaks found!',
+ ]
+ run_webkit_tests._parseNewRunWebKitTestsOutput(log_text)
+ self.assertEquals(run_webkit_tests.incorrectLayoutLines, expected_incorrect_lines)
+
+
+# FIXME: We should run this file as part of test-webkitpy.
+# Unfortunately test-webkitpy currently requires that unittests
+# be located in a directory with a valid module name.
+# 'build.webkit.org-config' is not a valid module name (due to '.' and '-')
+# so for now this is a stand-alone test harness.
+if __name__ == '__main__':
+ BuildBotConfigLoader().load_config('master.cfg')
+ unittest.main()
Property changes on: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py
___________________________________________________________________
Added: svn:executable
Modified: trunk/Tools/ChangeLog (92771 => 92772)
--- trunk/Tools/ChangeLog 2011-08-10 15:43:49 UTC (rev 92771)
+++ trunk/Tools/ChangeLog 2011-08-10 15:49:40 UTC (rev 92772)
@@ -1,3 +1,34 @@
+2011-08-10 Eric Seidel <[email protected]>
+
+ Leaks bot shows python logging prefixes as part of summary display
+ https://bugs.webkit.org/show_bug.cgi?id=65931
+
+ Reviewed by Adam Barth.
+
+ The big part of this change is adding a unittesting system for
+ master.cfg, so mere-mortals can make changes to build.webkit.org
+ with greatly-reduced risk of breaking the world.
+
+ Turns out that in typing up my trival logging fix I made 2 typos,
+ so hopefully the hour spent getting master.cfg to load was worth it. :)
+
+ I also tried to make mastercfg_unittest run as part of test-webkitpy
+ but right now test-webkitpy requires that unittest files be located in
+ a module-name-compatible directory. 'build.webkit.org-config' is not
+ a valid module name.
+
+ * BuildSlaveSupport/build.webkit.org-config/master.cfg:
+ - Fixed _parseNewRunWebKitTestsOutput to strip NRWT's python formatter prefix
+ by using a new _strip_python_logging_prefix function.
+ - Also fixed this function to file to work with a more modern
+ simplejson version (which returns unicode objects instead of str objects)
+ and filed a related bug with buildbot.net due to their handling of unicode builder names.
+ * BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py: Added.
+ - BuildBotConfigLoader is a huge pile of code just to get master.cfg to load.
+ - The actual tiny unittest of the new _parseNewRunWebKitTestsOutput logic.
+ * Scripts/webkitpy/thirdparty/__init__.py:
+ - Add autoinstallation of buildbot (and jinja2) for use by mastercfg_unittest.py
+
2011-08-09 Dimitri Glazkov <[email protected]>
garden-o-matic should extrapolate failures given a set of known results
Modified: trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py (92771 => 92772)
--- trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py 2011-08-10 15:43:49 UTC (rev 92771)
+++ trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py 2011-08-10 15:49:40 UTC (rev 92772)
@@ -81,6 +81,8 @@
self._install_irc()
elif '.pywebsocket' in fullname:
self._install_pywebsocket()
+ elif '.buildbot' in fullname:
+ self._install_buildbot()
def _install_mechanize(self):
# The mechanize package uses ClientForm, for example, in _html.py.
@@ -92,8 +94,7 @@
# its own directory so that we can include it in the search path
# without including other modules as a side effect.
clientform_dir = self._fs.join(_AUTOINSTALLED_DIR, "clientform")
- installer = AutoInstaller(append_to_search_path=True,
- target_dir=clientform_dir)
+ installer = AutoInstaller(append_to_search_path=True, target_dir=clientform_dir)
installer.install(url=""
url_subpath="ClientForm.py")
@@ -104,6 +105,21 @@
self._install("http://pypi.python.org/packages/source/p/pep8/pep8-0.5.0.tar.gz#md5=512a818af9979290cd619cce8e9c2e2b",
"pep8-0.5.0/pep8.py")
+ # autoinstalled.buildbot is used by BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py
+ # and should ideally match the version of BuildBot used at build.webkit.org.
+ def _install_buildbot(self):
+ # The buildbot package uses jinja2, for example, in buildbot/status/web/base.py.
+ # buildbot imports jinja2 directly (as though it were installed on the system),
+ # so the search path needs to include jinja2. We put jinja2 in
+ # its own directory so that we can include it in the search path
+ # without including other modules as a side effect.
+ jinja_dir = self._fs.join(_AUTOINSTALLED_DIR, "jinja2")
+ installer = AutoInstaller(append_to_search_path=True, target_dir=jinja_dir)
+ installer.install(url=""
+ url_subpath="Jinja2-2.6/jinja2")
+
+ self._install("http://pypi.python.org/packages/source/b/buildbot/buildbot-0.8.4p2.tar.gz#md5=7597d945724c80c0ab476e833a1026cb", "buildbot-0.8.4p2/buildbot")
+
def _install_eliza(self):
installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)
installer.install(url=""