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

Fixed various mistakes, added structure for runnning configuration transitions tests.
parent 975c3912
......@@ -162,7 +162,7 @@ sub register_remote ( $$ )
sub check_migrated ( $ )
{
my $file_name = shift;
my $nsls=`nsls $file_name`;
my $nsls=`nsls -l $file_name`;
if ($nsls=~ /^([\w-]+)\s+(\d+)\s+(\w+)\s+(\w+)\s+(\d+)/ ) {
return ( ('m' eq substr ($1,0,1)) || ($5 == 0) );
} else {
......@@ -170,6 +170,22 @@ sub check_migrated ( $ )
}
}
# Check fileservers ready with timeout
sub poll_fileserver_readyness ( $$ )
{
my ( $interval, $timeout ) = ( shift, shift );
my $start_time = `date +%s`;
while ( ($start_time + $timeout) >= `date +%s`) {
my $query=`su $environment{username} -c \"stager_qry -s\"`;
if ( $query =~ /FILESYSTEM_PRODUCTION/ ) {
print "Fileservers ready after ".(`date +%s` - $start_time)."s.\n";
return;
}
sleep ( $interval );
}
die "Timeout in poll_fileserver_readyness";
}
# create a local seed file, returning the index to the file.
# Take 1 parameter: the size in
sub make_seed ( $ )
......@@ -235,7 +251,7 @@ sub make_localfile ( $$ )
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`;
`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 );
......@@ -244,6 +260,7 @@ sub make_localfile ( $$ )
'adler32' => $checksum);
my $file_index = push @local_files, \%file_entry;
$file_index --;
print "Created local file $file_name\n";
return $file_index;
}
......@@ -268,13 +285,15 @@ sub rfcp_localfile ( $$ )
} else {
die "Wrong file path in rfcp_localfile";
}
`su $environment{username} -c \"STAGE_SVCCLASS=dev rfcp $local $remote\"`;
my $rfcp_ret=`su $environment{username} -c \"STAGE_SVCCLASS=dev rfcp $local $remote\" 2>&1`;
my %remote_entry = ( 'name' => $remote,
'type' => "file",
'size' => $local_files[$local_index]->{size},
'adler32' => $local_files[$local_index]->{size},
'adler32' => $local_files[$local_index]->{adler32},
'status' => 'rfcped' );
push @remote_files, \%remote_entry;
print "rtcp'ed $local => $remote:\n";
print $rfcp_ret;
}
# Check remote entries: check presence (should be always true) and then status of all files listed in remote files list
......@@ -291,8 +310,9 @@ sub check_remote_entries ()
}
# if it's a file, check the migration status
if ( $entry{type} eq "file" ) {
if ( $entry{status} eq "rfcpied" ) {
if ( $entry{status} eq "rfcped" ) {
if ( check_migrated ( $entry{name} ) ) {
print "File ".$entry{name}." now migrated to tape.\n";
$remote_files[$i]->{status} = "migrated";
$changed_entries ++;
}
......@@ -1295,6 +1315,8 @@ 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") {
......
......@@ -4,7 +4,7 @@
TAPETEST username_lxcastordev03 canoc3
TAPETEST checkout_location_lxcastordev03 /var/scratch/canoc3/test_gateway_r21263
TAPETEST file_size_lxcastordev03 10485760
TAPETEST file_number_lxcastordev03 10
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
......
......@@ -35,6 +35,9 @@ use DBD::Oracle qw(:ora_types);
use CastorTapeTests;
sub goodDaySingleAndDualCopyTest ( $$ );
sub badDayTests ( $$ );
sub preparePreTransitionBacklog ( $$ );
sub managePostTransitionBacklog ();
sub main ();
# Make sure at least Ctrl-C triggers a cleanup
......@@ -102,33 +105,49 @@ sub main ()
print `su $username -c "nsmkdir $castor_directory$dual_subdir"`;
print `su $username -c "nschclass test2 $castor_directory$dual_subdir"`;
CastorTapeTests::register_remote ( $castor_directory.$dual_subdir, "directory" );
# Let the dust settle
CastorTapeTests::poll_fileserver_readyness (5,60);
# First iteration of the test
goodDaySingleAndDualCopyTest ($seed_index, $file_number);
badDayTests ($seed_index, $file_number);
preparePreTransitionBacklog ($seed_index, $file_number);
# Migrate to the new system, with tape gateway, still running rtcpclientd
$dbh=CastorTapeTests::open_db();
CastorTapeTests::migrateToNewTapeGatewaySchema ();
CastorTapeTests::stopAndSwitchToRtcpclientd ( $dbh );
CastorTapeTests::startDaemons();
print "Switched to new schema with rtcpclientd =============\n";
# Second iteration of the test
managePostTransitionBacklog();
goodDaySingleAndDualCopyTest ($seed_index, $file_number);
badDayTests ($seed_index, $file_number);
preparePreTransitionBacklog ($seed_index, $file_number);
# Switch to tape gateway
CastorTapeTests::stopAndSwitchToTapeGatewayd ( $dbh );
CastorTapeTests::startDaemons();
print "Switched to tapegatewayd ============================\n";
# Third iteration of the test
managePostTransitionBacklog();
goodDaySingleAndDualCopyTest ($seed_index, $file_number);
badDayTests ($seed_index, $file_number);
preparePreTransitionBacklog ($seed_index, $file_number);
# Switch back to tape gateway.
CastorTapeTests::stopAndSwitchToRtcpclientd ( $dbh );
CastorTapeTests::startDaemons();
print "Switched back to rtcpclientd ========================\n";
# Fire 4th iteration of the test
managePostTransitionBacklog();
goodDaySingleAndDualCopyTest ($seed_index, $file_number);
badDayTests ($seed_index, $file_number);
print "Cleaning up test directories $castor_directory\{$single_subdir,$dual_subdir\}\n";
print `su $username -c "for p in $castor_directory\{$single_subdir,$dual_subdir\}; do nsrm -r -f \\\$p; done"`;
......@@ -158,3 +177,22 @@ sub goodDaySingleAndDualCopyTest ( $$ )
CastorTapeTests::poll_moving_entries ( $poll, $timeout );
}
# Inject error conditions to chekc on the reactions of the tape system
sub badDayTests ( $$ )
{
# To be fleshed out.
}
# Inject file right before transition from one running configuration to the other.
sub preparePreTransitionBacklog ( $$ )
{
# To be fleshed out.
}
# Follow up on the files injected in the system after the configuration switchover.
sub managePostTransitionBacklog ()
{
# To be fleshed out.
}
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