Commit e3f1d87a 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.

Added check and removal of the busy status between runs of stagers. The tapegateway just drops everything as it is on shutdown, including tapes in busy state.
Cosmetic changes.
Indetation fixing.
Various stuff.
parent c8f08de2
......@@ -74,6 +74,7 @@ our @export = qw(
print_leftovers
getOrastagerconfigParam
cleanup
elapsed_time
); # Symbols to autoexport (:DEFAULT tag)
# keep track of the locally created files and of the recalled and locally rfcped files.
......@@ -87,6 +88,20 @@ my %environment = (
allowed_stagers => [ 'lxcastordev03', 'lxcastordev04' ]
);
my $time_reference;
# Elapsed time since first call which implicitly sets the reference moment
sub elapsed_time ()
{
if ( defined $time_reference ) {
return `date +%s` - $time_reference;
} else {
$time_reference = `date +%s`;
chomp $time_reference;
return 0;
}
}
# Set the user name in the environment
sub read_config ( $ )
{
......@@ -95,7 +110,7 @@ sub read_config ( $ )
chomp $local_host;
$environment{hostname} = $local_host;
my @per_host_vars = ( 'username', 'checkout_location', 'file_size', 'file_number', 'castor_directory',
'migration_timeout', 'poll_interval');
'migration_timeout', 'poll_interval', 'tapepool');
my @global_vars = ( 'dbDir' , 'tstDir', 'stageUid', 'stageGid', 'adminList',
'originalDbSchema', 'originalDropSchema', 'castor_single_subdirectory',
'castor_dual_subdirectory' );
......@@ -190,55 +205,55 @@ sub poll_fileserver_readyness ( $$ )
# Take 1 parameter: the size in
sub make_seed ( $ )
{
my $size = shift;
((defined $size) || ($size < 0)) or die "In $package_name::make_seed: size not defined";
my $file_name = `mktemp`;
chomp $file_name;
my $megs = int ($size/(1024*1024));
my $kilos = int (($size%(1024*1024))/1024);
my $bytes = $size % 1024;
my $kflags="";
my $bflags="";
print "Creating seed file $file_name\n";
my $starttime = `date +%s`;
if ($megs != 0) {
`dd if=/dev/urandom of=$file_name bs=1M count=$megs`;
$kflags=" oflag=append conv=notrunc";
$bflags=" oflag=append conv=notrunc";
}
if ($kilos != 0) {
`dd if=/dev/urandom of=$file_name bs=1K count=$kilos $kflags`;
$bflags=" oflag=append conv=notrunc";
}
if ($bytes != 0) {
`dd if=/dev/urandom of=$file_name bs=1 count=$bytes $bflags`;
}
# Check that everything went fine
if (!-e $file_name) {
die "In $package_name::make_seed: file $file_name not created";
}
if (! (-s $file_name) == $size) {
die "In $package_name::make_seed: file $file_name created with wrong size";
}
my $endtime = `date +%s`;
print "Seed file created in ".($endtime - $starttime)."s. Speed=".
($size/(1024*1024)/($endtime - $starttime))."\n";
# Hand over the file to the user
print `chown $environment{'username'} $file_name`;
# We call it good enough
my $checksum = `adler32 $file_name 2>&1`;
chomp ($checksum);
my %file_entry = ( 'name' => $file_name,
'size' => $size,
my $size = shift;
((defined $size) || ($size < 0)) or die "In $package_name::make_seed: size not defined";
my $file_name = `mktemp`;
chomp $file_name;
my $megs = int ($size/(1024*1024));
my $kilos = int (($size%(1024*1024))/1024);
my $bytes = $size % 1024;
my $kflags="";
my $bflags="";
print "t=".elapsed_time()."s. Creating seed file $file_name\n";
my $starttime = `date +%s`;
if ($megs != 0) {
`dd if=/dev/urandom of=$file_name bs=1M count=$megs 2>&1`;
$kflags=" oflag=append conv=notrunc";
$bflags=" oflag=append conv=notrunc";
}
if ($kilos != 0) {
`dd if=/dev/urandom of=$file_name bs=1K count=$kilos $kflags 2>&1`;
$bflags=" oflag=append conv=notrunc";
}
if ($bytes != 0) {
`dd if=/dev/urandom of=$file_name bs=1 count=$bytes $bflags 2>&1`;
}
# Check that everything went fine
if (!-e $file_name) {
die "In $package_name::make_seed: file $file_name not created";
}
if (! (-s $file_name) == $size) {
die "In $package_name::make_seed: file $file_name created with wrong size";
}
my $endtime = `date +%s`;
print "t=".elapsed_time()."s. Seed file created in ".($endtime - $starttime)."s. Speed=".
($size/(1024*1024)/($endtime - $starttime))."MB/s.\n";
# Hand over the file to the user
print `chown $environment{'username'} $file_name`;
# We call it good enough
my $checksum = `adler32 $file_name 2>&1`;
chomp ($checksum);
my %file_entry = ( 'name' => $file_name,
'size' => $size,
'adler32' => $checksum);
my $file_index = push @local_files, \%file_entry;
$file_index --;
return $file_index;
my $file_index = push @local_files, \%file_entry;
$file_index --;
return $file_index;
}
......@@ -247,21 +262,21 @@ sub make_seed ( $ )
#
sub make_localfile ( $$ )
{
my ($seed_index, $file_name) = ( shift, shift );
open NEW_FILE, "> $file_name" or die "In $package_name::make_localfile: failed to open $file_name for writing: $!";
print NEW_FILE "$file_name";
close NEW_FILE;
`dd if=$local_files[$seed_index]->{'name'} of=$file_name bs=1M oflag=append conv=notrunc 2>&1`;
my $checksum = `adler32 $file_name 2>&1`;
chomp ($checksum);
my $size = ( -s $file_name );
my %file_entry = ( 'name' => $file_name,
'size' => $size,
'adler32' => $checksum);
my $file_index = push @local_files, \%file_entry;
$file_index --;
print "Created local file $file_name\n";
return $file_index;
my ($seed_index, $file_name) = ( shift, shift );
open NEW_FILE, "> $file_name" or die "In $package_name::make_localfile: failed to open $file_name for writing: $!";
print NEW_FILE "$file_name";
close NEW_FILE;
`dd if=$local_files[$seed_index]->{'name'} of=$file_name bs=1M oflag=append conv=notrunc 2>&1`;
my $checksum = `adler32 $file_name 2>&1`;
chomp ($checksum);
my $size = ( -s $file_name );
my %file_entry = ( 'name' => $file_name,
'size' => $size,
'adler32' => $checksum);
my $file_index = push @local_files, \%file_entry;
$file_index --;
print "t=".elapsed_time()."s. Created local file $file_name\n";
return $file_index;
}
# remote files statuses:
......@@ -292,8 +307,12 @@ sub rfcp_localfile ( $$ )
'adler32' => $local_files[$local_index]->{adler32},
'status' => 'rfcped' );
push @remote_files, \%remote_entry;
print "rtcp'ed $local => $remote:\n";
print $rfcp_ret;
print "t=".elapsed_time()."s. rtcp'ed $local => $remote:\n";
for ( split /^/, $rfcp_ret ) {
if ( ! /bytes in/ ) {
print $_."\n";
}
}
}
# Check remote entries: check presence (should be always true) and then status of all files listed in remote files list
......@@ -312,7 +331,7 @@ sub check_remote_entries ()
if ( $entry{type} eq "file" ) {
if ( $entry{status} eq "rfcped" ) {
if ( check_migrated ( $entry{name} ) ) {
print "File ".$entry{name}." now migrated to tape.\n";
print "t=".elapsed_time()."s. File ".$entry{name}." now migrated to tape.\n";
$remote_files[$i]->{status} = "migrated";
$changed_entries ++;
}
......@@ -341,7 +360,7 @@ sub poll_moving_entries ( $$ )
my $starttime = `date +%s`;
while ( count_to_be_migrated() > 0 && ((`date +%s` - $starttime) < $timeout) ) {
if ( check_remote_entries () ) {
print "Saw at least one migration...\n";
print "t=".elapsed_time()."s. Saw at least one new migration...\n";
$starttime = `date +%s`;
}
sleep ( $poll_interval );
......@@ -1061,51 +1080,51 @@ sub wipeAndRecreateDefaultLxcastodev03 ()
`sed -i s/\\&adminList/$adminList/g $hacked_creation`;
executeSQLPlusScript ( $dbUser, $dbPasswd, $dbName,
$hacked_creation, "Re-creating schema");
unlink $hacked_creation;
# Restart the demons
`/etc/init.d/jobmanagerd start`;
#`/etc/init.d/mighunterd start`;
`/etc/init.d/rechandlerd start`;
`/etc/init.d/rhd start`;
`/etc/init.d/rmmasterd start`;
#`/etc/init.d/rtcpclientd start`;
`/etc/init.d/stagerd start`;
#`/etc/init.d/tapegatewayd start`;
my $sleepPeriod = 2;
print("Sleeping $sleepPeriod seconds\n");
sleep($sleepPeriod);
my $rmGetNodesResult = `rmGetNodes | egrep 'name:'`;
print("\n");
print("rmGetNodes RESULTS\n");
print("==================\n");
print($rmGetNodesResult);
# Fill database with the standard set-up for a dev-box
`nslistclass | grep NAME | awk '{print \$2}' | xargs -i enterFileClass --Name {} --GetFromCns`;
`enterSvcClass --Name default --DiskPools default --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes --NbDrives 1 --TapePool stager_dev03 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
`enterSvcClass --Name dev --DiskPools extra --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes`;
`enterSvcClass --Name diskonly --DiskPools extra --ForcedFileClass temp --DefaultFileSize 10485760 --Disk1Behavior yes --FailJobsWhenNoSpace yes`;
`moveDiskServer default lxc2disk05.cern.ch`;
`moveDiskServer extra lxc2disk06.cern.ch`;
`rmAdminNode -r -R -n lxc2disk05.cern.ch`;
`rmAdminNode -r -R -n lxc2disk06.cern.ch`;
# Add a tape-pool to dev service-class ready for shared tape-pool tests
`modifySvcClass --Name dev --AddTapePool stager_dev03_2 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
# Set the number of drives on the default and dev service-classes to desired number for each
`modifySvcClass --Name default --NbDrives 1`;
`modifySvcClass --Name dev --NbDrives 2`;
`modifySvcClass --Name dev --AddTapePool stager_dev03_2`;
$dbh->disconnect();
undef $dbh;
unlink $hacked_creation;
# Restart the demons
`/etc/init.d/jobmanagerd start`;
#`/etc/init.d/mighunterd start`;
`/etc/init.d/rechandlerd start`;
`/etc/init.d/rhd start`;
`/etc/init.d/rmmasterd start`;
#`/etc/init.d/rtcpclientd start`;
`/etc/init.d/stagerd start`;
#`/etc/init.d/tapegatewayd start`;
my $sleepPeriod = 2;
print("Sleeping $sleepPeriod seconds\n");
sleep($sleepPeriod);
my $rmGetNodesResult = `rmGetNodes | egrep 'name:'`;
print("\n");
print("rmGetNodes RESULTS\n");
print("==================\n");
print($rmGetNodesResult);
# Fill database with the standard set-up for a dev-box
`nslistclass | grep NAME | awk '{print \$2}' | xargs -i enterFileClass --Name {} --GetFromCns`;
`enterSvcClass --Name default --DiskPools default --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes --NbDrives 1 --TapePool stager_dev03 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
`enterSvcClass --Name dev --DiskPools extra --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes`;
`enterSvcClass --Name diskonly --DiskPools extra --ForcedFileClass temp --DefaultFileSize 10485760 --Disk1Behavior yes --FailJobsWhenNoSpace yes`;
`moveDiskServer default lxc2disk05.cern.ch`;
`moveDiskServer extra lxc2disk06.cern.ch`;
`rmAdminNode -r -R -n lxc2disk05.cern.ch`;
`rmAdminNode -r -R -n lxc2disk06.cern.ch`;
# Add a tape-pool to dev service-class ready for shared tape-pool tests
`modifySvcClass --Name dev --AddTapePool stager_dev03_2 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
# Set the number of drives on the default and dev service-classes to desired number for each
`modifySvcClass --Name default --NbDrives 1`;
`modifySvcClass --Name dev --NbDrives 2`;
`modifySvcClass --Name dev --AddTapePool stager_dev03_2`;
$dbh->disconnect();
undef $dbh;
}
# Wipes and recreates the DB for lxcastordev04 (with a check to prevent wiping of unmigrated files
......@@ -1183,51 +1202,51 @@ sub wipeAndRecreateDefaultLxcastodev04 ()
`sed -i s/\\&adminList/$adminList/g $hacked_creation`;
executeSQLPlusScript ( $dbUser, $dbPasswd, $dbName,
$hacked_creation, "Re-creating schema");
unlink $hacked_creation;
# Restart the demons
`/etc/init.d/jobmanagerd start`;
#`/etc/init.d/mighunterd start`;
`/etc/init.d/rechandlerd start`;
`/etc/init.d/rhd start`;
`/etc/init.d/rmmasterd start`;
#`/etc/init.d/rtcpclientd start`;
`/etc/init.d/stagerd start`;
#`/etc/init.d/tapegatewayd start`;
my $sleepPeriod = 2;
print("Sleeping $sleepPeriod seconds\n");
sleep($sleepPeriod);
my $rmGetNodesResult = `rmGetNodes | egrep 'name:'`;
print("\n");
print("rmGetNodes RESULTS\n");
print("==================\n");
print($rmGetNodesResult);
# Fill database with the standard set-up for a dev-box
`nslistclass | grep NAME | awk '{print \$2}' | xargs -i enterFileClass --Name {} --GetFromCns`;
`enterSvcClass --Name default --DiskPools default --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes --NbDrives 1 --TapePool stager_dev04 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
`enterSvcClass --Name dev --DiskPools extra --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes`;
`enterSvcClass --Name diskonly --DiskPools extra --ForcedFileClass temp --DefaultFileSize 10485760 --Disk1Behavior yes --FailJobsWhenNoSpace yes`;
`moveDiskServer default lxc2disk05.cern.ch`;
`moveDiskServer extra lxc2disk06.cern.ch`;
`rmAdminNode -r -R -n lxc2disk05.cern.ch`;
`rmAdminNode -r -R -n lxc2disk06.cern.ch`;
# Add a tape-pool to dev service-class ready for shared tape-pool tests
###`modifySvcClass --Name dev --AddTapePool stager_dev03_2 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
# Set the number of drives on the default and dev service-classes to desired number for each
###`modifySvcClass --Name default --NbDrives 1`;
###`modifySvcClass --Name dev --NbDrives 2`;
###`modifySvcClass --Name dev --AddTapePool stager_dev03_2`;
$dbh->disconnect();
undef $dbh;
unlink $hacked_creation;
# Restart the demons
`/etc/init.d/jobmanagerd start`;
#`/etc/init.d/mighunterd start`;
`/etc/init.d/rechandlerd start`;
`/etc/init.d/rhd start`;
`/etc/init.d/rmmasterd start`;
#`/etc/init.d/rtcpclientd start`;
`/etc/init.d/stagerd start`;
#`/etc/init.d/tapegatewayd start`;
my $sleepPeriod = 2;
print("Sleeping $sleepPeriod seconds\n");
sleep($sleepPeriod);
my $rmGetNodesResult = `rmGetNodes | egrep 'name:'`;
print("\n");
print("rmGetNodes RESULTS\n");
print("==================\n");
print($rmGetNodesResult);
# Fill database with the standard set-up for a dev-box
`nslistclass | grep NAME | awk '{print \$2}' | xargs -i enterFileClass --Name {} --GetFromCns`;
`enterSvcClass --Name default --DiskPools default --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes --NbDrives 1 --TapePool stager_dev04 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
`enterSvcClass --Name dev --DiskPools extra --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes`;
`enterSvcClass --Name diskonly --DiskPools extra --ForcedFileClass temp --DefaultFileSize 10485760 --Disk1Behavior yes --FailJobsWhenNoSpace yes`;
`moveDiskServer default lxc2disk05.cern.ch`;
`moveDiskServer extra lxc2disk06.cern.ch`;
`rmAdminNode -r -R -n lxc2disk05.cern.ch`;
`rmAdminNode -r -R -n lxc2disk06.cern.ch`;
# Add a tape-pool to dev service-class ready for shared tape-pool tests
###`modifySvcClass --Name dev --AddTapePool stager_dev03_2 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
# Set the number of drives on the default and dev service-classes to desired number for each
###`modifySvcClass --Name default --NbDrives 1`;
###`modifySvcClass --Name dev --NbDrives 2`;
###`modifySvcClass --Name dev --AddTapePool stager_dev03_2`;
$dbh->disconnect();
undef $dbh;
}
......@@ -1315,11 +1334,12 @@ sub cleanup () {
print "Cleanup: removing ".$_->{name}."\n";
unlink $_->{name};
}
use Data::Dumper;
print Dumper \@remote_files;
for my $i ( scalar ( @remote_files ) - 1 .. 0 ) {
#reverse order files removal to removes directories in the end.
if ($remote_files[$i]->{type} eq "file") {
#use Data::Dumper;
#print Dumper \@remote_files;
for ( my $i =scalar ( @remote_files ) - 1 ; $i >= 0; $i-- ) {
#reverse order remotees removal to removes directories in the end.
print "Cleanup: removing ".$remote_files[$i]->{name}."\n";
if ($remote_files[$i]->{type} eq "file") {
`su $environment{username} -c \"stager_rm -M $remote_files[$i]->{name}\"`;
}
`su $environment{username} -c \"nsrm $remote_files[$i]->{name}\"`;
......
......@@ -8,6 +8,7 @@ TAPETEST file_number_lxcastordev03 2
TAPETEST castor_directory_lxcastordev03 /castor/cern.ch/dev/c/canoc3/
TAPETEST migration_timeout_lxcastordev03 600
TAPETEST poll_interval_lxcastordev03 5
TAPETEST tapepool_lxcastordev03 stager_dev03_2
TAPETEST username_lxcastordev04 murrayc3
TAPETEST checkout_location_lxcastordev04 /var/some_checkout
......@@ -16,6 +17,7 @@ TAPETEST file_number_lxcastordev04 10
TAPETEST castor_directory_lxcastordev04 /castor/cern.ch/dev/c/murrayc3/
TAPETEST migration_timeout_lxcastordev04 600
TAPETEST poll_interval_lxcastordev04 5
TAPETEST tapepool_lxcastordev04 stager_dev04
# General parameters
......
......@@ -57,6 +57,8 @@ main();
sub main ()
{
# Initialize: setup the environment
print "t=".CastorTapeTests::elapsed_time()."s. ";
print `date`;
my $conffile = './tapetests-lxcastordev.conf';
CastorTapeTests::read_config($conffile);
CastorTapeTests::check_environment ();
......@@ -72,23 +74,28 @@ sub main ()
my $ret = 0;
if (CastorTapeTests::check_leftovers ( $dbh )) {
my $userless; # workaround to prevent emacs from fscking the indentation.
CastorTapeTests::print_leftovers ( $dbh );
#CastorTapeTests::print_leftovers ( $dbh );
$dbh->disconnect();
exit 1;
die "Leftovers found in the database. Aborting test.";
}
$dbh->disconnect();
# Nuke and start clean
my $host = `hostname -s`; chomp $host;
if ( $host eq 'lxcastordev03' ) {
my $u;
print "t=".CastorTapeTests::elapsed_time."s. ";
print "Wiping the DB for a run of rtcpclientd with classic schema =============\n";
CastorTapeTests::wipeAndRecreateDefaultLxcastodev03();
} elsif ( $host eq 'lxcastordev04' ) {
my $u;
print "t=".CastorTapeTests::elapsed_time."s. ";
print "Wiping the DB for a run of rtcpclientd with classic schema =============\n";
CastorTapeTests::wipeAndRecreateDefaultLxcastodev04();
} else {
die "Unexpected host.";
}
print "t=".CastorTapeTests::elapsed_time."s\n";
my $seed_index = CastorTapeTests::make_seed ($file_size);
# Test with the old system
......@@ -107,10 +114,12 @@ sub main ()
CastorTapeTests::register_remote ( $castor_directory.$dual_subdir, "directory" );
# Let the dust settle
print "t=".CastorTapeTests::elapsed_time."s\n";
CastorTapeTests::poll_fileserver_readyness (5,60);
# First iteration of the test
print "t=".CastorTapeTests::elapsed_time."s\n";
goodDaySingleAndDualCopyTest ($seed_index, $file_number);
badDayTests ($seed_index, $file_number);
preparePreTransitionBacklog ($seed_index, $file_number);
......@@ -120,6 +129,7 @@ sub main ()
CastorTapeTests::migrateToNewTapeGatewaySchema ();
CastorTapeTests::stopAndSwitchToRtcpclientd ( $dbh );
CastorTapeTests::startDaemons();
print "t=".CastorTapeTests::elapsed_time."s. ";
print "Switched to new schema with rtcpclientd =============\n";
# Second iteration of the test
......@@ -131,6 +141,7 @@ sub main ()
# Switch to tape gateway
CastorTapeTests::stopAndSwitchToTapeGatewayd ( $dbh );
CastorTapeTests::startDaemons();
print "t=".CastorTapeTests::elapsed_time."s. ";
print "Switched to tapegatewayd ============================\n";
# Third iteration of the test
......@@ -142,6 +153,7 @@ sub main ()
# Switch back to tape gateway.
CastorTapeTests::stopAndSwitchToRtcpclientd ( $dbh );
CastorTapeTests::startDaemons();
print "t=".CastorTapeTests::elapsed_time."s. ";
print "Switched back to rtcpclientd ========================\n";
# Fire 4th iteration of the test
......@@ -193,6 +205,20 @@ sub preparePreTransitionBacklog ( $$ )
sub managePostTransitionBacklog ()
{
# To be fleshed out.
# Check that the tapes from the tape pool have been left in a proper state.
my $tapepool = CastorTapeTests::get_environement('tapepool');
my $tp_status = `vmgrlisttape -P $tapepool`;
for ( split /^/, $tp_status) {
if ( /BUSY/ ) {
chomp;
print "********** WARNING: ".$_."\n";
if ( /^([[:alnum:]]+) / ) {
`vmgrmodifytape -V $1 --st \"\"`;
print "Removed the busy flag from tape $1\n";
}
}
}
}
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