def __call__(self): # platform machine = self.test_machine() # build information browser_config = self.results.browser_config # a place to put results res = DatazillaResult() for test in self.results.results: suite = "%s" % test.name() res.add_testsuite(suite, options=self.run_options(test)) # serialize test results results = {} if not test.using_xperf: for result in test.results: # XXX this will not work for manifests which list # the same page name twice. It also ignores cycles for page, val in result.raw_values(): if page == 'NULL': results.setdefault(test.name(), []).extend(val) else: results.setdefault(page, []).extend(val) for result, values in results.items(): res.add_test_results(suite, result, values) # counters results_aux data for cd in test.all_counter_results: for name, vals in cd.items(): res.add_talos_auxiliary(suite, name, vals) else: # specific xperf_aux data for cd in test.all_counter_results: for name, vals in cd.items(): res.add_xperf_results(suite, name, vals) # make a datazilla test result collection collection = DatazillaResultsCollection( machine_name=machine['name'], os=machine['os'], os_version=machine['osversion'], platform=machine['platform'], build_name=browser_config['browser_name'], version=browser_config['browser_version'], revision=browser_config['sourcestamp'], branch=browser_config['branch_name'], id=browser_config['buildid'], test_date=self.results.date) collection.add_datazilla_result(res) return collection
def __call__(self): # platform machine = self.test_machine() # build information browser_config = self.results.browser_config # a place to put results res = DatazillaResult() for test in self.results.results: suite = "%s" % test.name() res.add_testsuite(suite, options=self.run_options(test)) # serialize test results results = {} if not test.using_xperf: for result in test.results: # XXX this will not work for manifests which list # the same page name twice. It also ignores cycles for page, val in result.raw_values(): if page == 'NULL': results.setdefault(test.name(), []).extend(val) else: results.setdefault(page, []).extend(val) for result, values in results.items(): res.add_test_results(suite, result, values) # counters results_aux data for cd in test.all_counter_results: for name, vals in cd.items(): res.add_talos_auxiliary(suite, name, vals) else: # specific xperf_aux data for cd in test.all_counter_results: for name, vals in cd.items(): res.add_xperf_results(suite, name, vals) # make a datazilla test result collection collection = DatazillaResultsCollection(machine_name=machine['name'], os=machine['os'], os_version=machine['osversion'], platform=machine['platform'], build_name=browser_config['browser_name'], version=browser_config['browser_version'], revision=browser_config['sourcestamp'], branch=browser_config['branch_name'], id=browser_config['buildid'], test_date=self.results.date) collection.add_datazilla_result(res) return collection
def test_add_testsuite(self): """Can add a test suite with tests and results.""" res = DatazillaResult() res.add_testsuite("suite", {"test1": [1, 2, 3]}) self.assertEqual(res.results, {"suite": {"test1": [1, 2, 3]}})
def post_to_datazilla(self, test_result): """ take test_results (json) and upload them to datazilla """ # We will attach wpt_data to the datazilla result as a top # level attribute to store out of band data about the test. wpt_data = { "url": "", "firstView": {}, "repeatView": {} } wpt_data["label"] = test_result["data"]["label"] submit_results = False if self.job.datazilla == "on": # Do not short circuit the function but collect # additional data for use in emailing the user # before returning. submit_results = True self.logger.debug('Submit results to datazilla: %s' % self.job.datazilla) wpt_data["connectivity"] = test_result["data"]["connectivity"] wpt_data["location"] = test_result["data"]["location"] wpt_data["url"] = test_result["data"]["url"] runs = test_result["data"]["runs"] # runs[0] is a dummy entry # runs[1]["firstView"]["SpeedIndex"] # runs[1]["repeatView"]["SpeedIndex"] # runs[1]["firstView"]["requests"][0]["headers"]["request"][2] # "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:26.0) Gecko/20100101 Firefox/26.0 PTST/125" wpt_metric_keys = ['TTFB', 'render', 'docTime', 'fullyLoaded', 'SpeedIndex', 'SpeedIndexDT', 'bytesInDoc', 'requestsDoc', 'domContentLoadedEventStart', 'visualComplete'] for wpt_key in wpt_metric_keys: for view in "firstView", "repeatView": wpt_data[view][wpt_key] = [] if len(runs) == 1: raise Exception("post_to_datazilla: no runs") os_version = "unknown" os_name = "unknown" platform = "x86" reUserAgent = re.compile('User-Agent: Mozilla/5.0 \(Windows NT ([^;]*);.*') for run in runs: for wpt_key in wpt_metric_keys: for view in "firstView", "repeatView": if not run[view]: continue if wpt_key in run[view]: if run[view][wpt_key]: wpt_data[view][wpt_key].append(run[view][wpt_key]) if os_name == "unknown": try: requests = run[view]["requests"] if requests and len(requests) > 0: request = requests[0] if request: headers = request["headers"] if headers: request_headers = headers["request"] if request_headers: for request_header in request_headers: if "User-Agent" in request_header: match = re.match(reUserAgent, request_header) if match: os_name = "WINNT" os_version = match.group(1) break except KeyError: pass machine_name = wpt_data["location"].split(":")[0] # limit suite name to 128 characters to match mysql column size suite_name = (wpt_data["location"] + "." + wpt_data["connectivity"])[:128] # limit {first,repeat}_name, to 255 characters to match mysql column size # leave protocol in the url in order to distinguish http vs https. first_name = wpt_data["url"][:252] + ":fv" repeat_name = wpt_data["url"][:252] + ":rv" result = DatazillaResult() result.add_testsuite(suite_name) result.add_test_results(suite_name, first_name, wpt_data["firstView"]["SpeedIndex"]) result.add_test_results(suite_name, repeat_name, wpt_data["repeatView"]["SpeedIndex"]) request = DatazillaRequest("https", "datazilla.mozilla.org", "webpagetest", self.oauth_key, self.oauth_secret, machine_name=machine_name, os=os_name, os_version=os_version, platform=platform, build_name=self.build_name, version=self.build_version, revision=self.build_revision, branch=self.build_branch, id=self.build_id) request.add_datazilla_result(result) datasets = request.datasets() for dataset in datasets: dataset["wpt_data"] = wpt_data if not submit_results: continue response = request.send(dataset) # print error 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() self.logger.debug("Error posting to %s %s %s: %s %s" % ( wpt_data["url"], wpt_data["location"], wpt_data["connectivity"], response.status, reason)) else: res = response.read() self.logger.debug("Datazilla response for %s %s %s is: %s" % ( wpt_data["url"], wpt_data["location"], wpt_data["connectivity"], res.lower())) return datasets
def post_to_datazilla(self): """ take test_results (json) and upload them to datazilla """ # We will attach wpt_data to the datazilla result as a top # level attribute to store out of band data about the test. submit_results = False if self.job.datazilla == "on": # Do not short circuit the function but collect # additional data for use in emailing the user # before returning. submit_results = True with open('/home/mozauto/power_logger/report.csv', 'r') as fHandle: data = fHandle.readlines() header = True browsers = [] for line in data: if header: header = False continue parts = line.split(',') if parts[1] not in browsers: browsers.append(parts[1]) for browser in browsers: result = DatazillaResult() suite_name = "PowerGadget" machine_name = "perf-windows-003" os_name = "Win" browsername = browser if browsername == "Internet Explorer": browsrename = "IE" os_version = "7 - %s" % browsername platform = "x86" result.add_testsuite(suite_name) #TODO: JMAHER: hardcoded microperf here, this project should be in a config file and a real name request = DatazillaRequest("https", "datazilla.mozilla.org", "power", self.oauth_key, self.oauth_secret, machine_name=machine_name, os=os_name, os_version=os_version, platform=platform, build_name=self.build_name, version=self.build_version, revision=self.build_revision, branch=self.build_branch, id=self.build_id) header = True for line in data: if header: header = False continue parts = line.split(',') #Skip data from other browsers if parts[1] != browser: continue result.add_test_results(suite_name, parts[13], [str(parts[14])]) print "JMAHER: added data: %s: %s = %s, %s" % (os_version, suite_name, parts[13], [str(parts[14])]) request.add_datazilla_result(result) responses = request.submit() for resp in responses: print 'server response: %d %s %s' % (resp.status, resp.reason, resp.read())
def post_to_datazilla(appinfo, configinfo): """ take test_results (json) and upload them to datazilla """ with open(os.path.join(configinfo['energia_dir'], 'report.csv'), 'r') as fHandle: data = fHandle.readlines() header = True browsers = [] for line in data: if header: header = False continue parts = line.split(',') if len(parts) != 18: continue if parts[15] not in browsers: browsers.append(parts[15]) tests = {'GT Watts': 4, 'IA Watts': 8, 'Processor Watts': 13} for browser in browsers: for test in tests: result = DatazillaResult() suite_name = "PowerGadget" machine_name = "tor-win8" os_name = "Win" browsername = browser if browsername == "Internet Explorer": browsername = "IE" os_version = "8-%s (%s)" % (browsername, test) platform = "x64" result.add_testsuite(suite_name) request = DatazillaRequest("https", "datazilla.mozilla.org", "power", configinfo['oauth_key'], configinfo['oauth_secret'], machine_name=machine_name, os=os_name, os_version=os_version, platform=platform, build_name=appinfo['build_name'], version=appinfo['build_version'], revision=appinfo['build_revision'], branch=appinfo['build_branch'], id=appinfo['build_id']) header = True for line in data: if header: header = False continue if len(parts) != 18: conitinue parts = line.split(',') #Skip data from other browsers if parts[15] != browser: continue result.add_test_results(suite_name, parts[16], [str(parts[tests[test]])]) request.add_datazilla_result(result) responses = request.submit() for resp in responses: print('server response: %d %s %s' % (resp.status, resp.reason, resp.read()))