Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 302305 Details for
Bug 406201
3.10: Commandline utilities and cron jobs
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
cron script sanitycheck.pl
cronjob_sanitycheck (text/plain), 7.33 KB, created by
Noura El hawary
on 2008-04-14 04:11:31 UTC
(
hide
)
Description:
cron script sanitycheck.pl
Filename:
MIME Type:
Creator:
Noura El hawary
Created:
2008-04-14 04:11:31 UTC
Size:
7.33 KB
patch
obsolete
>Index: sanitycheck.pl >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/sanitycheck.pl,v >retrieving revision 1.2 >diff -p -u -r1.2 sanitycheck.pl >--- sanitycheck.pl 31 Jan 2008 17:48:09 -0000 1.2 >+++ sanitycheck.pl 14 Apr 2008 04:09:10 -0000 >@@ -18,6 +18,7 @@ > # Frédéric Buclin. All Rights Reserved. > # > # Contributor(s): Frédéric Buclin <LpSolit@gmail.com> >+# Noura Elhawary <nelhawar@redhat.com> > > use strict; > >@@ -32,15 +33,42 @@ use Bugzilla::Mailer; > use Getopt::Long; > use Pod::Usage; > >-my $verbose = 0; # Return all comments if true, else errors only. >-my $login = ''; # Login name of the user which is used to call sanitycheck.cgi. >-my $help = 0; # Has user asked for help on this script? >- >-my $result = GetOptions('verbose' => \$verbose, >- 'login=s' => \$login, >- 'help|h|?' => \$help); >+use English qw( -no_match_vars ); >+use Text::Diff; > >-pod2usage({-verbose => 1, -exitval => 1}) if $help; >+my $do_text_diff = 1; >+eval "use Text::Diff"; >+if ($@){ >+ warn $@; >+ $do_text_diff = 0; >+} >+ >+my $verbose = 0; # Return all comments if true, else errors only. >+my $login = ''; # Login name of the user which is used to call sanitycheck.cgi. >+my $help = 0; # Has user asked for help on this script? >+ >+my %options = ('verbose' => \$verbose, 'login' => \$login, 'help' => \$help); >+ >+my @OptionDefs = ( >+ 'foreign_keys', 'profile_loginnames', >+ 'keyword_cache', 'general_bug_check', >+ 'control_values', 'unsent_emails', >+ 'flag_check', 'diff_report'); >+ >+# check options >+my @Checks = qw( >+ foreign_keys >+ profile_loginnames >+ keyword_cache >+ general_bug_check >+ control_values >+ unsent_emails >+ flag_check >+); >+ >+GetOptions(\%options, 'verbose', 'login=s', 'help|h|?', @OptionDefs); >+ >+pod2usage({ -verbose => 1, -exitval => 1 }) if $help; > > Bugzilla->usage_mode(USAGE_MODE_CMDLINE); > >@@ -56,25 +84,113 @@ my $template = Bugzilla->template; > # Authenticate using this user account. > Bugzilla->set_user($user); > >+# build check list >+my @checks; >+for my $check (@Checks) { >+ if ( $options{$check} ) { >+ $cgi->param( $check, 1 ); >+ push @checks, $check; >+ } >+} >+ >+# if no checks given on command line then assume all checks >+if (@checks == 0) { >+ push @checks, @Checks; >+ $cgi->param($_, 1) foreach @checks; >+} >+ >+# run checks and report >+my $msg_body = ''; # accumulate check reports here >+ > # Pass this param to sanitycheck.cgi. > $cgi->param('verbose', $verbose); > > require 'sanitycheck.cgi'; > >-# Now it's time to send an email to the user if there is something to notify. >-if ($cgi->param('output')) { >+for my $check (@checks) { >+ >+ my $out_rpt = $check . "_report"; >+ >+ # Now it's time to send an email to the user if there is something to notify. > my $message; > my $vars = {}; > $vars->{'addressee'} = $user->email; >- $vars->{'output'} = $cgi->param('output'); >+ $vars->{'output'} = $cgi->param($out_rpt); > $vars->{'error_found'} = $cgi->param('error_found') ? 1 : 0; > > $template->process('email/sanitycheck.txt.tmpl', $vars, \$message) > || ThrowTemplateError($template->error()); > >- MessageToMTA($message); >+ # full_report if given then report in case of FAIL or PASS >+ # otherwise only report in case of FAIL >+ if ($options{diff_report} && $do_text_diff) { >+ $msg_body .= create_diff_report($check, $message); >+ } >+ else { >+ $msg_body .= create_report($check, $message); >+ } >+} >+ >+if (Bugzilla->params->{mail_delivery_method} eq 'None') { >+ print "$msg_body\n"; >+} >+else { >+ MessageToMTA($msg_body); >+} >+ >+# returns string report >+sub create_report { >+ my ($check, $rpt) = @_; >+ >+ my $check_rpt = >+ "Check: $check\n====================================" >+ . "===============================\n$rpt\n"; >+ >+ return $check_rpt; >+} >+ >+# returns empty string '' if no difference, otherwise a string representing the diff report >+sub create_diff_report { >+ my ($check, $rpt) = @_; >+ >+ my $report = create_report($check, $rpt); >+ >+ my $baseline_fn = $check . ".orig"; >+ >+ $baseline_fn = "data/sanitycheck/$baseline_fn"; >+ >+ if (not -e $baseline_fn) { >+ create_report_file($baseline_fn, $report); >+ return ''; >+ } >+ >+ # write the current report to a file to diff it against >+ # the baseline report >+ my $rpt_file = 'rpt_tmp_file'; >+ create_report_file($rpt_file, $report); >+ >+ my $diff = diff $baseline_fn, $rpt_file; >+ >+ if ($diff) { >+ return "Difference Check: $check\n" >+ . "===================================================================\n" >+ . "$diff\n\n"; >+ } >+ >+ unlink $rpt_file; >+ return ''; > } > >+sub create_report_file { >+ >+ my ($file_name, $report) = @_; >+ open my $FILE, ">", $file_name >+ or die "Couldn't open '$file_name' : $OS_ERROR"; >+ print {$FILE} $report >+ or die "Couldn't write to '$file_name': $OS_ERROR"; >+ close $FILE or die "Couldn't close '$file_name': $OS_ERROR"; >+ >+} > > __END__ > >@@ -86,6 +202,8 @@ sanitycheck.pl - Perl script to perform > > ./sanitycheck.pl [--help] > ./sanitycheck.pl [--verbose] --login <user@domain.com> >+ ./sanitycheck.pl [check_name] --login <user@domain.com> >+ ./sanitycheck.pl [check_name] [--diff_report] --login <user@domain.com> > > =head1 OPTIONS > >@@ -107,10 +225,70 @@ This should be passed the email address > running the Sanity Check process, a user with the editcomponents priv. This > user will receive an email with the results of the script run. > >+=item B<--diff_report> >+ >+Generates only diff report for checks by comparing freshly generated check report >+with stored report for that check. >+ >+=item B<check_name> >+ >+This can be any one of the following checknames or a combination of them: >+ >+=over >+ >+=item B<--foreign_keys> >+ >+Performs referential integrity checks (cross and double cross). >+ >+=item B<--profile_loginname> >+ >+Performs login email checks for format and lowercase. >+ >+=item B<--keyword_cache> >+ >+Performs vote/keyword cache checks. >+ >+=item B<--general_bug_check> >+ >+Performs general bug checks ex: resolutions, statuses etc. >+ >+=item B<--control_values> >+ >+Performs group control values are validation check. >+ >+=item B<--unsent_emails> >+ >+Performs checks for bugs that have changes but no mail sent for at least half an hour. >+ >+=item B<--flag_check> >+ >+Check for flags being in incorrect products and components. >+ >+=back >+ > =back > > =head1 DESCRIPTION > > This script provides a way of running a 'Sanity Check' on the database > via either a CLI or cron. It is equivalent to calling sanitycheck.cgi >-via a web broswer. >+via a web broswer with an extra feature for generating diff sanitycheck >+reports. If the user specified the checks they want to perform then only >+those checks will be performed, otherwise all checks will be performed. >+ >+The generated check reports can be of three types: >+ >+"full reports" >+ that include errors as well as successful checks, to get >+ those the --verbose option must be set. >+ >+"fail reports" >+ that include only errors in the reports, to get those >+ the --verbose must be ignored. >+ >+"diff reports" >+ to produce diff check reports. freshly generated reports >+ are diffed against original ones kept in the data/sanitycheck >+ dir and the result is the desired diff reports. to get those >+ the --diff_report option must be set. >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 406201
:
300010
|
302304
|
302305
|
302344