def get_db_size(project): """Return the size of the database on disk in megabytes""" ptrdm = factory.get_ptrdm(project) pt_size = ptrdm.get_db_size() ptrdm.disconnect() return pt_size
def get_testdata(project, branch, revision, product_name=None, os_name=None, os_version=None, branch_version=None, processor=None, build_type=None, test_name=None, page_name=None): """Return test data based on the parameters and optional filters.""" ptm = factory.get_ptm(project) ptrdm = factory.get_ptrdm(project) # get the testrun ids from perftest test_run_ids = ptm.get_test_run_ids(branch, [revision], product_name, os_name, os_version, branch_version, processor, build_type, test_name) blobs = ptrdm.get_object_json_blob_for_test_run(test_run_ids) filtered_blobs = [] #Build a page lookup to filter by page_names = set() if page_name: map(lambda page: page_names.add(page.strip()), page_name.split(',')) for blob in blobs: if blob["error_flag"] == "Y": filtered_blobs.append({ "bad_test_data": { "test_run_id": trid, "error_msg": blob["error_msg"] } }) else: filtered_blob = json.loads(blob["json_blob"]) #Only load pages in page_names if page_names: new_results = {} for p in page_names: if p in filtered_blob['results']: new_results[p] = filtered_blob['results'][p] filtered_blob['results'] = new_results filtered_blobs.append(filtered_blob) ptm.disconnect() ptrdm.disconnect() return filtered_blobs
def get_run_counts_by_branch(project, startdate, enddate): """Return a count of test runs by branch in date range""" ptrdm = factory.get_ptrdm(project) test_runs = ptrdm.get_run_counts_by_branch(startdate, enddate) ptrdm.disconnect() #now form the data the way we want it result = {} for tr in test_runs: branch = result.setdefault(tr["branch"], {}) branch["count"] = tr.get("count") return result
def get_runs_by_branch(project, startdate, enddate): """Return a list of test runs by branch in date range""" ptrdm = factory.get_ptrdm(project) plm = factory.get_plm() branches = [x["name"] for x in plm.get_all_branches()] result = {} for branch in branches: test_runs = ptrdm.get_run_lists_by_branch(startdate, enddate, branch) if test_runs["count"] > 0: result[branch] = test_runs plm.disconnect() ptrdm.disconnect() return result
def get_testdata( project, branch, revision, product_name=None, os_name=None, os_version=None, branch_version=None, processor=None, build_type=None, test_name=None, page_name=None): """Return test data based on the parameters and optional filters.""" ptm = factory.get_ptm(project) ptrdm = factory.get_ptrdm(project) # get the testrun ids from perftest test_run_ids = ptm.get_test_run_ids( branch, [revision], product_name, os_name, os_version, branch_version, processor, build_type, test_name ) blobs = ptrdm.get_object_json_blob_for_test_run(test_run_ids) filtered_blobs = [] #Build a page lookup to filter by page_names = set() if page_name: map( lambda page:page_names.add(page.strip()), page_name.split(',') ) for blob in blobs: if blob["error_flag"] == "Y": filtered_blobs.append({"bad_test_data": { "test_run_id": trid, "error_msg": blob["error_msg"] }}) else: filtered_blob = json.loads(blob["json_blob"]) #Only load pages in page_names if page_names: new_results = {} for p in page_names: if p in filtered_blob['results']: new_results[p] = filtered_blob['results'][p] filtered_blob['results'] = new_results filtered_blobs.append( filtered_blob ) ptm.disconnect() ptrdm.disconnect() return filtered_blobs
def get_not_referenced(project, startdate, enddate, branches=None): """ Return a list of test runs by in pushlogs not in Datazilla ``project`` The PerformanceTestModel project. Note: NOT the PushLogModel project. """ branches = branches or get_all_branches() ptrdm = factory.get_ptrdm(project) tr_set = ptrdm.get_distinct_test_run_revisions() ptrdm.disconnect() plrdm = factory.get_plrdm() pl_dict = plrdm.get_pushlog_dict(startdate, enddate, branches) plrdm.disconnect() # gather matching and non-matching sets branch_wo_match = {} branch_w_match = {} for pl, data in pl_dict.iteritems(): rev_list = data["revisions"] if not len(tr_set.intersection(set(rev_list))): bucket = branch_wo_match else: bucket = branch_w_match br_list = bucket.setdefault(data["branch_name"], {}) pushlog_list = br_list.setdefault("pushlogs", []) pushlog_list.append({ "push_id": pl, "revisions": rev_list, }) return { "with_matching_test_run": branch_w_match, "without_matching_test_run": branch_wo_match, }