test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Qiu, Michael" <michael.qiu@intel.com>
To: "Liu, Yong" <yong.liu@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH 1/2] framework: add new module to create email report
Date: Mon, 16 Feb 2015 05:02:19 +0000	[thread overview]
Message-ID: <533710CFB86FA344BFBF2D6802E60286CEA215@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1424061918-9106-1-git-send-email-yong.liu@intel.com>

On 2/16/2015 12:45 PM, Yong Liu wrote:
> This module will parse excel result file and create email like below.
>
> Summary: Run XXX cases (PASS-Count FAIL-Count BLOCK-Count)
> Latest commit log:
> Kernel Version:
> CPU info:
> GCC Version:

Here I don't see any place try to show this field

Thanks,
Michael
> Target: x86_64-native-linuxapp-gcc                   FAIL:XXX/YYY
> Detail information of failed cases:
> Target: x86_64-native-linuxapp-gcc
> Test Case                                            Result
> Case name                                            FAILED
>
> Signed-off-by: Marvinliu <yong.liu@intel.com>
>
> diff --git a/framework/email_report.py b/framework/email_report.py
> new file mode 100644
> index 0000000..38e390c
> --- /dev/null
> +++ b/framework/email_report.py
> @@ -0,0 +1,132 @@
> +import argparse      # prase arguments module
> +import smtplib       # send email module
> +from email.mime.text import MIMEText
> +from email.mime.multipart import MIMEMultipart
> +
> +from excel_reporter import ExcelReporter  # excel parse module
> +from texttable import Texttable          # formatted output module
> +
> +rece_maillist = ["dts@dpdk.org"]
> +from_maillist = "sys_stv@intel.com"
> +
> +# Global variable
> +total_target = 0
> +global os_type
> +global test_type
> +global git_commit
> +global dut_config
> +dut_config = []
> +os_type = ""
> +test_type = ""
> +git_commit = ""
> +
> +
> +# Format of Email
> +class Email():
> +
> +    def __init__(self, excel):
> +        self.subject_format = "%s %s Test Report"
> +        self.summary_format = "Summary: Run %d cases (PASS-%d FAIL-%d BLOCK-%d)"
> +        self.result_summary_format = "Target: %-30s               FAIL:%d/%d\r\n"
> +        excel = ExcelReporter(excel)
> +        self.result = excel.load()
> +        self.smtp = smtplib.SMTP()
> +        self.smtp.connect("mail.intel.com", 25)
> +
> +    def subject(self):
> +        return self.subject_format % (os_type, test_type)
> +
> +    def summary(self):
> +        total = 0
> +        passed = 0
> +        fail = 0
> +        block = 0
> +        for dut in self.result.all_duts():
> +            targets = self.result.all_targets(dut)
> +            for target in targets:
> +                suites = self.result.get_target_suites(dut, target)
> +                results = self.result.get_suites_status(suites)
> +                total += len(results)
> +                passed += results.count("PASSED")
> +                fail += results.count("FAILED")
> +                block += results.count("BLOCKED")
> +
> +        return self.summary_format % (total, passed, fail, block)
> +
> +    def target_summary(self):
> +        summary = ""
> +        for dut in self.result.all_duts():
> +            targets = self.result.all_targets(dut)
> +            for target in targets:
> +                suites = self.result.get_target_suites(dut, target)
> +                results = self.result.get_suites_status(suites)
> +                summary += self.result_summary_format % (target, results.count("FAILED"), len(results))
> +        return summary
> +
> +    def failed_case_summary(self):
> +        summary = ""
> +        for dut in self.result.all_duts():
> +            targets = self.result.all_targets(dut)
> +            for target in targets:
> +                summary += "Target: %s\r\n" % (target)
> +                table = Texttable()
> +                table.set_deco(Texttable.HEADER)
> +                table.set_cols_align(["l", "l"])
> +                table.set_cols_width([50, 10])
> +                table.add_row(["Test Case", "Result"])
> +                suites = self.result.get_target_suites(dut, target)
> +                failed = self.result.get_cases_by_status(suites, 'FAILED')
> +                blocked = self.result.get_cases_by_status(suites, 'BLOCKED')
> +                for case in failed:
> +                    table.add_row([case, 'FAILED'])
> +                for case in blocked:
> +                    table.add_row([case, 'BLOCKED'])
> +                summary += table.draw()
> +                summary += "\r\n\r\n"
> +
> +        return summary
> +
> +    def send(self, _from, _to, attachment):
> +        content = ""
> +        msg = MIMEMultipart('alternative')
> +        msg['Subject'] = self.subject()
> +        msg['From'] = _from
> +        msg['To'] = ", ".join(_to)
> +        content += self.summary()
> +        content += "\r\n\r\n"
> +        content += git_commit
> +        content += "\r\n\r\n"
> +        content += "".join(dut_config)
> +        content += "\r\n\r\n"
> +        content += self.target_summary()
> +        content += "\r\n\r\n"
> +        content += "Detail information of failed cases:\r\n"
> +        content += self.failed_case_summary()
> +        part2 = MIMEText(content, "plain", "utf-8")
> +        msg.attach(part2)
> +        fp = open(attachment, 'r')
> +        part1 = MIMEText(fp.read(), 'base64', 'utf-8')
> +        part1['Content-type'] = 'application/octet-stream'
> +        part1['Content-Disposition'] = 'attachment;filename="output.zip"'
> +        fp.close()
> +        msg.attach(part1)
> +        self.smtp.sendmail(
> +            _from, _to, msg.as_string())
> +        self.smtp.quit()
> +
> +if __name__ == '__main__':
> +    parser = argparse.ArgumentParser(description="DTS Email Report Module")
> +    parser.add_argument("-o", "--os_type", default="Fedora20")
> +    parser.add_argument("-t", "--test_type", default="Functional")
> +    parser.add_argument(
> +        "-e", "--excel_file", default="output/test_results.xls")
> +    parser.add_argument("-g", "--git_commit", default="test commit")
> +    args = parser.parse_args()
> +    os_type = args.os_type
> +    test_type = args.test_type
> +    git_commit = args.git_commit
> +    email = Email(args.excel_file)
> +    print email.subject()
> +    print email.summary()
> +    print email.target_summary()
> +    print email.failed_case_summary()


      parent reply	other threads:[~2015-02-16  5:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16  4:45 Yong Liu
2015-02-16  4:45 ` [dts] [PATCH 2/2] framework: support load execution result from excel report Yong Liu
2015-02-16  5:02 ` Qiu, Michael [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=533710CFB86FA344BFBF2D6802E60286CEA215@SHSMSX101.ccr.corp.intel.com \
    --to=michael.qiu@intel.com \
    --cc=dts@dpdk.org \
    --cc=yong.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).