From 50e8e47f81ca9ea140d71522b7ccdac213ba253d Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 17 Aug 2021 17:55:59 -0600 Subject: [PATCH] lf_check.py : added time , start , stop and duration Signed-off-by: Chuck SmileyRekiere --- py-scripts/tools/lf_check.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/py-scripts/tools/lf_check.py b/py-scripts/tools/lf_check.py index 26c7dc1b..2fbb21b2 100755 --- a/py-scripts/tools/lf_check.py +++ b/py-scripts/tools/lf_check.py @@ -126,6 +126,11 @@ class lf_check(): self.background_purple = "background-color:purple" self.background_blue = "background-color:blue" + # results + self.test_start_time = "" + self.test_end_time = "" + self.duration = "" + self.http_test_ip = "" self.ftp_test_ip = "" self.test_ip = "" @@ -380,6 +385,9 @@ NOTE: Diagrams are links in dashboard""".format(ip_qa=ip,qa_url=qa_url) Test Command + Duration + Start + End Result STDOUT STDERR @@ -983,6 +991,9 @@ NOTE: Diagrams are links in dashboard""".format(ip_qa=ip,qa_url=qa_url) command_to_run = command command_to_run = shlex.split(command_to_run) print("running {command_to_run}".format(command_to_run=command_to_run)) + self.test_start_time = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")).replace(':','-') + print("Test start: {time}".format(time=self.test_start_time)) + start_time = datetime.datetime.now() try: process = subprocess.Popen(command_to_run, shell=False, stdout=stdout_log, stderr=stderr_log, universal_newlines=True) @@ -997,6 +1008,14 @@ NOTE: Diagrams are links in dashboard""".format(ip_qa=ip,qa_url=qa_url) print("No such file or directory with command: {}".format(command)) self.logger.info("No such file or directory with command: {}".format(command)) + end_time = datetime.datetime.now() + self.test_end_time = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")).replace(':','-') + print("Test end time {time}".format(time=self.test_end_time)) + + time_delta = end_time - start_time + self.duration = "{day}d {seconds}s {msec} ms".format( + day=time_delta.days,seconds=time_delta.seconds,msec=time_delta.microseconds) + if self.test_result != "TIMEOUT": stderr_log_size = os.path.getsize(stderr_log_txt) if stderr_log_size > 0: @@ -1043,6 +1062,9 @@ NOTE: Diagrams are links in dashboard""".format(ip_qa=ip,qa_url=qa_url) stderr_log_link = str(stderr_log_txt).replace('/home/lanforge', '') self.html_results += """ """ + str(test) + """""" + str(command) + """ + """ + str(self.duration) + """ + """ + str(self.test_start_time) + """ + """ + str(self.test_end_time) + """ """ + str(self.test_result) + """ STDOUT""" if self.test_result == "Failure": @@ -1053,6 +1075,7 @@ NOTE: Diagrams are links in dashboard""".format(ip_qa=ip,qa_url=qa_url) stderr_log_link) + """ target=\"_blank\">STDERR""" else: self.html_results += """""" + self.html_results += """""" row = [test, command, self.test_result, stdout_log_txt, stderr_log_txt]