def test_create_from_results_collection(self): collection = DatazillaResultsCollection(machine_name='localhost', os='linux') test_date = collection.test_date req = DatazillaRequest.create('host', 'project', 'key', 'secret', collection) self.assertEqual(req.machine_name, 'localhost') self.assertEqual(req.os, 'linux') self.assertEqual(req.test_date, test_date) self.assertEqual(req.host, 'host') self.assertEqual(req.project, 'project') self.assertEqual(req.oauth_key, 'key') self.assertEqual(req.oauth_secret, 'secret')
def test_create_from_results_collection(self): collection = DatazillaResultsCollection(machine_name='localhost', os='linux', branch='mozilla-try') test_date = collection.test_date req = DatazillaRequest.create('http', 'host', 'project', 'key', 'secret', collection) self.assertEqual(req.machine_name, 'localhost') self.assertEqual(req.os, 'linux') self.assertEqual(req.test_date, test_date) self.assertEqual(req.host, 'host') self.assertEqual(req.project, 'project') self.assertEqual(req.oauth_key, 'key') self.assertEqual(req.oauth_secret, 'secret')
def post(self, results, server, path, scheme, tbpl_output): """post the data to datazilla""" # datazilla project project = path.strip('/') url = '%s://%s/%s' % (scheme, server, project) # oauth credentials oauth_key = None oauth_secret = None if self.oauth: project_oauth = self.oauth.get(project) if project_oauth: required = ['oauthKey', 'oauthSecret'] if set(required).issubset(project_oauth.keys()): oauth_key = project_oauth['oauthKey'] oauth_secret = project_oauth['oauthSecret'] else: utils.info("%s not found for project '%s' in '%s' (found: %s)", required, project, self.authfile, project_oauth.keys()) else: utils.info("No oauth credentials found for project '%s' in '%s'", project, self.authfile) utils.info("datazilla: %s//%s/%s; oauth=%s", scheme, server, project, bool(oauth_key and oauth_secret)) # submit the request req = DatazillaRequest.create(scheme, server, project, oauth_key, oauth_secret, results) responses = req.submit() # print error responses for response in responses: if response.status != 200: # use lower-case string because buildbot is sensitive to upper case error # as in 'INTERNAL SERVER ERROR' # https://bugzilla.mozilla.org/show_bug.cgi?id=799576 reason = response.reason.lower() print "Error posting to %s: %s %s" % (url, response.status, reason) else: res = response.read() print "Datazilla response is: %s" % res.lower() # TBPL output # URLs are in the form of # https://datazilla.mozilla.org/<path>/summary/<branch>/<revision>?product=Firefox&branch_version=16.0a1 # see https://bugzilla.mozilla.org/show_bug.cgi?id=816634#c8 if results.branch and results.revision: # compute url path = '/%s/summary/%s/%s' % (project, results.branch, results.revision) query = '&'.join(['%s=%s' % (j, urllib.quote(getattr(results, i))) for i, j in (('build_name', 'product'), ('version', 'branch_version')) if getattr(results, i)]) if query: query = '?' + query url = '%(scheme)s://%(server)s%(path)s%(query)s' % dict(scheme=scheme, server=server, path=path, query=query) # build TBPL output # XXX this will not work for multiple URLs :( tbpl_output.setdefault('datazilla', {}) for dataset in results.datasets(): tbpl_output['datazilla'][dataset['testrun']['suite']] = {'url': url} utils.info("Datazilla results at %s", url)
def post(self, results, server, path, scheme, tbpl_output): """post the data to datazilla""" # datazilla project project = path.strip('/') url = '%s://%s/%s' % (scheme, server, project) # oauth credentials oauth_key = None oauth_secret = None if self.oauth: project_oauth = self.oauth.get(project) if project_oauth: required = ['oauthKey', 'oauthSecret'] if set(required).issubset(project_oauth.keys()): oauth_key = project_oauth['oauthKey'] oauth_secret = project_oauth['oauthSecret'] else: utils.info("%s not found for project '%s' in '%s' (found: %s)", required, project, self.authfile, project_oauth.keys()) else: utils.info("No oauth credentials found for project '%s' in '%s'", project, self.authfile) utils.info("datazilla: %s//%s/%s; oauth=%s", scheme, server, project, bool(oauth_key and oauth_secret)) # submit the request req = DatazillaRequest.create(scheme, server, project, oauth_key, oauth_secret, results) responses = req.submit() # print error responses for response in responses: if response.status != 200: # use lower-case string because buildbot is sensitive to upper case error # as in 'INTERNAL SERVER ERROR' # https://bugzilla.mozilla.org/show_bug.cgi?id=799576 reason = response.reason.lower() print "Error posting to %s: %s %s" % (url, response.status, reason) else: res = response.read() print "Datazilla response is: %s" % res.lower() # TBPL output # URLs are in the form of # https://datazilla.mozilla.org/?start=1379423909&stop=1380028709&product=Firefox&repository=Mozilla-Inbound&os=linux&os_version=Ubuntu%2012.04&test=a11yr&x86=false&project=talos if results.branch and results.revision: # compute url now = str(datetime.datetime.now()) diff = str(datetime.datetime.now() - datetime.timedelta(days=7)) jsend = int(time.mktime(time.strptime(now.split('.')[0], "%Y-%m-%d %H:%M:%S"))) jsstart = int(time.mktime(time.strptime(diff.split('.')[0], "%Y-%m-%d %H:%M:%S"))) params = {} if results.platform == 'x86': params['x86_64'] = 'false' else: params['x86'] = 'false' revision = "" if results.revision and results.revision != 'NULL': params['graph_search'] = results.revision params['start'] = jsstart params['stop'] = jsend params['product'] = results.build_name params['repository'] = results.branch params['os'] = results.os.lower() # As per bug 957166, we need to Capitalize Android if params['os'] == 'android': params['os'] = 'Android' params['os_version'] = results.os_version params['project'] = project query = '?%s' % '&'.join(['%s=%s' % (key, urllib.quote(str(value))) for key, value in params.items()]) url = '%(scheme)s://%(server)s%(query)s' % dict(scheme=scheme, server=server, query=query) # build TBPL output # XXX this will not work for multiple URLs :( tbpl_output.setdefault('datazilla', {}) for dataset in results.datasets(): url = "%s&test=%s" % (url, dataset['testrun']['suite']) tbpl_output['datazilla'][dataset['testrun']['suite']] = {'url': url} utils.info("Datazilla results at %s", url)
def post(self, results, server, path, scheme, tbpl_output): """post the data to datazilla""" # datazilla project project = path.strip('/') url = '%s://%s/%s' % (scheme, server, project) # oauth credentials oauth_key = None oauth_secret = None if self.oauth: project_oauth = self.oauth.get(project) if project_oauth: required = ['oauthKey', 'oauthSecret'] if set(required).issubset(project_oauth.keys()): oauth_key = project_oauth['oauthKey'] oauth_secret = project_oauth['oauthSecret'] else: utils.info( "%s not found for project '%s' in '%s' (found: %s)", required, project, self.authfile, project_oauth.keys()) else: utils.info( "No oauth credentials found for project '%s' in '%s'", project, self.authfile) utils.info("datazilla: %s//%s/%s; oauth=%s", scheme, server, project, bool(oauth_key and oauth_secret)) # submit the request req = DatazillaRequest.create(scheme, server, project, oauth_key, oauth_secret, results) responses = req.submit() # print error responses for response in responses: if response.status != 200: # use lower-case string because buildbot is sensitive to upper case error # as in 'INTERNAL SERVER ERROR' # https://bugzilla.mozilla.org/show_bug.cgi?id=799576 reason = response.reason.lower() print "Error posting to %s: %s %s" % (url, response.status, reason) else: res = response.read() print "Datazilla response is: %s" % res.lower() # TBPL output # URLs are in the form of # https://datazilla.mozilla.org/<path>/summary/<branch>/<revision>?product=Firefox&branch_version=16.0a1 # see https://bugzilla.mozilla.org/show_bug.cgi?id=816634#c8 if results.branch and results.revision: # compute url path = '/%s/summary/%s/%s' % (project, results.branch, results.revision) query = '&'.join([ '%s=%s' % (j, urllib.quote(getattr(results, i))) for i, j in (('build_name', 'product'), ('version', 'branch_version')) if getattr(results, i) ]) if query: query = '?' + query url = '%(scheme)s://%(server)s%(path)s%(query)s' % dict( scheme=scheme, server=server, path=path, query=query) # build TBPL output # XXX this will not work for multiple URLs :( tbpl_output.setdefault('datazilla', {}) for dataset in results.datasets(): tbpl_output['datazilla'][dataset['testrun']['suite']] = { 'url': url } utils.info("Datazilla results at %s", url)