lf_report.py : added text for html, lf_check.py added sha, test_l3_longevity.py : changed title

Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
Chuck SmileyRekiere
2021-05-14 14:23:30 -06:00
parent 1d826bab20
commit 90f5e0b155
3 changed files with 35 additions and 28 deletions

View File

@@ -65,6 +65,7 @@ class lf_report():
print("path set: {}".format(self.path))
self.dataframe=_dataframe
self.text = ""
self.title=_title
self.table_title=_table_title
self.graph_title=_graph_title
@@ -144,6 +145,9 @@ class lf_report():
os.mkdir(self.path_date_time)
print("report path : {}".format(self.path_date_time))
def set_text(self,_text):
self.text = _text
def set_title(self,_title):
self.title = _title
@@ -287,6 +291,18 @@ class lf_report():
"""
self.html += self.table_title_html
def build_text(self):
self.text_html = """
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1' />
<div class='HeaderStyle'>
<h3 class='TitleFontPrint' style='color:darkgreen;'>""" + str(self.text) + """</h3>
"""
self.html += self.text_html
def build_date_time(self):
self.date_time = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-h-%m-m-%S-s")).replace(':','-')
return self.date_time

View File

@@ -140,6 +140,7 @@ class lf_check():
out, err = process.communicate()
errcode = process.returncode
# Not currently used
def load_blank_db(self):
print("file_wd {}".format(self.scripts_wd))
try:
@@ -192,8 +193,8 @@ class lf_check():
#process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
process = subprocess.Popen((command).split(' '), shell=False, stdout=stdout_log, stderr=stderr_log, universal_newlines=True)
# wait for the process to terminate
out, err = process.communicate()
errcode = process.returncode
# out, err = process.communicate() #CMR remove
# errcode = process.returncode #CMR remove
print(stdout_log_txt)
stdout_log_size = os.path.getsize(stdout_log_txt)
@@ -250,8 +251,7 @@ for running scripts listed in lf_check_config.ini
args = parser.parse_args()
# Create report, instanciate a reporting class
# need to be able to pass in the naming?
# output report.
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())
@@ -262,28 +262,29 @@ for running scripts listed in lf_check_config.ini
outfile = report.file_add_path(outfile)
print("output file : {}".format(outfile))
# create header
# lf_check() class created
check = lf_check(_csv_outfile = csv_outfile,
_outfile = outfile)
#check.parse_ap_stats()
# get the git sha
process = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE)
(commit_hash, err) = process.communicate()
exit_code = process.wait()
git_sha = commit_hash.decode('utf-8','ignore')
#print("commit_hash: {}".format(commit_hash))
#print("commit_hash2: {}".format(commit_hash.decode('utf-8','ignore')))
check.read_config_contents() # CMR need mode to just print out the test config and not run
check.run_script_test()
# Get Results
# csv_test_results_file =
# csv_kpi_file
report.set_title("LF Check (lf_check.py)")
# Generate Ouptput reports
report.set_title("LF Check: lf_check.py")
report.build_banner()
report.set_table_title("LF Check Test Results")
report.build_table_title()
report.set_text("sha: {}".format(git_sha))
report.build_text()
html_results = check.get_html_results()
#print("html_results {}".format(html_results))
report.set_custom_html(html_results)
@@ -292,16 +293,6 @@ for running scripts listed in lf_check_config.ini
report.write_pdf_with_timestamp()
# report.set_table_dataframe_from_csv(csv_kpi_file)
# report.build_table()
# report.write_html()
# report.write_pdf(_page_size = 'A3', _orientation='Landscape')
# report.write_pdf(_page_size = 'A4', _orientation='Portrait')
if __name__ == '__main__':
main()

View File

@@ -920,8 +920,8 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp m
report = lf_report(_results_dir_name = "test_l3_longevity",_output_html="test_l3_longevity.html",_output_pdf="test_l3_longevity.pdf")
if args.csv_outfile != None:
current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime())
csv_outfile = "test_l3_longevity_{}_{}.csv".format(args.csv_outfile,current_time)
current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
csv_outfile = "{}_{}-test_l3_longevity.csv".format(args.csv_outfile,current_time)
csv_outfile = report.file_add_path(csv_outfile)
print("csv output file : {}".format(csv_outfile))