blob: 0e7ef8d7d40b8ca67f974ae1d7d227093e9de226 [file] [log] [blame]
andrewonlab5cbb3cd2014-11-18 14:25:40 -05001#!/usr/bin/env python
2
3import sys
4import os
5import re
6import datetime
7import time
8import argparse
9
10parser = argparse.ArgumentParser()
11parser.add_argument("-n", "--name", help="Comma Separated string of test names. Ex: --name='test1, test2, test3'")
12args = parser.parse_args()
13
14#Pass in test names as a comma separated string argument.
15#Example: ./Jenkins_getresult.py "Test1,Test2,Test3,Test4"
16name_list = args.name.split(",")
17result_list = map(lambda x: x.strip(), name_list)
18
19#NOTE: testnames list should be in order in which it is run
20testnames = result_list
21output = ''
22testdate = datetime.datetime.now()
23
24output +="<p>**************************************</p>"
25output +=testdate.strftime('Jenkins test result for %H:%M on %b %d, %Y. %Z')
26
27#TestON reporting
28for test in testnames:
29 name = os.popen("ls /home/admin/ONLabTest/TestON/logs/ -rt | grep %s | tail -1" % test).read().split()[0]
30 path = "/home/admin/ONLabTest/TestON/logs/" + name + "/"
31 output +="<p></p>"
32 #output +=" Date: %s, %s %s" % (name.split("_")[2], name.split("_")[1], name.split("_")[3]) + "<br>*******************<br>"
33 #Open the latest log folder
34 output += "<h2>Test "+str(test)+"</h2><p>************************************</p>"
35
36 f = open(path + name + ".rpt")
37
38 #Parse through each line of logs and look for specific strings to output to wiki.
39 #NOTE: with current implementation, you must specify which output to output to wiki by using
40 #main.log.report("") since it is looking for the [REPORT] tag in the logs
41 for line in f:
42 if re.search("Result summary for Testcase", line):
43 output += "<h3>"+str(line)+"</h3>"
44 #output += "<br>"
45 if re.search("\[REPORT\]", line):
46 line_split = line.split("] ")
47 #line string is split by bracket, and first two items (log tags) in list are omitted from output
48 #join is used to convert list to string
49 line_str = ''.join(line_split[2:])
50 output += "<p>"
51 output += line_str
52 output += "</p>"
53 if re.search("Result:", line):
54 output += "<p>"
55 output += line
56 output += "</p>"
57 f.close()
58
59 #*********************
60 #include any other phrase specific to case you would like to include in wiki here
61 if test == "IntentPerf":
62 output += "URL to Historical Performance results data: <a href='http://10.128.5.54/perf.html'>Perf Graph</a>"
63 #*********************
64print output