b=424823
- daily reports will now contain lists of unclear results, as well as added and changed testcases git-svn-id: svn://10.0.0.236/trunk@249048 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -36,6 +36,7 @@ use Getopt::Long;
|
||||
use Litmus::DBI;
|
||||
use Litmus::Config;
|
||||
use Litmus::Mailer qw( sendMessage );
|
||||
use Litmus::DB::Testcase;
|
||||
|
||||
use vars qw(
|
||||
$litmus_dbh
|
||||
@@ -51,7 +52,8 @@ $litmus_dbh = Litmus::DBI->db_ReadOnly() or die;
|
||||
|
||||
my $help;
|
||||
my $html_mail;
|
||||
GetOptions('help|?' => \$help,'html' => \$html_mail);
|
||||
my $batch;
|
||||
GetOptions('help|?' => \$help,'html' => \$html_mail,'batch' => \$batch);
|
||||
|
||||
if ($help) {
|
||||
&usage;
|
||||
@@ -63,7 +65,7 @@ my ($sql,$sth);
|
||||
$sql= qq{
|
||||
SELECT tr.testresult_id, pr.name AS product, br.name AS branch, pl.name AS platform, o.name AS opsys, u.email, tc.summary
|
||||
FROM test_results tr, platforms pl, opsyses o, products pr, branches br, users u, testcases tc
|
||||
WHERE tr.result_status_id=2 AND
|
||||
WHERE tr.result_status_id=? AND
|
||||
tr.valid=1 AND
|
||||
tr.submission_time>=DATE_SUB(NOW(), INTERVAL 1 DAY) AND
|
||||
tr.testcase_id=tc.testcase_id AND
|
||||
@@ -77,22 +79,112 @@ ORDER BY pr.name ASC, br.name ASC, pl.name ASC, o.name ASC;
|
||||
};
|
||||
|
||||
$sth = $litmus_dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$sth->execute(2);
|
||||
my @failed_results;
|
||||
while (my $hashref = $sth->fetchrow_hashref) {
|
||||
$hashref->{'branch'} =~ s/ Branch//;
|
||||
push @failed_results, $hashref;
|
||||
}
|
||||
|
||||
my $combined_message_body = "";
|
||||
|
||||
my $failed_results_message_body = "";
|
||||
if (scalar @failed_results > 0) {
|
||||
$failed_results_message_body = &format_results(\@failed_results, 'Failed', $html_mail);
|
||||
} else {
|
||||
# No Failed Results today.
|
||||
}
|
||||
|
||||
if ($failed_results_message_body ne "") {
|
||||
if (!$batch) {
|
||||
my $title = 'Failed results submitted to Litmus in the past day';
|
||||
my $rv = &create_and_send_message($title,
|
||||
$failed_results_message_body,
|
||||
$html_mail);
|
||||
} else {
|
||||
$combined_message_body .= $failed_results_message_body;
|
||||
}
|
||||
}
|
||||
|
||||
$sth->execute(3);
|
||||
my @unclear_results;
|
||||
while (my $hashref = $sth->fetchrow_hashref) {
|
||||
$hashref->{'branch'} =~ s/ Branch//;
|
||||
push @unclear_results, $hashref;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
if (scalar @failed_results > 0) {
|
||||
if ($html_mail) {
|
||||
&send_html_mail(\@failed_results);
|
||||
} else {
|
||||
&send_plaintext_mail(\@failed_results);
|
||||
}
|
||||
my $unclear_results_message_body = "";
|
||||
if (scalar @unclear_results > 0) {
|
||||
$unclear_results_message_body = &format_results(\@unclear_results, 'Unclear', $html_mail);
|
||||
} else {
|
||||
# No Results today.
|
||||
# No Unclear Results today.
|
||||
}
|
||||
|
||||
if ($unclear_results_message_body ne "") {
|
||||
if (!$batch) {
|
||||
my $title = 'Unclear results submitted to Litmus in the past day';
|
||||
my $rv = &create_and_send_message($title,
|
||||
$unclear_results_message_body,
|
||||
$html_mail);
|
||||
} else {
|
||||
$combined_message_body .= $unclear_results_message_body;
|
||||
}
|
||||
}
|
||||
|
||||
my $match_limit = 100;
|
||||
|
||||
my @added_testcases = Litmus::DB::Testcase->getNewTestcases(
|
||||
1,
|
||||
$match_limit
|
||||
);
|
||||
|
||||
my $added_testcases_message_body = "";
|
||||
if (scalar @added_testcases > 0) {
|
||||
$added_testcases_message_body = &format_testcases(\@added_testcases, 'Added to', $html_mail);
|
||||
} else {
|
||||
# No testcases added today.
|
||||
}
|
||||
|
||||
if ($added_testcases_message_body ne "") {
|
||||
if (!$batch) {
|
||||
my $title = 'Testcases added to Litmus in the past day';
|
||||
my $rv = &create_and_send_message($title,
|
||||
$added_testcases_message_body,
|
||||
$html_mail);
|
||||
} else {
|
||||
$combined_message_body .= $added_testcases_message_body;
|
||||
}
|
||||
}
|
||||
|
||||
my @changed_testcases = Litmus::DB::Testcase->getRecentlyUpdated(
|
||||
1,
|
||||
$match_limit
|
||||
);
|
||||
|
||||
my $changed_testcases_message_body = "";
|
||||
if (scalar @changed_testcases > 0) {
|
||||
$changed_testcases_message_body = &format_testcases(\@changed_testcases, 'Changed in', $html_mail);
|
||||
} else {
|
||||
# No testcases added today.
|
||||
}
|
||||
|
||||
if ($changed_testcases_message_body ne "") {
|
||||
if (!$batch) {
|
||||
my $title = 'Testcases changed in Litmus in the past day';
|
||||
my $rv = &create_and_send_message($title,
|
||||
$changed_testcases_message_body,
|
||||
$html_mail);
|
||||
} else {
|
||||
$combined_message_body .= $changed_testcases_message_body;
|
||||
}
|
||||
}
|
||||
|
||||
if ($batch and $combined_message_body ne "") {
|
||||
my $title = '';
|
||||
my $rv = &create_and_send_message($title,
|
||||
$combined_message_body,
|
||||
$html_mail);
|
||||
}
|
||||
|
||||
exit;
|
||||
@@ -103,76 +195,27 @@ sub usage {
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub message_header {
|
||||
sub message_header($$) {
|
||||
my ($title,$html_mail) = @_;
|
||||
my $today = &UnixDate("today","%Y/%m/%d");
|
||||
my $subject = "[litmus] Daily Report - $today";
|
||||
my $subject = "[litmus] Daily Report";
|
||||
if ($title) {
|
||||
$subject .= " - $title";
|
||||
}
|
||||
$subject .= " - $today";
|
||||
my $header .= "Subject: $subject\n";
|
||||
$header .= "Content-Type: text/html\n";
|
||||
$header .= "To: " . join(',',@Litmus::Config::nightly_report_recipients) . "\n\n";
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub send_plaintext_mail(\@) {
|
||||
my ($failed_results) = @_;
|
||||
|
||||
my $message = &message_header();
|
||||
$message .= "Failed results submitted to Litmus in the past day:\n\n";
|
||||
|
||||
my $header = sprintf(
|
||||
"%-8s %-8s %-6s %-8s %-8s %-15s %-20s",
|
||||
"ID",
|
||||
"Product",
|
||||
"Branch",
|
||||
"Platform",
|
||||
"Opsys",
|
||||
"Tester",
|
||||
"Testcase Summary"
|
||||
);
|
||||
|
||||
$message .= "$header\n";
|
||||
|
||||
foreach my $hashref (@$failed_results) {
|
||||
my $result_link = sprintf("<a href=\"http://litmus.mozilla.org/single_result.cgi?id=%d\">%-8d</a>",
|
||||
$hashref->{'testresult_id'},
|
||||
$hashref->{'testresult_id'}
|
||||
);
|
||||
$message .= $result_link;
|
||||
|
||||
my $result = sprintf(
|
||||
" %-8.8s %-6.6s %-8.8s %-8.8s %-15.15s %-20.20s",
|
||||
$hashref->{'product'},
|
||||
$hashref->{'branch'},
|
||||
$hashref->{'platform'},
|
||||
$hashref->{'opsys'},
|
||||
$hashref->{'email'},
|
||||
$hashref->{'summary'}
|
||||
);
|
||||
$message .= "$result\n";
|
||||
}
|
||||
|
||||
$message .= "\n";
|
||||
$message .= "Visit Litmus: <a href=\"http:/litmus.mozilla.org/\">http:/litmus.mozilla.org/</a>\n\n";
|
||||
|
||||
my $rv = sendMessage($message);
|
||||
if (!$rv) {
|
||||
warn('[litmus] FAIL - Unable to send daily report');
|
||||
}
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub send_html_mail(\@) {
|
||||
my ($failed_results) = @_;
|
||||
|
||||
my $message = &message_header();
|
||||
|
||||
$message .= '
|
||||
if ($html_mail) {
|
||||
$header .= '
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<title>Failed results submitted to Litmus in the past day</title>
|
||||
<title>';
|
||||
$header .= $subject;
|
||||
$header .= '</title>
|
||||
</head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
@@ -227,9 +270,34 @@ td {
|
||||
</style>
|
||||
|
||||
<body>
|
||||
';
|
||||
}
|
||||
return $header;
|
||||
}
|
||||
|
||||
<h1>Failed results submitted to Litmus in the past day:</h1>
|
||||
#########################################################################
|
||||
sub message_footer($) {
|
||||
my ($html_mail) = @_;
|
||||
|
||||
my $footer = "";
|
||||
if ($html_mail) {
|
||||
$footer = "<p>Visit Litmus: <a href=\"http:/litmus.mozilla.org/\">http:/litmus.mozilla.org/</a></p>\n";
|
||||
$footer .= "</body>\n</html>\n\n";
|
||||
} else {
|
||||
$footer = "Visit Litmus: <a href=\"http:/litmus.mozilla.org/\">http:/litmus.mozilla.org/</a>\n\n";
|
||||
}
|
||||
|
||||
return $footer;
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub format_results(\@$$) {
|
||||
my ($results, $result_type, $html_mail) = @_;
|
||||
|
||||
my $formatted_results = "";
|
||||
if ($html_mail) {
|
||||
$formatted_results = "<h1>${result_type} results submitted to Litmus in the past day:</h1>";
|
||||
$formatted_results .= '
|
||||
<table cellpadding="0" cellspacing="0" width="620" class="body">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
@@ -242,36 +310,142 @@ td {
|
||||
</tr>
|
||||
';
|
||||
|
||||
my $class='odd';
|
||||
foreach my $hashref (@$failed_results) {
|
||||
if ($class eq 'odd') {
|
||||
$class = 'even';
|
||||
} else {
|
||||
$class = 'odd';
|
||||
}
|
||||
$message .= '<tr class="' . $class . '">' . "\n";
|
||||
$message .= '<td align="center"><a href="http://litmus.mozilla.org/single_result.cgi?id=' .
|
||||
$hashref->{'testresult_id'} . '">' .
|
||||
$hashref->{'testresult_id'} . "</a></td>\n";
|
||||
my $class='odd';
|
||||
foreach my $hashref (@$results) {
|
||||
if ($class eq 'odd') {
|
||||
$class = 'even';
|
||||
} else {
|
||||
$class = 'odd';
|
||||
}
|
||||
$formatted_results .= '<tr class="' . $class . '">' . "\n";
|
||||
$formatted_results .= '<td align="center"><a href="http://litmus.mozilla.org/single_result.cgi?id=' .
|
||||
$hashref->{'testresult_id'} . '">' .
|
||||
$hashref->{'testresult_id'} . "</a></td>\n";
|
||||
|
||||
$message .= '<td align="center">' . $hashref->{'product'} . "</td>\n";
|
||||
$message .= '<td align="center">' . $hashref->{'branch'} . "</td>\n";
|
||||
$message .= '<td align="center">' . $hashref->{'platform'} . "</td>\n";
|
||||
$message .= '<td align="center">' . $hashref->{'opsys'} . "</td>\n";
|
||||
$message .= '<td align="center">' . $hashref->{'email'} . "</td>\n";
|
||||
$message .= '<td>' . $hashref->{'summary'} . "</td>\n";
|
||||
$formatted_results .= '<td align="center">' . $hashref->{'product'} . "</td>\n";
|
||||
$formatted_results .= '<td align="center">' . $hashref->{'branch'} . "</td>\n";
|
||||
$formatted_results .= '<td align="center">' . $hashref->{'platform'} . "</td>\n";
|
||||
$formatted_results .= '<td align="center">' . $hashref->{'opsys'} . "</td>\n";
|
||||
$formatted_results .= '<td align="center">' . $hashref->{'email'} . "</td>\n";
|
||||
$formatted_results .= '<td>' . $hashref->{'summary'} . "</td>\n";
|
||||
|
||||
$message .= "</tr>\n";
|
||||
$formatted_results .= "</tr>\n";
|
||||
}
|
||||
$formatted_results .= "</table>\n<br/>\n";
|
||||
|
||||
} else {
|
||||
$formatted_results .= "${result_type} results submitted to Litmus in the past day:\n\n";
|
||||
|
||||
my $header = sprintf(
|
||||
"%-8s %-8s %-6s %-8s %-8s %-15s %-20s",
|
||||
"ID",
|
||||
"Product",
|
||||
"Branch",
|
||||
"Platform",
|
||||
"Opsys",
|
||||
"Tester",
|
||||
"Testcase Summary"
|
||||
);
|
||||
|
||||
$formatted_results .= "$header\n";
|
||||
|
||||
foreach my $hashref (@$results) {
|
||||
my $result_link = sprintf("<a href=\"http://litmus.mozilla.org/single_result.cgi?id=%d\">%-8d</a>",
|
||||
$hashref->{'testresult_id'},
|
||||
$hashref->{'testresult_id'}
|
||||
);
|
||||
$formatted_results .= $result_link;
|
||||
|
||||
my $result = sprintf(
|
||||
" %-8.8s %-6.6s %-8.8s %-8.8s %-15.15s %-20.20s",
|
||||
$hashref->{'product'},
|
||||
$hashref->{'branch'},
|
||||
$hashref->{'platform'},
|
||||
$hashref->{'opsys'},
|
||||
$hashref->{'email'},
|
||||
$hashref->{'summary'}
|
||||
);
|
||||
$formatted_results .= "$result\n";
|
||||
}
|
||||
$formatted_results .= "\n\n";
|
||||
}
|
||||
return $formatted_results;
|
||||
}
|
||||
|
||||
########################################################################
|
||||
sub format_testcases(\@$$) {
|
||||
my ($testcases, $testcase_type, $html_mail) = @_;
|
||||
|
||||
my $formatted_testcases = "";
|
||||
|
||||
if ($html_mail) {
|
||||
$formatted_testcases = "<h1>Testcases $testcase_type Litmus in the past day:</h1>";
|
||||
$formatted_testcases .= '
|
||||
<table cellpadding="0" cellspacing="0" width="620" class="body">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
';
|
||||
my $class='odd';
|
||||
foreach my $hashref (@$testcases) {
|
||||
if ($class eq 'odd') {
|
||||
$class = 'even';
|
||||
} else {
|
||||
$class = 'odd';
|
||||
}
|
||||
$formatted_testcases .= '<tr class="' . $class . '">' . "\n";
|
||||
$formatted_testcases .= '<td align="center"><a href="https://litmus.mozilla.org/show_test.cgi?id=' .
|
||||
$hashref->{'testcase_id'} . '">' .
|
||||
$hashref->{'testcase_id'} . "</a></td>\n";
|
||||
|
||||
$formatted_testcases .= '<td align="center">' . $hashref->{'summary'} . "</td>\n";
|
||||
$formatted_testcases .= "</tr>\n";
|
||||
}
|
||||
$formatted_testcases .= "</table>\n<br/>\n";
|
||||
|
||||
} else {
|
||||
$formatted_testcases .= "${testcase_type} Litmus in the past day:\n\n";
|
||||
|
||||
my $header = sprintf(
|
||||
"%-8s %-20s",
|
||||
"ID",
|
||||
"Summary"
|
||||
);
|
||||
|
||||
$formatted_testcases .= "$header\n";
|
||||
|
||||
foreach my $hashref (@$testcases) {
|
||||
my $result_link = sprintf("<a href=\"http://litmus.mozilla.org/show_test.cgi?id=%d\">%-8d</a>",
|
||||
$hashref->{'testcase_id'},
|
||||
$hashref->{'testcase_id'}
|
||||
);
|
||||
$formatted_testcases .= $result_link;
|
||||
|
||||
my $testcase = sprintf(
|
||||
" %-20.20s",
|
||||
$hashref->{'summary'}
|
||||
);
|
||||
$formatted_testcases .= "$testcase\n";
|
||||
}
|
||||
$formatted_testcases .= "\n\n";
|
||||
}
|
||||
|
||||
$message .= "</table>\n";
|
||||
$message .= "<p>Visit Litmus: <a href=\"http:/litmus.mozilla.org/\">http:/litmus.mozilla.org/</a></p>\n";
|
||||
return $formatted_testcases;
|
||||
}
|
||||
|
||||
$message .= "</body>\n</html>\n\n";
|
||||
#########################################################################
|
||||
sub create_and_send_message($$$) {
|
||||
my($title,$message_body,$html_mail) = @_;
|
||||
my $message_header = &message_header($title, $html_mail);
|
||||
my $message_footer = &message_footer($html_mail);
|
||||
|
||||
my $message = $message_header . $message_body . $message_footer;
|
||||
|
||||
my $rv = sendMessage($message);
|
||||
if (!$rv) {
|
||||
warn('[litmus] FAIL - Unable to send daily report');
|
||||
}
|
||||
warn('[litmus] FAIL - Unable to send daily report - ' . $title);
|
||||
}
|
||||
|
||||
return $rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user