def read_file_by_iozone(block_size=None, file_size=None, threads=None, sequential=None): """ Read file by iozone, will use params from test_conf generally """ tc_logger.info('==>Start to read file by iozone') device_id = test_conf["device_id"] exe_file = test_conf['tool']['iozone'] exe_dir = os.path.dirname(exe_file) if block_size is None: block_size = test_conf.get('block_size', '4k').lower() if file_size is None: file_size = test_conf.get('file_size', '128m').lower() if threads is None: threads = test_conf.get('threads', '8') if sequential is None: sequential = test_conf.get('sequential', True) sequential = '1' if unify_bool_value(sequential) else '2' command = 'shell "cd {0};{1} -w -r {2} -s {3} -i {4} -I -t {5}"'.format( exe_dir, exe_file, block_size, file_size, sequential, str(threads)) adb = ADB(device_id) adb.execute_adb_command(command) tc_logger.info('==>Read file by iozone over')
def read_file_by_fio(block_size=None, file_size=None, rw=None, rwmixread=None, sub_jobs=None, runtime=None): """ Write file by fio, use params from test_conf generally """ tc_logger.info('==>Write file by fio over') device_id = test_conf["device_id"] exe_file = test_conf['tool']['fio'] iodepth = test_conf.get("iodepth", "32") if block_size is None: block_size = test_conf.get("block_size", "4k") if file_size is None: file_size = test_conf.get("file_size", "10G") if rw is None: rw = test_conf.get("rw", "read") if rwmixread is None: rwmixread = test_conf.get("rwmixread", "50") if runtime is None: runtime = test_conf.get("runtime", "600") if sub_jobs is None: sub_jobs = test_conf.get('sub_jobs', None) rewrite = unify_bool_value(test_conf.get('rewrite', True)) filename = os.path.join(test_conf['tool']['dir'], 'fio_test_file') # testcase business workflow adb = ADB(device_id) if rw in ["randrw", "rw", "readwrite"]: rw = rw + " --rwmixread=" + rwmixread _sub_jobs = '--name=perf_std --filename={}'.format(filename) if sub_jobs: _sub_jobs_list = list() for i in range(1, int(sub_jobs) + 1): sub_name = 'job' + str(i) sub_filename = 'fio_test_' + str(file_size) + '_' + str(i) if not rewrite: rand_str = random.choice(range(10000)) sub_filename = 'fio_test_' + str(file_size) + '_' + str( i) + '_' + str(rand_str) sub_file_path = os.path.join(test_conf['tool']['dir'], sub_filename) _sub_job = '--name={0} --filename={1}'.format( sub_name, sub_file_path) _sub_jobs_list.append(_sub_job) _sub_jobs = ' '.join(_sub_jobs_list) fio_command = "shell {0} --direct=1 --norandommap=0 --numjobs=1 --ioengine=libaio --iodepth={1} --rw={2} --bs={3} --size={4} --runtime={5} --output-format=json,normal {6}" \ .format(exe_file, iodepth, rw, block_size, file_size, runtime, _sub_jobs) adb.execute_adb_command(fio_command) tc_logger.info('==>Write file by fio over')
def create_file_by_iozone(block_size=None, file_size=None, threads=None): """ Create file by iozone, use params from test_conf generally, this method will write file 2 times """ tc_logger.info('==>Start to create file by iozone') device_id = test_conf["device_id"] exe_file = test_conf['tool']['iozone'] exe_dir = os.path.dirname(exe_file) if block_size is None: block_size = test_conf.get('block_size', '4k').lower() if file_size is None: file_size = test_conf.get('file_size', '128m').lower() if threads is None: threads = test_conf.get('threads', '8') command = 'shell "cd {0};{1} -w -r {2} -s {3} -i 0 -I -t {4}"'.format( exe_dir, exe_file, block_size, file_size, str(threads)) adb = ADB(device_id) adb.execute_adb_command(command) tc_logger.info('==>Create file by iozone over')
def tc2_wb_function_sample(): # test data and benchmark definition according to host environment result = 0 if test_conf["chip_capacity"] == "256G": test_data = {"fio_file_size": "25G"} test_benchmark = { "fio_sw_time": { "min": 20, "max": 60, "comments": ["Initial Version"] }, "abs_min": { "min": 0, "max": 0, "comments": ["available buffer size should be used up"] }, "abs_max": { "min": 100, "max": 100, "comments": [ "available buffer size should be able to recover to A within limited time" ] }, "abs_recover_time": { "min": 0, "max": 600, "comments": ["Initial Version"] }, "flush_status_after_recover_1": { "min": 3, "max": 3, "comments": ["flush status should be set to 3 after abs recovered"] }, "flush_status_after_recover_2": { "min": 0, "max": 0, "comments": [ "flush status should be set to 0 after abs recovered and status read" ] } } elif test_conf["chip_capacity"] == "128G": test_data = {"fio_file_size": "13G"} test_benchmark = { "fio_sw_time": { "min": 10, "max": 30, "comments": ["Initial Version"] }, "abs_min": { "min": 0, "max": 0, "comments": ["available buffer size should be used up"] }, "abs_max": { "min": 100, "max": 100, "comments": [ "available buffer size should be able to recover to A within limited time" ] }, "abs_recover_time": { "min": 0, "max": 600, "comments": ["Initial Version"] }, "flush_status_after_recover_1": { "min": 3, "max": 3, "comments": ["flush status should be set to 3 after abs recovered"] }, "flush_status_after_recover_2": { "min": 0, "max": 0, "comments": [ "flush status should be set to 0 after abs recovered and status read" ] } } else: raise Exception("Unsupported chip capacity: " + test_conf["chip_capacity"]) # pre_case, post_case, pre_loop and post_loop definition tc_logger.info( "Defining pre_case, post_case, pre_loop and post_loop inside of test case" ) test_conf["ud_pre_case"] = ud_pre_case_string test_conf["ud_post_case"] = ud_post_case_string # pre case configuration set_up(level='case') # adb initialization adb = ADB(test_conf["device_id"]) device = Device(test_conf["device_id"]) # launch abs monitoring in backend def wb_func_abs_monitor(abs_use_up_timeout=60, abs_recover_timeout=60, monitor_interval=1, log_file=None): if log_file is None: log_file = os.path.join(test_conf["monitor_home"], "wb_func_abs_monitor.log") # device = Device(test_conf["device_id"]) with open(log_file, "w") as f: f.write("monitor_start=" + str(time.time()) + os.linesep) # monitor whether abs can be used up time_start = time.time() while True: # monitor whether ads is used up time_now = time.time() if (time_now - time_start) > abs_use_up_timeout: f.write("abs_use_up_ts=timeout" + os.linesep) break else: abs_now = device.get_wb_avail_buf()[1][0] f.write(abs_now + os.linesep) if abs_now == "0%": f.write("abs_use_up_ts=" + str(time.time()) + os.linesep) break f.flush() time.sleep(monitor_interval) # monitor whether abs can recover to 100% time_start = time.time() while True: # monitor whether ads is used up time_now = time.time() if (time_now - time_start) > abs_recover_timeout: f.write("abs_recover_ts=timeout" + os.linesep) break else: abs_now = device.get_wb_avail_buf()[1][0] f.write(abs_now + os.linesep) if abs_now == "100%": f.write("abs_recover_ts=" + str(time.time()) + os.linesep) break f.flush() time.sleep(monitor_interval) p = Process(target=wb_func_abs_monitor, args=[ test_benchmark["fio_sw_time"]["max"], test_benchmark["abs_recover_time"]["max"], ]) p.daemon = True p.start() # run fio command on cell phone background cmd = "shell '/data/auto_tools/fio --direct=1 --norandommap=0 --numjobs=1 --ioengine=libaio " \ + "--iodepth=32 --rw=write --size={} --bs=512k --runtime=600" \ + " --name=job1 --filename=/data/auto_tools/fio_test_file'" cmd = cmd.format(test_data["fio_file_size"]) fio_start_ts = time.time() tc_logger.info("FIO cmd execution start timestamp: " + str(fio_start_ts)) adb.execute_adb_command(cmd) fio_end_ts = time.time() tc_logger.info("FIO cmd execution end timestamp: " + str(fio_end_ts)) result = assert_values_meet_benchmark([fio_end_ts - fio_start_ts], test_benchmark["fio_sw_time"], False, "dc.yaml", ["fio_sw_time"]) | result # wait for abs monitoring to completed p.join(test_benchmark["fio_sw_time"]["max"] + test_benchmark["abs_recover_time"]["max"]) p.terminate() # verify whether abs is used up during fio execution monitor_log_file = os.path.join(test_conf["monitor_home"], "wb_func_abs_monitor.log") abs_use_up_ts_pattern = re.compile("abs_use_up_ts=(.+)") with open(monitor_log_file, "r") as f: for line in f.readlines(): abs_use_up_ts = abs_use_up_ts_pattern.search(line) if abs_use_up_ts is not None: break else: abs_min = line abs_min = abs_min.split("%")[0] result = assert_values_meet_benchmark( [int(abs_min)], test_benchmark["abs_min"], False, "dc.yaml", ["abs_min"]) | result # verify whether abs can fully recover abs_recover_ts_pattern = re.compile("abs_recover_ts=(.+)") with open(monitor_log_file, "r") as f: for line in f.readlines(): abs_recover_ts = abs_recover_ts_pattern.search(line) if abs_recover_ts is not None: abs_recover_ts = abs_recover_ts.group(1) break else: abs_max = line abs_max = abs_max.split("%")[0] result = assert_values_meet_benchmark( [int(abs_max)], test_benchmark["abs_max"], False, "dc.yaml", ["abs_max"]) | result # verify abs recover time consumption if abs_recover_ts == "timeout": abs_recover_time = -1 else: abs_recover_time = float(abs_recover_ts) - fio_end_ts result = assert_values_meet_benchmark( [abs_recover_time], test_benchmark["abs_recover_time"], False, "dc.yaml", ["abs_recover_time"]) | result # verify flush_status_after_recover_1 flush_status_after_recover = device.get_wb_flush_status() result = assert_values_meet_benchmark( [flush_status_after_recover], test_benchmark["flush_status_after_recover_1"], False, "dc.yaml", ["flush_status_after_recover_1"]) | result # flush_status_after_recover_2 flush_status_after_recover = device.get_wb_flush_status() result = assert_values_meet_benchmark( [flush_status_after_recover], test_benchmark["flush_status_after_recover_2"], False, "dc.yaml", ["flush_status_after_recover_2"]) | result # return test case result return result