# HG changeset patch # User Maciej Seroka # Date 1286376601 -3600 # Node ID 7ad2f93c76661674976fb30eea5b4e39a949337f # Parent 05c7556875df9d9e57007d7df6239f3023933310 Added BIT db interface for Test Results diff -r 05c7556875df -r 7ad2f93c7666 common/diamonds/linksForDiamonds.xml.ftl --- a/common/diamonds/linksForDiamonds.xml.ftl Wed Oct 06 11:18:12 2010 +0100 +++ b/common/diamonds/linksForDiamonds.xml.ftl Wed Oct 06 15:50:01 2010 +0100 @@ -22,20 +22,6 @@ Build Logs file:///${ant['sf.spec.publish.networkdrive']}\${ant['sf.spec.job.name']}\builds\${ant['sf.spec.job.codeline']}\${ant['build.id']}\build_logs.zip - <#if "${ant['sf.spec.smoketest.enable']}" = "true" && "${ant['sf.spec.ats.version']}" = "ats3"> - - log - Smoke Test Report - file:///${ant['sf.spec.publish.networkdrive']}\${ant['sf.spec.job.name']}\builds\${ant['sf.spec.job.codeline']}\${ant['build.id']}\ats_reports\ATS3Report.html - - - <#if "${ant['sf.spec.smoketest.enable']}" = "true" && "${ant['sf.spec.ats.version']}" = "ats4"> - - log - Smoke Test Report - file:///${ant['sf.spec.publish.networkdrive']}\${ant['sf.spec.job.name']}\builds\${ant['sf.spec.job.codeline']}\${ant['build.id']}\ats_reports\simplelogger\testreport.xml - - <#if "${ant['sf.spec.bccheck.enable']}" = "true" && "${ant['sf.spec.bccheck.enable.ha']}" = "true"> log diff -r 05c7556875df -r 7ad2f93c7666 common/tools/ats/update_brag_status.pl --- a/common/tools/ats/update_brag_status.pl Wed Oct 06 11:18:12 2010 +0100 +++ b/common/tools/ats/update_brag_status.pl Wed Oct 06 15:50:01 2010 +0100 @@ -24,14 +24,17 @@ my $test_report; my $help; my $line; -my $auto_tests_total; -my $auto_tests_passed; -my $auto_tests_failed; -my $auto_tests_notrun; -my $man_tests_total; -my $man_tests_passed; -my $man_tests_failed; -my $man_tests_notrun; +my $auto_tests_total = 0; +my $auto_tests_passed = 0; +my $auto_tests_failed = 0; +my $auto_tests_skipped = 0; +my $auto_tests_noresult = 0; +my $auto_tests_notrun = 0; +my $auto_tests_disabled = 0; +my $man_tests_total = 0; +my $man_tests_passed = 0; +my $man_tests_failed = 0; +my $man_tests_notrun = 0; my $temp_path; my $detailshref; my $xml_report; @@ -42,6 +45,26 @@ my $m; my @lines; my $man_detailshref; +my $build_id; +my $name; +my $type = "smoke"; # Currently hard-coded. +my $start_time; +my $end_time; +my $time_stamp; +my ($date, $time); +my ($day, $month, $year); +my $cases_total; +my $cases_passed; +my $cases_failed; +my $cases_not_run; +my $cases_not_available; +my $fail_rate; +my $auto_pass_rate; +my $test_brag_status; +my $test_target = "winscw"; # Currently hard-coded. +my $report_url; +my $bit_file = "bitinfo_smoketest.txt"; +my $bitops_path = "\.\.\\bitops.pl"; # Location of the bitops script (to update BIT db). sub usage($); sub help(); @@ -51,6 +74,7 @@ 'ats3-report' => \$ats3_report, 'ats4-report' => \$ats4_report, 'test-report' => \$test_report, + 'build-id' => \$build_id, 'help' => \$help); GetOptions(\%optmap, @@ -58,6 +82,7 @@ 'ats3-report=s', 'ats4-report=s', 'test-report=s', + 'build-id=i', 'help!') or usage_error(); @@ -84,6 +109,10 @@ $auto_tests_total =~ s/^.*\">//; $auto_tests_total =~ s/<.*//; } + if ($read_flag == 3) { # Get number of Disabled tests. + ($auto_tests_disabled) = split /\//,$line; + $auto_tests_disabled =~ s/^.*\">//; # Remove opening td tag. + } if ($read_flag == 4) { # Get number of Passed tests. ($auto_tests_passed) = split /\//,$line; $auto_tests_passed =~ s/^.*\">//; # Remove opening td tag. @@ -92,9 +121,13 @@ ($auto_tests_failed) = split /\//,$line; $auto_tests_failed =~ s/^.*\">//; # Remove opening td tag. } - if ($read_flag == 7) { # Get number of Not run tests. - ($auto_tests_notrun) = split /\//,$line; - $auto_tests_notrun =~ s/^.*\">//; # Remove opening td tag. + if ($read_flag == 6) { # Get number of Skipped tests. + ($auto_tests_skipped) = split /\//,$line; + $auto_tests_skipped =~ s/^.*\">//; # Remove opening td tag. + } + if ($read_flag == 7) { # Get number of No result tests. + ($auto_tests_noresult) = split /\//,$line; + $auto_tests_noresult =~ s/^.*\">//; # Remove opening td tag. } if ($line eq "Nested tests<\/td>") { # Set flag for reading results. $read_flag = 0; @@ -104,12 +137,33 @@ }; } close FILE; + # Set number of No run tests. + $auto_tests_notrun = $auto_tests_skipped + $auto_tests_noresult; + + # Get additional info + open (FILE, "<$ats3_report") or die ("Couldn't open $ats3_report for reading: $!\n"); + while ($line = ) { + chomp $line; + if ($line =~ "Test run:") { + $name = $line; + $name =~ s/^.*//; + $name =~ s/<\/td>.*//; + } + if ($line =~ "Start time:") { + $start_time = $line; + $start_time =~ s/^.*//; + $start_time =~ s/<\/td>.*//; + } + if ($line =~ "End time:") { + $end_time = $line; + $end_time =~ s/^.*//; + $end_time =~ s/<\/td>.*//; + } + } + close FILE; + } if (defined($ats4_report)) { # Get ATS4 Smoketest results. - $auto_tests_total = 0; - $auto_tests_passed = 0; - $auto_tests_failed = 0; - $auto_tests_notrun = 0; open (FILE, "<$ats4_report") or die ("Couldn't open $ats4_report for reading: $!\n"); my $read_flag = -1; print "Reading $ats4_report... "; @@ -120,7 +174,8 @@ $auto_tests_total++; if ($line =~ "PASSED") { $auto_tests_passed++ } if ($line =~ "FAILED") { $auto_tests_failed++ } - if (($line =~ "SKIPPED") || ($line =~ "NOT_AVAILABLE")) { $auto_tests_notrun++ } + if ($line =~ "SKIPPED") { $auto_tests_skipped++ } + if ($line =~ "NOT_AVAILABLE") { $auto_tests_notrun++ } # Re-set flag. $read_flag = -1; } @@ -129,21 +184,44 @@ } } close FILE; + + # Get additional info + $name = "Smoketest"; # Name not available in ATS4 testreport. + open (FILE, "<$ats4_report") or die ("Couldn't open $ats4_report for reading: $!\n"); + $start_time = ""; + while ($line = ) { + chomp $line; + if ($line =~ "timeStamp=\"") { + $time_stamp = $line; + $time_stamp =~ s/^.*timeStamp=\"//; + $time_stamp =~ s/\..*//; + ($date,$time) = split /\s/,$time_stamp; + ($day, $month, $year) = split /-/,$date; + $time_stamp = "$year-$month-$day $time"; + if ($start_time eq "") { $start_time = $time_stamp } + } + } + close FILE; + $end_time = $time_stamp; # Last entry becomes end_time. } print "complete\n"; -print "Total number of tests: $auto_tests_total\n"; -print "Passed tests: $auto_tests_passed\n"; -print "Failed tests: $auto_tests_failed\n"; -print "Not run tests: $auto_tests_notrun\n"; +#print "Total number of tests: $auto_tests_total\n"; +#print "Passed tests: $auto_tests_passed\n"; +#print "Failed tests: $auto_tests_failed\n"; +#print "Not run tests: $auto_tests_notrun\n"; -# Define detailshref attribute. +# Define detailshref attribute and report_url. $temp_path = $brag_file; $temp_path =~ s/\\/\//g; # Replace \ with / $temp_path =~ s/\/summary\/.*//; if (defined($ats3_report)) { $detailshref = $ats3_report }; if (defined($ats4_report)) { $detailshref = $ats4_report }; $detailshref =~ s/\\/\//g; # Replace \ with / +$report_url = lc($detailshref); $detailshref =~ s/($temp_path)/../; +#Replace "//v800020/publish" with "http://cdn.symbian.org" in report_url +$report_url =~ s/^.*\/publish\//http:\/\/cdn.symbian.org\//; + if (defined($test_report)) { $man_detailshref = $test_report; $man_detailshref =~ s/\\/\//g; # Replace \ with / @@ -154,20 +232,16 @@ print "Parsing " . $test_report . "... "; $xml_report = XMLin("$test_report", keeproot => 1, forcearray => [ 'test-set', 'test-case' ], keyattr => [] ); print "complete \n"; - $man_tests_total = 0; - $man_tests_passed = 0; - $man_tests_failed = 0; - $man_tests_notrun = 0; foreach $test_case (@{$xml_report->{'test-report'}->{'test-set'}->[0]->{'test-case'}}) { if (lc($test_case->{'result'}) eq "passed") { $man_tests_passed++ } if (lc($test_case->{'result'}) eq "failed") { $man_tests_failed++ } if (lc($test_case->{'result'}) eq "not run") { $man_tests_notrun++ } $man_tests_total++; } - print "Total number of tests: $man_tests_total\n"; - print "Passed tests: $man_tests_passed\n"; - print "Failed tests: $man_tests_failed\n"; - print "Not run tests: $man_tests_notrun\n"; +# print "Total number of tests: $man_tests_total\n"; +# print "Passed tests: $man_tests_passed\n"; +# print "Failed tests: $man_tests_failed\n"; +# print "Not run tests: $man_tests_notrun\n"; } # Check for Smoketest results in BRAG file. @@ -253,6 +327,51 @@ close FILE; print "$test_brag_xml saved\n"; +# Calculate Test BRAG Status (based on auto + manual) +$cases_total = $man_tests_total + $auto_tests_total; +$cases_passed = $man_tests_passed + $auto_tests_passed; +$cases_failed = $man_tests_failed + $auto_tests_failed; +$cases_not_run = $man_tests_notrun + $auto_tests_notrun; +$cases_not_available = $auto_tests_disabled; +if ($auto_tests_total > 0) { + $auto_pass_rate = ($auto_tests_passed / $auto_tests_total) * 100; +} else { + $auto_pass_rate = 0; +} +if ($cases_total > 0) { + $fail_rate = ($cases_failed / $cases_total) * 100; +} else { + $fail_rate = 0; +} +if ($cases_total == 0) { + $test_brag_status = "n/a"; +} elsif (($fail_rate > 0) && ($fail_rate <= 50)) { + $test_brag_status = "amber"; +} elsif ($fail_rate > 50) { + $test_brag_status = "red"; +} else { + $test_brag_status = "green"; +} +$auto_pass_rate = sprintf("%.1f", $auto_pass_rate); +# Generate bit file +if (-e $bit_file) { # Delete the file if exists. + unlink($bit_file); + print "$bit_file deleted\n"; +} +open (FILE, "> $bit_file") or die ("Couldn't open $bit_file for writing: $!\n"); +print FILE "test $name,$type,$test_target,$start_time,$end_time,$auto_tests_total,$auto_tests_passed,$auto_tests_failed,$auto_tests_notrun,$auto_tests_disabled,$auto_pass_rate\n"; +if ($test_brag_status ne "n/a") { print FILE "test_brag $test_brag_status\n"; } +print FILE "report Smoke Test Report,$report_url,report"; +close FILE; +print "$bit_file saved\n"; + +if (defined($build_id)) { + print "Updating BIT db... "; + my @args = ("perl", $bitops_path, "-u", $build_id, "-a", "-f", $bit_file); + system(@args) == 0 or die "system @args failed: $?"; + print "complete\n"; +} + exit 0; sub usage($) @@ -263,14 +382,15 @@ "Specify the BRAG xml file and ATS report\n" . "synopsis:\n" . " update_brag_status.pl --help\n" . - " update_brag_status.pl [--brag-file=XML_FILE] [--ats3-report=HTML_REPORT] [--ats4-report=SIMPLELOGGER_REPORT] [--test-report=XML_REPORT] \n" . + " update_brag_status.pl [--brag-file=XML_FILE] [--ats3-report=HTML_REPORT] [--ats4-report=SIMPLELOGGER_REPORT] [--test-report=XML_REPORT] [--build-id=ID]\n" . "options:\n" . " --help Display this help and exit.\n" . " --brag-file=XML_FILE XML_FILE is the full path to the file containing BRAG summary.\n" . " --ats3-report=HTML_REPORT HTML_REPORT is the full path to the ATS3 report.\n" . " --ats4-report=SIMPLELOGGER_REPORT SIMPLELOGGER_REPORT is the full path to the ATS4 report.\n" . " --test-report=XML_REPORT XML_REPORT is the name of the test report for manually executed tests.\n" . - " If not specified only automated tests results will be taken into account.\n"; + " If not specified only automated tests results will be taken into account.\n" . + " --build-id=ID ID is the id of the build which will be updated with the test results.\n"; exit $error; }