How to use get_test_keyval method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...35 lines.append(" ".join(line))36 cursor.close()37 conn.close()38 return lines39def get_test_keyval(jobid, keyname, default=''):40 idx = exec_sql("select job_idx from tko_jobs where afe_job_id=%s"41 % jobid)[-1]42 test_idx = exec_sql('select test_idx from tko_tests where job_idx=%s'43 % idx)[3]44 try:45 return exec_sql('select value from tko_test_attributes'46 ' where test_idx=%s and attribute="%s"'47 % (test_idx, keyname))[-1]48 except Exception:49 return default50class Sample(object):51 """ Collect test results in same environment to a sample """52 def __init__(self, type, arg):53 def generate_raw_table(test_dict):54 ret_dict = []55 tmp = []56 type = category = None57 for i in test_dict:58 line = i.split('|')[1:]59 if not type:60 type = line[0:2]61 if type != line[0:2]:62 ret_dict.append('|'.join(type + tmp))63 type = line[0:2]64 tmp = []65 if "e+" in line[-1]:66 tmp.append("%.0f" % float(line[-1]))67 elif 'e-' in line[-1]:68 tmp.append("%.2f" % float(line[-1]))69 elif not (re.findall("[a-zA-Z]", line[-1]) or is_int(line[-1])):70 tmp.append("%.2f" % float(line[-1]))71 else:72 tmp.append(line[-1])73 if category != i.split('|')[0]:74 category = i.split('|')[0]75 ret_dict.append("Category:" + category.strip())76 ret_dict.append(self.categories)77 ret_dict.append('|'.join(type + tmp))78 return ret_dict79 if type == 'file':80 files = arg.split()81 self.files_dict = []82 for i in range(len(files)):83 fd = open(files[i], "r")84 f = []85 for line in fd.readlines():86 line = line.strip()87 if re.findall("^### ", line):88 if "kvm-userspace-ver" in line:89 self.kvmver = line.split(':')[-1]90 elif "kvm_version" in line:91 self.hostkernel = line.split(':')[-1]92 elif "guest-kernel-ver" in line:93 self.guestkernel = line.split(':')[-1]94 elif "session-length" in line:95 self.len = line.split(':')[-1]96 else:97 f.append(line.strip())98 self.files_dict.append(f)99 fd.close()100 elif type == 'database':101 jobid = arg102 self.kvmver = get_test_keyval(jobid, "kvm-userspace-ver")103 self.hostkernel = get_test_keyval(jobid, "kvm_version")104 self.guestkernel = get_test_keyval(jobid, "guest-kernel-ver")105 self.len = get_test_keyval(jobid, "session-length")106 self.categories = get_test_keyval(jobid, "category")107 idx = exec_sql("select job_idx from tko_jobs where afe_job_id=%s"108 % jobid)[-1]109 data = exec_sql("select test_idx,iteration_key,iteration_value"110 " from tko_perf_view where job_idx=%s" % idx)111 testidx = None112 job_dict = []113 test_dict = []114 for line in data:115 s = line.split()116 if not testidx:117 testidx = s[0]118 if testidx != s[0]:119 job_dict.append(generate_raw_table(test_dict))120 test_dict = []...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?