Commit 570769ae authored by wsiegrist@apple.com's avatar wsiegrist@apple.com

2010-12-08 William Siegrist <wsiegrist@apple.com>

        Reviewed by Eric Seidel.

        Migrate buildbot.py from xmlrpc to json.
        https://bugs.webkit.org/show_bug.cgi?id=50647

        * Scripts/webkitpy/common/net/buildbot.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73590 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f8bc3579
2010-12-08 William Siegrist <wsiegrist@apple.com>
Reviewed by Eric Seidel.
Migrate buildbot.py from xmlrpc to json.
https://bugs.webkit.org/show_bug.cgi?id=50647
* Scripts/webkitpy/common/net/buildbot.py:
2010-12-08 Tony Chang <tony@chromium.org>
Reviewed by Eric Seidel.
......
......@@ -28,11 +28,16 @@
#
# WebKit's Python module for interacting with WebKit's buildbot
try:
import json
except ImportError:
# python 2.5 compatibility
import webkitpy.thirdparty.simplejson as json
import operator
import re
import urllib
import urllib2
import xmlrpclib
from webkitpy.common.net.failuremap import FailureMap
from webkitpy.common.net.layouttestresults import LayoutTestResults
......@@ -67,13 +72,13 @@ class Builder(object):
# This provides a single place to mock
def _fetch_build(self, build_number):
build_dictionary = self._buildbot._fetch_xmlrpc_build_dictionary(self, build_number)
build_dictionary = self._buildbot._fetch_build_dictionary(self, build_number)
if not build_dictionary:
return None
return Build(self,
build_number=int(build_dictionary['number']),
revision=int(build_dictionary['revision']),
is_green=(build_dictionary['results'] == 0) # Undocumented, buildbot XMLRPC, 0 seems to mean "pass"
revision=int(build_dictionary['sourceStamp']['revision']),
is_green=(build_dictionary['results'] == 0) # Undocumented, 0 seems to mean "pass"
)
def build(self, build_number):
......@@ -140,7 +145,7 @@ class Builder(object):
return None
build = self.build(build_number)
if not build and allow_failed_lookups:
# Builds for old revisions with fail to lookup via buildbot's xmlrpc api.
# Builds for old revisions with fail to lookup via buildbot's json api.
build = Build(self,
build_number=build_number,
revision=revision,
......@@ -345,16 +350,22 @@ class BuildBot(object):
return not self.red_core_builders()
# FIXME: These _fetch methods should move to a networking class.
def _fetch_xmlrpc_build_dictionary(self, builder, build_number):
# The buildbot XMLRPC API is super-limited.
# For one, you cannot fetch info on builds which are incomplete.
proxy = xmlrpclib.ServerProxy("http://%s/xmlrpc" % self.buildbot_host, allow_none=True)
def _fetch_build_dictionary(self, builder, build_number):
try:
return proxy.getBuild(builder.name(), int(build_number))
except xmlrpclib.Fault, err:
base = "http://%s" % self.buildbot_host
path = urllib.quote("json/builders/%s/builds/%s" % (builder.name(),
build_number))
url = "%s/%s" % (base, path)
jsondata = urllib2.urlopen(url)
return json.load(jsondata)
except urllib2.URLError, err:
build_url = Build.build_url(builder, build_number)
_log.error("Error fetching data for %s build %s (%s): %s" % (builder.name(), build_number, build_url, err))
return None
except ValueError, err:
build_url = Build.build_url(builder, build_number)
_log.error("Error decoding json data from %s: %s" % (build_url, err))
return None
def _fetch_one_box_per_builder(self):
build_status_url = "http://%s/one_box_per_builder" % self.buildbot_host
......
......@@ -297,15 +297,17 @@ class BuildBotTest(unittest.TestCase):
self.assertEqual(builder.url_encoded_name(), "Test%20Builder")
self.assertEqual(builder.results_url(), "http://build.webkit.org/results/Test%20Builder")
# Override _fetch_xmlrpc_build_dictionary function to not touch the network.
def mock_fetch_xmlrpc_build_dictionary(self, build_number):
# Override _fetch_build_dictionary function to not touch the network.
def mock_fetch_build_dictionary(self, build_number):
build_dictionary = {
"revision" : 2 * build_number,
"sourceStamp": {
"revision" : 2 * build_number,
},
"number" : int(build_number),
"results" : build_number % 2, # 0 means pass
}
return build_dictionary
buildbot._fetch_xmlrpc_build_dictionary = mock_fetch_xmlrpc_build_dictionary
buildbot._fetch_build_dictionary = mock_fetch_build_dictionary
build = builder.build(10)
self.assertEqual(build.builder(), builder)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment