def create_testsuite_list(): if compare_product_list: where_string = make_where_string_for_compare_product_list() global compare_product_where_string compare_product_where_string = where_string if where_string: cnx = database.open_query() select_string="".join(["SELECT distinct testsuite from performance_view ", " where ", where_string, ";"]) print(select_string) cursor = cnx.cursor() cursor.execute(select_string); i=0 table=list() for (testsuite) in cursor: table.append(testsuite) print(i, table[i]) i+=1 cnx.close() l = input("Please input the NO. testsuite(eg. 3):") global compare_testsuite_string if not l and i > 0: compare_testsuite_string = "".join(table[0]) else: compare_testsuite_string = "".join(table[int(l)]) return
def create_candidate_list(): """ The candidate list include kernel_version, product, release. this group could on behalf of one object that be used in performance testing as a abstract product. """ query = ("SELECT distinct `kernel_version`, `product`, `release` from performance_view") cnx = database.open_query() cursor = cnx.cursor() cursor.execute(query) i=0 table=list() for (kernel_version, product, release) in cursor: table.append([kernel_version, product, release]) print(i, table[i]) i+=1 cnx.close() l = input("Please input the NO. products(eg. 11,1):").split(",") for index in l: try: compare_product_list.append(table[int(index)]) except IndexError: sys.stderr.write("choose error, total amount: " + str(len(table)) + "\n" +"out of list\n") sys.exit(1) return
def create_arch_list(): if compare_testcase_string and compare_testsuite_string and compare_product_where_string and compare_host_string: query = "".join(["SELECT distinct arch from performance_view where" + compare_product_where_string + " and " + " `testsuite` = '" + compare_testsuite_string + "'" + " and " + " `testcase` = '" + compare_testcase_string + "'" + " and " + " `host` = '" + compare_host_string + "';"]) cnx = database.open_query() cursor = cnx.cursor() cursor.execute(query) i = 0 table=list() for (arch) in cursor: table.append(arch) print(i, table[i]) i+=1 cnx.close() l = input("Please input the NO. arch(eg, 0):") global compare_arch_string if not l and i > 0: compare_arch_string = "".join(table[0]) else: compare_arch_string = "".join(table[int(l)]) return
def build_global_testcase_list(): """ Query Database get TestCase objects set. This set include all candidate records to compare. """ make_final_select_query() cnx = database.open_query() cursor = cnx.cursor() print(final_select_string) cursor.execute(final_select_string) testcase_list = list() for (submission_id, arch, product, release, host, log_url, testsuite, test_time, failed, testcase, kernel_version) in cursor: testcase_list.append(TestCase(submission_id, arch, product, release, host, log_url, testsuite, test_time, testcase,kernel_version)) #groups = defaultdict(list) #for obj in testcase_list: # groups[obj.kernel_version+obj.product+obj.release].append(obj) #new_list = groups.values() #a = OrderedDict(new_list) #groups = OrderedDict() #for obj in testcase_list: # groups[obj.kernel_version+obj.product+obj.release].append(obj) #new_list = groups.values() """ TestCase_global_list_array looks like: """ groups = DefaultOrderedDict(list) for obj in testcase_list: groups[obj.kernel_version+obj.product+obj.release].append(obj) new_list = groups.values() global TestCase_global_list_array TestCase_global_list_array = new_list