From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id CA21E106A for ; Thu, 11 May 2017 07:43:22 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 May 2017 22:43:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,322,1491289200"; d="scan'208,217";a="967114367" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 10 May 2017 22:43:21 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 May 2017 22:43:21 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 May 2017 22:43:20 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.217]) with mapi id 14.03.0319.002; Thu, 11 May 2017 13:42:34 +0800 From: "Liu, Yong" To: "Pei, Yulong" , "dts@dpdk.org" CC: "Xu, Qian Q" Thread-Topic: [PATCH 1/2] support html report for nic performance result Thread-Index: AQHSygwbhfhq4ULhMUyaU9g9AE/b5KHunSqg Date: Thu, 11 May 2017 05:42:33 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62DCEDD4@SHSMSX103.ccr.corp.intel.com> References: <1494392396-125970-1-git-send-email-yulong.pei@intel.com> In-Reply-To: <1494392396-125970-1-git-send-email-yulong.pei@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH 1/2] support html report for nic performance result X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 May 2017 05:43:23 -0000 Thanks Yulong, some comments below. > -----Original Message----- > From: Pei, Yulong > Sent: Wednesday, May 10, 2017 1:00 PM > To: dts@dpdk.org > Cc: Xu, Qian Q ; Liu, Yong > Subject: [PATCH 1/2] support html report for nic performance result >=20 > support html report for nic performance result and support to send it > out by email. >=20 > Signed-off-by: Yulong Pei > --- > nics/perf_report.jinja | 82 +++++++++++++++++++++++++++++++++++++++++ > nics/perf_report.py | 79 ++++++++++++++++++++++++++++++++++++++++ > nics/system_info.py | 99 > ++++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 260 insertions(+) > create mode 100644 nics/perf_report.jinja > create mode 100644 nics/perf_report.py > create mode 100644 nics/system_info.py >=20 > diff --git a/nics/perf_report.jinja b/nics/perf_report.jinja > new file mode 100644 > index 0000000..1a3f903 > --- /dev/null > +++ b/nics/perf_report.jinja > @@ -0,0 +1,82 @@ > + > + > + > + > +{{ title }} > + > + > + > + > + > +
> +

DPDK Git Information

> +

Branch: {{ git_info['branch'] }}

> +

commit: {{ git_info['commit'] }}

> +

Author: {{ git_info['author'] }}

> +

Date: {{ git_info['date'] }}

> +

Summary: {{ git_info['summary'] }}

> +
> + > +
> +

NIC Detail Information

> + > + > + > + > + > + {% for key in nic_infos %} > + > + > + > + > + {% endfor %} > +
ItemDescription
{{ key }}{{ nic_infos[key] }}
> +
> + > +
> +

Test Result:

> + > + > + > + > + > + > + {% for result in test_results %} > + > + > + > + > + > + {% endfor %} > +
Frame_size(bytes)Throughput(Mpps)Line rate%
{{ result[0] }}{{ result[1] }}{{ result[2] }}
> +
> + > +
> +

Hardware and Software Ingredients

> + > + > + > + > + > + {% for key in system_infos %} > + > + > + > + > + {% endfor %} > +
ItemDescription
{{ key }}{{ system_infos[key] }}
> +
> + > + > + > + > diff --git a/nics/perf_report.py b/nics/perf_report.py Yulong, please add copyright for each python file. > new file mode 100644 > index 0000000..2517a68 > --- /dev/null > +++ b/nics/perf_report.py > @@ -0,0 +1,79 @@ > +import os > +import time > +import re > + > +import jinja2 > +import smtplib > + > +from email.mime.text import MIMEText > +from email.mime.multipart import MIMEMultipart > +from collections import OrderedDict > +#install GitPython > +from git import Repo > +from system_info import SystemInfo > + > +def get_dpdk_git_info(repo_dir=3D"/root/dpdk"): > + > + if not os.path.exists(repo_dir): > + return None > + > + commit =3D OrderedDict() > + > + git_repo =3D Repo(repo_dir) > + assert not git_repo.bare > + > + latest_commit =3D git_repo.active_branch.commit > + commit['branch'] =3D str(git_repo.active_branch) > + commit['commit'] =3D str(latest_commit) > + commit['author'] =3D latest_commit.author > + commit['date'] =3D time.ctime(latest_commit.authored_date) > + commit['summary'] =3D latest_commit.summary > + return commit > + > +def generate_html_report(file_tpl, perf_data, git_info, nic_info, > system_info): > + > + if not os.path.exists(file_tpl): > + return None > + > + templateLoader =3D jinja2.FileSystemLoader(searchpath =3D "/") > + templateEnv =3D jinja2.Environment(loader=3DtemplateLoader) > + template =3D templateEnv.get_template(file_tpl) > + > + templateVars =3D { "title" : "Daily Performance Test Report", \ > + "test_results" : perf_data, \ > + "system_infos" : system_info, \ > + "nic_infos" : nic_info, \ > + "git_info" : git_info \ > + } > + > + output =3D template.render(templateVars) > + return output > + > +#sender =3D 'zzz@intel.com' > +#mailto =3D ['xxx@intel.com', 'yyy@intel.com'] > +def html_message(sender, mailto, subject, html_msg): > + > + msg =3D MIMEMultipart('alternative') > + msg['From'] =3D sender > + msg['to'] =3D ";".join(mailto) > + msg['Subject'] =3D subject > + > + msg.attach(MIMEText(html_msg, 'html')) > + > + return msg > + > +#smtp =3D smtplib.SMTP('smtp.intel.com') > +def send_email(sender, mailto, message, smtp_server): > + > + try: > + smtp =3D smtplib.SMTP(smtp_server) > + smtp.sendmail(sender, mailto, message.as_string()) > + smtp.quit() > + print "OK to sent email." > + except Exception, e: > + print "Failed to send email " + str(e) Please use utils.red and utils.green for those failure and successful log. > + > +def send_html_report(sender, mailto, subject, html_msg, smtp_server): > + > + message =3D html_message(sender, mailto, subject, html_msg) > + send_email(sender, mailto, message, smtp_server) > diff --git a/nics/system_info.py b/nics/system_info.py > new file mode 100644 > index 0000000..a78c841 > --- /dev/null > +++ b/nics/system_info.py > @@ -0,0 +1,99 @@ > +#!/usr/bin/python > + > +import os > +import time > +import re > + > +from collections import OrderedDict > +#install GitPython > +from git import Repo > + > +class SystemInfo(object): > + > + def __init__(self, dut, pci_device_id): > + self.dut =3D dut > + self.pci_device_id =3D pci_device_id > + self.session =3D self.dut.session > + self.system_info =3D OrderedDict() > + self.nic_info =3D OrderedDict() > + > + def get_system_info(self): > + > + board =3D self.session.send_expect("dmidecode -s system-product- > name", "# ") > + self.system_info["Board"] =3D board > + > + processors =3D self.session.send_expect("dmidecode -s processor- > version", "# ") > + processor =3D processors.split('\r\n')[0] > + self.system_info["CPU"] =3D processor > + > + memories =3D self.session.send_expect("dmidecode -t memory", "]#= ") > + channels, size, speed =3D self._strip_memory(memories) > + memory_info =3D "Total %d MBs in %d channels @ %s" %(size, > channels, speed) > + self.system_info["Memory"] =3D memory_info > + > + release =3D self.session.send_expect("lsb_release -d |awk -F':' > '{print $2}'", "# ") > + self.system_info["Operating system"] =3D release > + > + kernel =3D self.session.send_expect("uname -r", "# ") > + self.system_info["Linux kernel version"] =3D kernel > + > + gcc_info =3D self.session.send_expect("gcc --version", "# ") > + gcc =3D gcc_info.split('\r\n')[0] > + self.system_info["GCC version"] =3D gcc > + > + return self.system_info > + > + def _strip_memory(self, memories): > + """ > + Size: 8192 MB Locator: DIMM_A1 Speed: 2133 MHz > + """ > + s_regex =3D r"(\s+)Size: (\d+) MB" > + l_regex=3D r"(\s+)Locator: DIMM_(\w+)" > + speed_regex =3D r"(\s+)Speed: (.*)" > + size =3D "" > + locate =3D "" > + speed =3D "Unknown" > + memory_infos =3D [] > + memory_channel =3D set() > + lines =3D memories.split('\r\n') > + total_size =3D 0 > + for line in lines: > + m =3D re.match(s_regex, line) > + if m: > + size =3D m.group(2) > + l_m =3D re.match(l_regex, line) > + if l_m: > + locate =3D l_m.group(2) > + s_m =3D re.match(speed_regex, line) > + if s_m: > + speed =3D s_m.group(2) > + if speed !=3D "Unknown": > + memory=3D{"Size": size, "Locate": locate, "Speed": speed= } > + memory_infos.append(memory) > + speed =3D "Unknown" > + total_size +=3D int(size) > + memory_channel.add(locate[0]) > + > + return len(memory_channel), total_size, memory_infos[0]["Speed"] > + > + def get_nic_info(self): > + > + vendor =3D self.session.send_expect("cat > /sys/bus/pci/devices/%s/vendor" % self.pci_device_id, "# ") > + if "No such" in vendor: > + return None > + device =3D self.session.send_expect("cat > /sys/bus/pci/devices/%s/device" % self.pci_device_id, "# ") > + if "No such" in device: > + return None > + > + interface =3D self.session.send_expect("ls --color=3Dnever > /sys/bus/pci/devices/%s/net" % self.pci_device_id, "# ") > + if "No such" in interface: > + return None > + firmware =3D self.session.send_expect("ethtool -i %s | grep -- > color=3Dnever firmware |awk -F':' '{print $2}'" % interface, "# ") > + if "No such" in firmware: > + return None > + > + self.nic_info['nic_name'] =3D self.session.send_expect("lspci - > vmmks %s |grep -i ^device |awk -F':' '{print $2}'" % self.pci_device_id, > "# ") Please try to keep each line in 79 characters. > + self.nic_info['device_id'] =3D vendor[2:] + ':' + device[2:] > + self.nic_info['firmware-version'] =3D firmware > + return self.nic_info > + > -- > 2.5.0