diff --git a/py-scripts/sandbox/lf_check.py b/py-scripts/sandbox/lf_check.py index fef4220b..d6ce4207 100755 --- a/py-scripts/sandbox/lf_check.py +++ b/py-scripts/sandbox/lf_check.py @@ -52,7 +52,7 @@ class FileAdapter(object): class lf_check(): def __init__(self, - _csv_outfile, + _csv_results, _outfile): self.lf_mgr_ip = "" self.lf_mgr_port = "" @@ -62,7 +62,7 @@ class lf_check(): os.chdir(path_parent) self.scripts_wd = os.getcwd() self.results = "" - self.csv_outfile = _csv_outfile, + self.csv_results = _csv_results, self.outfile = _outfile self.test_result = "Failure" self.results_col_titles = ["Test","Command","Result","STDOUT","STDERR"] @@ -83,6 +83,20 @@ class lf_check(): self.col_names = "" self.upstream_port = "" + self.csv_results_file = "" + self.csv_results_writer = "" + self.csv_results_column_headers = "" + + def get_csv_results(self): + return self.csv_file.name + + def start_csv_results(self): + self.csv_results_file = open(self.csv_results, "w") + self.csv_results_writer = csv.writer(self.csv_results_file, delimiter=",") + self.csv_results_column_headers = ['Test','Command','Result','STDOUT','STDERR'] + self.csv_rsults_writer.writerow(self.csv_results_column_headers) + self.csv_results_file.flush() + def get_html_results(self): return self.html_results @@ -116,8 +130,8 @@ class lf_check(): config_file = configparser.ConfigParser() success = True success = config_file.read(CONFIG_FILE) - #print("{}".format(success)) - #print("{}".format(config_file)) + print("{}".format(success)) + print("{}".format(config_file)) if 'LF_MGR' in config_file.sections(): section = config_file['LF_MGR'] @@ -164,6 +178,7 @@ class lf_check(): self.test_dict = json.loads(section.get('TEST_DICT', self.test_dict).replace('\n',' ').replace('\r',' ')) #print("test_dict {}".format(self.test_dict)) + def load_factory_default_db(self): #print("file_wd {}".format(self.scripts_wd)) try: @@ -195,6 +210,8 @@ class lf_check(): def run_script_test(self): self.start_html_results() + self.start_csv_results() + for test in self.test_dict: if self.test_dict[test]['enabled'] == "FALSE": print("test: {} skipped".format(test)) @@ -263,30 +280,23 @@ class lf_check(): #if err: print("command Test timed out: {}".format(command)) - - # close the file stdout_log.flush() stdout_log.close() - stderr_log.flush() stderr_log.close() - - #print(stdout_log_txt) + ''' stdout_log_size = os.path.getsize(stdout_log_txt) stdout_log_st_size = os.stat(stdout_log_txt).st_size print("stdout_log_size {}".format(stdout_log_size)) print("stdout_log_st_size {}".format(stdout_log_st_size)) print("stdout {}".format(os.stat(stdout_log_txt))) - - stderr_log_size = os.path.getsize(stderr_log_txt) stderr_log_st_size = os.stat(stderr_log_txt).st_size - #print("stderr_log_size {}".format(stderr_log_size)) - #print("stderr_log_st_size {}".format(stderr_log_st_size)) - #print("stderr {}".format(os.stat(stderr_log_txt))) - - + print("stderr_log_size {}".format(stderr_log_size)) + print("stderr_log_st_size {}".format(stderr_log_st_size)) + print("stderr {}".format(os.stat(stderr_log_txt))) + ''' #print(stderr_log_txt) stderr_log_size = os.path.getsize(stderr_log_txt) if stderr_log_size > 0 : @@ -299,7 +309,6 @@ class lf_check(): self.test_result = "Success" background = self.background_green - self.html_results += """ """ + str(test) + """""" + str(command) + """ """ + str(self.test_result) + """ @@ -309,8 +318,10 @@ class lf_check(): else: self.html_results += """""" self.html_results += """""" - # CMR need to generate the CSV.. should be pretty straight forward + row = [test,command,self.test_result,stdout_log_txt,stderr_log_txt] + self.csv_results_writer.writerow(row) + self.csv_results_file.flush() #print("row: {}".format(row)) print("test: {} executed".format(test)) @@ -344,15 +355,15 @@ for running scripts listed in lf_check_config.ini report = lf_report(_results_dir_name = "lf_check",_output_html="lf_check.html",_output_pdf="lf-check.pdf") current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) - csv_outfile = "lf_check{}-{}.csv".format(args.outfile,current_time) - csv_outfile = report.file_add_path(csv_outfile) - #print("csv output file : {}".format(csv_outfile)) + csv_results = "lf_check{}-{}.csv".format(args.outfile,current_time) + csv_results = report.file_add_path(csv_results) + #print("csv output file : {}".format(csv_results)) outfile = "lf_check-{}-{}".format(args.outfile,current_time) outfile = report.file_add_path(outfile) #print("output file : {}".format(outfile)) # lf_check() class created - check = lf_check(_csv_outfile = csv_outfile, + check = lf_check(_csv_results = csv_results, _outfile = outfile) # get the git sha diff --git a/py-scripts/sandbox/lf_check_config.ini b/py-scripts/sandbox/lf_check_config.ini index b8dc02f8..3bfbfa2f 100755 --- a/py-scripts/sandbox/lf_check_config.ini +++ b/py-scripts/sandbox/lf_check_config.ini @@ -28,6 +28,7 @@ SSID_PW_USED = "jedway-wpa2-x2048-4-1" SECURITY_USED = "wpa2" NUM_STA = "3" COL_NAMES = "name,tx_bytes,rx_bytes,dropped" +UPSTREAM_PORT = "eth1" [LF_MGR] @@ -41,8 +42,14 @@ REPORT_DATA="/home/lanforge/report-data" [TEST_PARAMETERS] TEST_TIMEOUT = "120" -# NOTE: the +# TEST_DICTIONARY used by lf_check, Other section names will be ignored so can save other test lists [TEST_DICTIONARY] +TEST_DICT: { + "create_l3":{"enabled":"TRUE","command":"create_l3.py","args":"RADIO_0_CFG --debug"}, + "create_l4":{"enabled":"TRUE","command":"create_l4.py","args":"RADIO_1_CFG --debug"} +} + +[TEST_DICTIONARY_NOT_RUN] TEST_DICT: { "example_security_connection0":{"enabled":"TRUE","command":"example_security_connection.py","args":"RADIO_0_CFG --debug"}, "example_security_connection1":{"enabled":"TRUE","command":"example_security_connection.py","args":"RADIO_2_CFG --debug"}, @@ -60,7 +67,7 @@ TEST_DICT: { "test_ipv4_l4":{"enabled":"TRUE","command":"test_ipv4_l4.py","args":"RADIO_0_CFG --test_duration 15s --debug"}, "test_ipv4_variable_time0":{"enabled":"TRUE","command":"test_ipv4_variable_time.py","args":"RADIO_0_CFG --test_duration 15s --output_format excel --layer3_cols COL_NAMES --traffic_type lf_udp --debug"}, "test_ipv4_variable_time1":{"enabled":"TRUE","command":"test_ipv4_variable_time.py","args":"RADIO_0_CFG --test_duration 15s --output_format csv --layer3_cols COL_NAMES --traffic_type lf_udp --debug"}, - "create_bridge":{"enabled":"FALSE","command":"create_bridge.py","args":""}, + "create_bridge":{"enabled":"TRUE","command":"create_bridge.py","args":"--radio RADIO_USED --upstream_port UPSTREAM_PORT --target_device sta0000 --debug"}, "create_l3":{"enabled":"TRUE","command":"create_l3.py","args":"RADIO_0_CFG --debug"}, "create_l4":{"enabled":"TRUE","command":"create_l4.py","args":"RADIO_1_CFG --debug"}, "create_macvlan":{"enabled":"FALSE","command":"create_macvlan.py","args":""},