From c4899348010b42f849999ec1764c0a192cc5760d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Mon, 7 Nov 2011 14:31:47 +0000 Subject: [PATCH] Regression test SB #88502 & more --- org.glite.testsuites.ctb/LB/tests/lb-test-purge.pl | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/org.glite.testsuites.ctb/LB/tests/lb-test-purge.pl b/org.glite.testsuites.ctb/LB/tests/lb-test-purge.pl index 6241b7a..df3639b 100755 --- a/org.glite.testsuites.ctb/LB/tests/lb-test-purge.pl +++ b/org.glite.testsuites.ctb/LB/tests/lb-test-purge.pl @@ -106,6 +106,10 @@ sub test_failed() { if ($html_output) { printf ("-TEST FAILED-
\n"); } else { print_result ('bold red','-TEST FAILED-'); } } +sub test_skipped() { + if ($html_output) { printf ("skipped
\n"); } + else { print_result ('bold yellow','skipped'); } +} sub test_printf { if ($html_output) { printf("
"); } printf "@_\n"; @@ -303,6 +307,50 @@ for (values(%old),values(%new)) { die "EIDRM or state Purged should have been returned for zombies\n" if $failed; +test_printf ("** Check purge by cron"); + +#Trying purger log +$sudoerr=system("sudo -n /bin/cat /etc/cron.d/glite-lb-purge.cron | grep -E \"^[0-9,\\-\\*]\\s[0-9,\\-\\*]\\s[0-9,\\-\\*]\\s[0-9,\\-\\*]\\s[0-9,\\-\\*]\" > /tmp/glite-lb-purge.cron.$$"); +if($sudoerr) { + printf "user not allowed to 'sudo'"; + test_skipped(); +} +else { + printf("\nChecking if purge by cron has been set up at all... "); + $purgecronlines = `cat /tmp/glite-lb-purge.cron.$$ | wc -l`; + if ($purgecronlines > 0) { + test_done(); + } + else { + test_failed(); + die "Purging by cron not set up"; + } + + printf("Checking for Common Logging Format headers in cron logfile (Regression into bug #88502)...\n"); + # Store old crontab + system("crontab -l > /tmp/crontab.glite.$$ 2> /dev/null"); + + # Add a new crontab line, change frequency to max. and output to tmp + system("cat /tmp/glite-lb-purge.cron.$$ | sed 's/^[0-9,\\-\\*]\\s[0-9,\\-\\*]\\s[0-9,\\-\\*]\\s[0-9,\\-\\*]\\s[0-9,\\-\\*]/\* \* \* \* \*/' | sed 's/\\/var\\/log\\/glite\\/glite-lb-purger.log/\\/tmp\\/lite-lb-purger.log.$$/g' | crontab"); + + #Give cron time to make a run + system("sleep 60"); + + #Check for expected format + $datepresent=system("grep -E -o '^[a-zA-Z]+\\s+[0-9]+\\s+[0-9]+:[0-9]+:[0-9]+\\s+[a-zA-Z]+\\s+[a-zA-Z0-9.\\-]+:' /tmp/lite-lb-purger.log.$$"); + if ($datepresent) { + test_failed(); + die "Common Logging Format headers not found in the log file."; + } + else { + test_done(); + } + + #Reinstate old crontab + system("cat /tmp/crontab.glite.$$ | crontab"); +} +system("rm -f /tmp/glite-lb-purge.cron.$$ /tmp/crontab.glite.$$ /tmp/lite-lb-purger.log.$$"); + test_printf ("\n** All tests passed **"); test_done(); exit 0; -- 1.8.2.3