Skip to content

Commit

Permalink
get more logs and embed docker logs into html report
Browse files Browse the repository at this point in the history
  • Loading branch information
louie-tsai committed Nov 25, 2024
1 parent 243aab7 commit 4f82faa
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 11 deletions.
14 changes: 14 additions & 0 deletions ChatQnA/tests/ChatQnA_Xeon.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
"model": "Intel/neural-chat-7b-v3-3",
"messages": [{"role": "user", "content": "What is Deep Learning?"}],
"output": "generated_text"
},
{
"service": "nginx",
"port": "80",
"endpoint": "v1/chatqna",
"messages": "What is the revenue of Nike in 2023?",
"output": "data: "
},
{
"service": "mega",
"port": "8888",
"endpoint": "v1/chatqna",
"messages": "What is the revenue of Nike in 2023?",
"output": "data: "
}
]
}
81 changes: 70 additions & 11 deletions ChatQnA/tests/Triage.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def __init__(self, name):
self.docker_ps = ''
self.docker_ps_df = None
self.docker_report_df = None
import datetime
d = datetime.datetime.now()
dateinfo = d.strftime("%m-%d_%H-%M")
self.result_folder_name = self.name + '_' + dateinfo
import os
if not os.path.exists(self.result_folder_name):
os.makedirs(self.result_folder_name)

def parse_docker_ps_to_df(self, output):
lines = []
columns = []
Expand Down Expand Up @@ -146,11 +154,14 @@ def dump_docker_logs(self, port):

def dump_log_to_file(self, output, filename):
#print(filename)
fd = open(filename, "w") # append mode
filepath = self.result_folder_name + os.sep + filename
fd = open(filepath, "w") # append mode
fd.write(output)
fd.close()
return
def generate_triage_report(self):
import os
import re
print(" Example Name:" + self.name)
print(" ### ENV Variables###")
print(self.env_vars_df)
Expand All @@ -161,15 +172,34 @@ def generate_triage_report(self):
print(self.docker_report_df)

report_name = self.name + '.html'
with open(report_name, 'w') as hfile:
hfile.write(
"\n\n ### Servces Status###\n\n"
+ self.docker_report_df.to_html()
+ "\n\n ### System Info###\n\n"
+ self.system_info_df.head().to_html()
+ "\n\n ### Environment Variables###\n\n"
+ self.env_vars_df.head().to_html())


report_path = self.result_folder_name + os.sep + report_name

# Log Files

docker_log_html_content = ''
pattern = r".*\_docker_log.txt$" # Match all files ending with ".txt"
for filename in os.listdir(self.result_folder_name):
if re.search(pattern, filename):
html_content = " \n\n <h2>" + filename +"</h2>\n" + "<iframe src=" + '"' + filename + '"' + " width=" + '"' + "1000" + '"' + "height=" + '"' + "300" + '"' +"></iframe>"
docker_log_html_content = docker_log_html_content + html_content



with open(report_path, 'w') as hfile:
hfile.write(
"\n\n <h1>1. Servces Status</h1>\n\n"
+ self.docker_report_df.to_html()
+ "\n\n <h1>2. System Info</h1>\n\n"
+ self.system_info_df.head().to_html()
+ "\n\n <h1>3. Environment Variables</h1>\n\n"
+ self.env_vars_df.head().to_html()
+ "\n\n <h1>4. Docker Log Files</h1>\n\n"
+ docker_log_html_content)

print("\nReport File is : " + report_path)
import shutil
shutil.make_archive(self.result_folder_name, 'zip', self.result_folder_name)
return


Expand Down Expand Up @@ -314,7 +344,22 @@ def test_6_rerank(self):
response_status_code = self.utils.service_test(self.ip, port, endpoint_name, data, self.triage_report, self.triage_level)
self.assertEqual(response_status_code, 200)

def test_7_llm(self):
def test_7_nginx(self):

service_name = "nginx"
#Get configs/data
data, port, endpoint_name, output = self.utils.load_input_data(service_name)
self.assertNotEqual(data, None)

# Health Check
response_status_code = self.utils.service_health_check(self.ip, port, self.triage_report, self.triage_level)
#self.assertEqual(response_status_code, 200)

# Testing
response_status_code = self.utils.service_test(self.ip, port, endpoint_name, data, self.triage_report, self.triage_level)
self.assertEqual(response_status_code, 200)

def test_8_llm(self):

service_name = "llm"
#Get configs/data
Expand All @@ -329,6 +374,20 @@ def test_7_llm(self):
response_status_code = self.utils.service_test(self.ip, port, endpoint_name, data, self.triage_report, self.triage_level)
self.assertEqual(response_status_code, 200)

def test_9_mega(self):

service_name = "mega"
#Get configs/data
data, port, endpoint_name, output = self.utils.load_input_data(service_name)
self.assertNotEqual(data, None)

# Health Check
response_status_code = self.utils.service_health_check(self.ip, port, self.triage_report, self.triage_level)
#self.assertEqual(response_status_code, 200)

# Testing
response_status_code = self.utils.service_test(self.ip, port, endpoint_name, data, self.triage_report, self.triage_level)
self.assertEqual(response_status_code, 200)


if __name__ == "__main__":
Expand Down

0 comments on commit 4f82faa

Please sign in to comment.