Commit b7ca8b8b authored by Eric Cano's avatar Eric Cano
Browse files

bug #72215: Remove the TAPEGATEWAYREQUEST table from the schema, and drop the...

bug #72215: Remove the TAPEGATEWAYREQUEST table from the schema, and drop the triggers that populate it.

 Various improvements in the test script:

- Tighter control of the parameters of mighunterd
- Factorized the loop checking with timeout for all migrations.
- Created additionnal functions to recompile and check invalid status.
parent 0789a755
......@@ -52,6 +52,9 @@ my $tstDir = 'test/tapegateway_release_tests';
sub open_db();
sub check_leftoevers( $ );
sub print_leftovers ( $ );
sub print_leftovers_poll_timeout ( $$$ );
sub check_broken_compilation ( $ );
sub massage_compilation ( $ );
sub nullize_arrays_undefs ( $ );
sub main();
# Imported funtions from Steve's test script
......@@ -140,6 +143,19 @@ sub check_leftovers ( $ )
return $row[0];
}
# check_leftovers_poll_timeout: loop poll
sub check_leftovers_poll_timeout ( $$$ )
{
my ( $dbh, $interval, $timeout ) = ( shift, shift, shift );
my $start_time = `date +%s`;
while (check_leftovers($dbh)) {
if (`date +%s`> $start_time + $timeout) {
return 1;
}
}
return 0;
}
# print_leftovers
sub print_leftovers ( $ )
{
......@@ -170,6 +186,35 @@ sub print_leftovers ( $ )
}
}
# check_leftovers : find wether there are any leftover unmigrated data in the stager
sub check_broken_compilation ( $ )
{
my $dbh = shift;
my $sth = $dbh -> prepare ("SELECT count (*) FROM user_objects ".
" WHERE object_type IN ('FUNCTION', 'PROCEDURE')".
" AND status = 'INVALID'");
$sth -> execute();
my @row = $sth->fetchrow_array();
return $row[0];
}
# massage_compilation: tell oracle to re-compile whatever is in an invalid state
sub massage_compilation ( $ )
{
my $dbh = shift;
my $sth = $dbh -> prepare ("BEGIN".
" FOR obj in (".
" SELECT *".
" FROM user_objects".
" WHERE".
" object_type IN ('FUNCTION', 'PROCEDURE')".
" AND status = 'INVALID' AND object_name NOT LIKE 'TG_%') LOOP".
" EXECUTE IMMEDIATE 'ALTER ' || obj.object_type || ' ' || obj.object_name || ' COMPILE';".
" END LOOP;".
"END;");
$sth -> execute();
}
# Replace undef members of an array by the string NULL
sub nullize_arrays_undefs ( $ )
{
......@@ -878,28 +923,52 @@ sub goodDaySingleAndDualCopyTest ()
# MAIN PROGRAM STARTS HERE
################################################################################
# Make sur the mighunter will run with low latency and for each service class
print `perl -p -i -e 'if (/MIGHUNTERD_OPTIONS|SVCCLASSES/) { \$_ = ""; }' /etc/sysconfig/mighunterd`;
print `echo "MIGHUNTERD_OPTIONS='-t 5'" >> /etc/sysconfig/mighunterd`;
print `echo "SVCCLASSES='dev default'" >> /etc/sysconfig/mighunterd`;
# Clean up for potential leftovers:
startDaemons();
print "Cleaning up test directories /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_{single,dual}_tape_copy_files\n";
print `su canoc3 -c "for p in /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_{single,dual}_tape_copy_files; do nsrm -r -f \\\$p; done"`;
# Open the DB access
my $dbh=open_db();
# Wait for stager emptiness with timeout
if ( check_leftovers_poll_timeout ( $dbh, 2, 60 )) {
print "Timeout expired for initial cleanup of files.";
print_leftovers ($dbh);
die;
}
wipeAndRecreateDefaultLxcastodev03();
startDaemons();
# Re-create the directories:
print `su canoc3 -c "nsmkdir /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_single_tape_copy_files"`;
print `su canoc3 -c "nschclass largeuser /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_single_tape_copy_files"`;
print `su canoc3 -c "nsmkdir /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_dual_tape_copy_files"`;
print `su canoc3 -c "nschclass test2 /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_dual_tape_copy_files"`;
open CMD, 'su canoc3 -c "( cd '.$checkout_location.'; pwd;'.
'sh test/tapegateway_release_tests/createAndCopyFilesToCastor.sh lxcastordev03 dev lxcastorsrv101 /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_single_tape_copy_files 100 2;'.
'sh test/tapegateway_release_tests/createAndCopyFilesToCastor.sh lxcastordev03 dev lxcastorsrv101 /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_dual_tape_copy_files 100 2; )" |';
while (<CMD>) {
print $_;
}
my $dbh=open_db();
my $timeout = 10*60;
my $start_time=`date +%s`;
while (check_leftovers($dbh)) {
if (`date +%s`> $start_time + $timeout) {
print "Timeout expired for migration of files.";
print_leftovers ($dbh);
die;
}
sleep(5);
if ( check_leftovers_poll_timeout ( $dbh, 5, 60*10 )) {
print "Timeout expired for migration of files.";
print_leftovers ($dbh);
die;
}
migrateToNewTapeGatewaySchema ();
massage_compilation($dbh);
if ( check_broken_compilation($dbh) ) { die "Compilation in a broken state."; }
startDaemons ();
open CMD, 'su canoc3 -c "( cd '.$checkout_location.'; pwd;'.
'sh test/tapegateway_release_tests/createAndCopyFilesToCastor.sh lxcastordev03 dev lxcastorsrv101 /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_single_tape_copy_files 100 2;'.
......@@ -907,18 +976,15 @@ open CMD, 'su canoc3 -c "( cd '.$checkout_location.'; pwd;'.
while (<CMD>) {
print $_;
}
$timeout = 10*60;
$start_time=`date +%s`;
while (check_leftovers($dbh)) {
if (`date +%s` > $start_time + $timeout) {
print "Timeout expired for migration of files.";
print_leftovers ($dbh);
die;
}
sleep(5);
if ( check_leftovers_poll_timeout ( $dbh, 5, 60*10 )) {
print "Timeout expired for migration of files.";
print_leftovers ($dbh);
die;
}
stopAndSwitchToTapeGatewayd($dbh);
if ( check_broken_compilation($dbh) ) { die "Compilation in a broken state."; }
startDaemons ();
open CMD, 'su canoc3 -c "( cd '.$checkout_location.'; pwd;'.
'sh test/tapegateway_release_tests/createAndCopyFilesToCastor.sh lxcastordev03 dev lxcastorsrv101 /castor/cern.ch/dev/c/canoc3/migrate_and_recall_10_single_tape_copy_files 100 2;'.
......@@ -926,15 +992,10 @@ open CMD, 'su canoc3 -c "( cd '.$checkout_location.'; pwd;'.
while (<CMD>) {
print $_;
}
$timeout = 10*60;
$start_time=`date +%s`;
while (check_leftovers($dbh)) {
if (`date +%s` > $start_time + $timeout) {
print "Timeout expired for migration of files.";
print_leftovers ($dbh);
die;
}
sleep(5);
if ( check_leftovers_poll_timeout ( $dbh, 5, 60*10 )) {
print "Timeout expired for migration of files.";
print_leftovers ($dbh);
die;
}
$dbh->disconnect();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment