Skip to content

Commit

Permalink
update check report support html (oceanbase#482)
Browse files Browse the repository at this point in the history
* update report title

* remove report
  • Loading branch information
xiaodong-ji authored Oct 14, 2024
1 parent d4cf88a commit 7244a18
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions handler/checker/check_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def export_report_html(self):
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>obdiag Check Report</title>
<title>{{ report_title }}</title>
<style>
body {
padding-top: 60px;
Expand Down Expand Up @@ -290,7 +290,7 @@ def export_report_html(self):
html_template_report_info_table = """
<section>
<table>
<div style="font-weight: bold;font-size: 24px;">obdiag Check Report</div>
<div style="font-weight: bold;font-size: 24px;">{{ report_title }}</div>
<p class="line"></p>
<tr>
<th>Report Time</th>
Expand Down Expand Up @@ -344,16 +344,21 @@ def export_report_html(self):
if len(task.all_fail()) == 0 and len(task.all_critical()) == 0 and len(task.all_warning()) == 0:
report_all_html.append({"task": task.name, "task_report": "all pass"})

report_title_str = "obdiag Check Report"
if self.report_target == "observer":
report_title_str = "obdiag observer Check Report"
elif self.report_target == "obproxy":
report_title_str = "obdiag obproxy Check Report"
fp = open(self.report_path + ".html", 'a+', encoding='utf-8')
template_head = Template(html_template_head)
template_table = Template(html_template_data_table)
fp.write(template_head.render() + "\n")
fp.write(template_head.render(report_title=report_title_str) + "\n")
template_report_info_table = Template(html_template_report_info_table)
cluster_ips = ""
for server in self.context.cluster_config["servers"]:
cluster_ips += server["ip"]
cluster_ips += ";"
fp.write(template_report_info_table.render(report_time=self.report_time, obdiag_version=OBDIAG_VERSION, ob_cluster_ip=cluster_ips, ob_version=self.context.cluster_config["version"]) + "\n")
fp.write(template_report_info_table.render(report_title=report_title_str, report_time=self.report_time, obdiag_version=OBDIAG_VERSION, ob_cluster_ip=cluster_ips, ob_version=self.context.cluster_config["version"]) + "\n")

if len(fail_map_html) != 0:
rendered_fail_map_html = template_table.render(task_name="Fail Tasks Report", tasks=fail_map_html)
Expand Down

0 comments on commit 7244a18

Please sign in to comment.