source: issm/trunk/cron/report.sh@ 1636

Last change on this file since 1636 was 1636, checked in by Mathieu Morlighem, 16 years ago

minor

  • Property svn:executable set to *
File size: 6.7 KB
RevLine 
[882]1#!/bin/bash
2#generate html report from nightly.log output file
3
[1568]4#Process log
[884]5cat nightly.log | grep 'package: macayeal' | grep -v "not supported yet" > macayeal.log
6cat nightly.log | grep 'package: ice' | grep -v "not supported yet" > ice.log
7cat nightly.log | grep 'package: cielo_serial' | grep -v "not supported yet" > cielo_serial.log
8cat nightly.log | grep 'package: cielo_parallel'| grep -v "not supported yet" > cielo_parallel.log
[1605]9cat nightly.log | grep 'NIGHTLYRUNTERMINATEDCORRECTLY' > check.log
10cat nightly.log | grep 'ERROR' | grep -v "PETSC ERROR" > errors.log
11cat nightly.log | grep 'SUCCESS' > success.log
12cat errors.log success.log > tests.log
[882]13
[1568]14#create some variables
[1635]15if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
[1576]16then
17 IS_INSTALL=0
18else
19 IS_INSTALL=1
20fi
[1636]21if [ $(wc -l nightly.log | awk '{printf("%s",$1);}') -eq 0 ]
[1568]22then
[1636]23 IS_RUN=0
24else
25 IS_RUN=1
26fi
27if [ $(wc -l check.log | awk '{printf("%s",$1);}') -eq 0 ]
28then
[1568]29 IS_END=0
30else
31 IS_END=1
32fi
33
[1605]34#style
35H1_STYLE='width="800px" cellpadding="20"'
36H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
[1568]37
[1605]38H2_STYLE='width="840px" cellpadding="20"'
39H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
[1074]40
[1605]41TABLE_STYLE='width="820px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
42TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
[882]43
[1605]44BODY_STYLE='width="820px"'
45BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
[882]46
[1605]47NOTEST_STYLE='width="650px"'
48NOTEST_FONT='style="color:#FF0000; font-family:Arial, Verdana, Tahoma; font-size:14px;" align="left"'
[1074]49
[1605]50FOOTER_STYLE='width="800px" cellpadding="10"'
51FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
[1574]52
[1605]53#build report.html
54
55#first: summary
[1574]56cat << END > summary.html
[1605]57<div align="center">
58<table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
59
60<table $TABLE_STYLE>
61<tr>
62<td $TABLE_FONT>host: $HOST_NAME</td>
63<td $TABLE_FONT>date: $TODAY</td>
64</tr>
65<tr>
66<td $TABLE_FONT>OS: $OS</td>
67<td $TABLE_FONT>total elapsed time: $ELAPSED_TOTAL</td>
68</tr>
69<tr>
70<td $TABLE_FONT>release: $ISSM_RELEASE</td>
71<td $TABLE_FONT>installation elapsed time: $ELAPSED_INSTAL</td>
72</tr>
73<tr>
74$(#print status
75if [ $(echo $IS_INSTALL) = 0 ];
[882]76then
[1568]77 #installation failed, end of report
[1605]78 echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation failed</span></td>"
79 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
80 echo "</tr>"
81 echo "</table>"
[1574]82 rm check.log errors.log success.log tests.log
[882]83else
[1605]84 #installation successful. Did we go to the end?
85
[1636]86 if [ $(echo $IS_RUN) -eq 0 ];
[1568]87 then
[1636]88 #run failed, end of report
89 echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation successful but tests runs failed</span></td>"
90 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
91 echo "</tr>"
92 echo "</table>"
93 rm check.log errors.log success.log tests.log
94
[1568]95 else
[1636]96
97 if [ $(echo $IS_END) -eq 0 ];
98 then
99 echo "<td $TABLE_FONT>status: <span style=\"color:#FFA500\">stopped before the end</span></td>"
100 else
101 echo "<td $TABLE_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td>"
102 fi
103 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
104 echo "</tr>"
105 echo "<tr>"
106 echo "<td $TABLE_FONT>number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)</td>"
107 echo "<td $TABLE_FONT> </td>"
108 echo "</tr>"
109 echo "<tr>"
110 echo "<td $TABLE_FONT>number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm success.log tests.log)</td>"
111 echo "<td $TABLE_FONT> </td>"
112 echo "</tr>"
113 echo "</table>"
114
115 #draw a line and clean up
116 echo "<br><hr width=\"900px\">"
117 rm check.log
[1568]118 fi
[1574]119fi)
120END
[882]121
[1605]122
[1574]123#report content
[1576]124if [ $(echo $IS_INSTALL) = 1 ];
[1574]125then
126 cat << END > content.html
[882]127$(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
128
129 #enter title
[1605]130 if [ $package == "macayeal" ];
131 then
132 echo "<table $H2_STYLE><tr><td $H2_FONT>Macayeal package</td></tr></table>"
[882]133 fi
[1605]134 if [ $package == "ice" ];
135 then
136 echo "<table $H2_STYLE><tr><td $H2_FONT>Ice package</td></tr></table>"
[882]137 fi
[1605]138 if [ $package == "cielo_serial" ];
139 then
140 echo "<table $H2_STYLE><tr><td $H2_FONT>Cielo serial package</td></tr></table>"
[882]141 fi
[1605]142 if [ $package == "cielo_parallel" ];
143 then
144 echo "<table $H2_STYLE><tr><td $H2_FONT>Cielo parallel package</td></tr></table>"
[882]145 fi
146
[1074]147 #check that at least one Test exists
[882]148 if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
[1074]149
150 #No Test: use a table to fix entourage bug.
[1605]151 echo "<table $NOTEST_STYLE><tr><td $NOTEST_FONT>No test found.</td></tr></table>"
[1074]152
[882]153 else
154
[1605]155 echo "<table $BODY_STYLE cellspacing=\"-1\">"
156 echo "<tr> <th $BODY_FONT>Result</th> <th $BODY_FONT>Tolerance</th> <th $BODY_FONT>Test</th> <th $BODY_FONT>Solution</th> <th $BODY_FONT>Field</th> </tr>"
[882]157
158 # go through the lines of $package.log
[1521]159 COUNTER=0
[1435]160 MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
161 while [ $COUNTER -lt $MAX ]; do
162 let COUNTER=COUNTER+1
[882]163
164 echo "<tr>"
165
166 #see wether it is success or error (get color: red or green)
[1435]167 if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
[882]168 then
169 color="bgcolor=#ddffdd";
170 else
171 color="bgcolor=#ffdddd";
172 fi
[1605]173 FONT=$(echo "$BODY_FONT $color")
[882]174
175 #build html corresponding line
[1605]176 cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk -v FONT="$FONT" '
177 /line'$COUNTER'o/ { printf("<td %s>%s</td><td %s> %s%s%s</td><td %s> %s</td><td %s> %s</td><td %s> %s</td>",FONT,$2,FONT,$4,$5,$6,FONT,$8,FONT,$10,FONT,$14);}
178 ';
[882]179 echo "</tr>"
180 done
181
182 echo "</table>"
183 fi
[1074]184
[1605]185 #remove log file
[882]186 rm $package.log
[1074]187
[882]188done)
[1574]189<br>
190END
191else
192 for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
193 rm $package.log
194 done
195fi
[882]196
[1574]197#last footer
198cat << END > footer.html
[1074]199<br>
[1605]200<table $FOOTER_STYLE><tr><td $FOOTER_FONT><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</td></tr></table>
201</div>
[882]202END
[1574]203
204#concatenate files
[1636]205if [ $IS_INSTALL -eq 1 ];
[1574]206then
[1636]207 if [ $IS_END -eq 1 ];
208 cat summary.html content.html footer.html > report.html
209 rm summary.html content.html footer.html
210 else
211 cat summary.html footer.html > report.html
212 rm summary.html footer.html
213 fi
[1574]214else
[1605]215 cat summary.html footer.html > report.html
216 rm summary.html footer.html
[1574]217fi
Note: See TracBrowser for help on using the repository browser.