Commit 0e43613f 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.

Clarified the test behavior and state transitions for files, implemented checks at most significant steps,
reorganized the code a bit and created placeholder function to inject errors on every step of the cycle.
parent 48f199db
......@@ -172,28 +172,6 @@ sub register_remote ( $$ )
return $file_index - 1;
}
# Returns true if the file is of size zero or migrated (m bit), false otherwise
# Dies on the first problem.
sub check_migrated ( $ )
{
my $file_name = shift;
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 {
die "Failed to find file $file_name";
}
}
# Returns true if the file is recalled
sub check_recalled ( $ )
{
my $file_name = shift;
my $stager_qry=`stager_qry -M $file_name`;
return $stager_qry=~ /STAGED/;
}
# Check fileservers ready with timeout
sub poll_fileserver_readyness ( $$ )
{
......@@ -288,8 +266,48 @@ sub make_localfile ( $$ )
return $file_index;
}
# Utility functions for polling states of files.
# Returns true if the file is of size zero or migrated (m bit), false otherwise
# Dies on the first problem.
sub check_migrated_in_ns ( $ )
{
my $file_name = shift;
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 {
die "Failed to find file $file_name";
}
}
# Returns true if the file is declared as invalid in the stager
sub check_invalid ( $ )
{
my $file_name = shift;
my $stager_qry=`stager_qry -M $file_name`;
return $stager_qry=~ /INVALID/;
}
# Returns true if the file is recalled
sub check_recalled_or_fully_migrated ( $ )
{
my $file_name = shift;
my $stager_qry=`stager_qry -M $file_name`;
return $stager_qry=~ /STAGED/;
}
# remote files statuses:
# rfcped => migrated, "on tape", "being recalled" => staged
# => rfcped -> partially migrated -> migrated => invalidation requested -> on tape => being recalled -> recalled
#
# all self-transtions (->) are followed up in the same loop, with corresponding checks...
# all test-program initiated transitions (=>) are initiated from a different function...
# rfcped is created by rfcp_localfile
# invalidation requested is generated by cleanup_migrated
# being recalled is generated by stager_reget_from_tape.
# rfcp file to either single or dual copy directory and push all the
# know properties of the local file to the remote file created for the occasion
......@@ -331,7 +349,7 @@ sub cleanup_migrated ()
my %f = %{$remote_files[$i]};
if ( $f{type} eq "file" && $f{status} eq "migrated" ) {
`su $environment{username} -c \"stager_rm -M $f{name}\"`;
$remote_files[$i]->{status} = "on tape";
$remote_files[$i]->{status} = "invalidation requested";
print "t=".elapsed_time()."s. Removed $f{name} (was migrated) from stager.\n";
}
}
......@@ -342,8 +360,7 @@ sub stager_reget_from_tape ()
{
for ( my $i =0; $i < scalar (@remote_files); $i++ ) {
my %f = %{$remote_files[$i]};
if ( $f{type} eq "file" && $f{status} eq "migrated" ) {
`su $environment{username} -c \"stager_rm -M $f{name}\"`;
if ( $f{type} eq "file" && $f{status} eq "on tape" ) {
`su $environment{username} -c \"stager_get -M $f{name}\"`;
$remote_files[$i]->{status} = "being recalled";
print "t=".elapsed_time()."s. Initiated recall for $f{name}.\n";
......@@ -351,18 +368,6 @@ sub stager_reget_from_tape ()
}
}
#
# rfcp file, but give it a special traetement to asses the behaviour of the migration with bad/broken files
sub rfcp_localfile_break ( $$ )
{
my $breaking_type = shift;
die "TODO";
if ($breaking_type eq "missing castorfile") {
}
}
# Check remote entries: check presence (should be always true) and then status of all files listed in remote files list
# returns true is any file has changed status, allowig a caller function to tiem out on "nothing moves anymore"
sub check_remote_entries ()
......@@ -381,10 +386,10 @@ sub check_remote_entries ()
if ( $entry{type} eq "file" ) {
# check the migration status and compare checksums.
if ( $entry{status} eq "rfcped" ) {
if ( check_migrated ( $entry{name} ) ) {
if ( check_migrated_in_ns ( $entry{name} ) ) {
# Report the newly detected migration.
print "t=".elapsed_time()."s. File ".$entry{name}." now migrated to tape.\n";
$remote_files[$i]->{status} = "migrated";
print "t=".elapsed_time()."s. File ".$entry{name}." now partially migrated to tape (has 'm' bit).\n";
$remote_files[$i]->{status} = "partially migrated";
# Validate the checksum.
my $remote_checksum_string = `su $environment{username} -c \"nsls --checksum $entry{name}\"`;
chomp $remote_checksum_string;
......@@ -402,6 +407,14 @@ sub check_remote_entries ()
if ( $local_checksum ne $remote_checksum ) {
print "ERROR: checksum mismatch beween remote and locally stored for $entry{name}: $local_checksum != $remote_checksum\n";
}
$changed_entries ++;
}
# check the number of tape copies after the full migration
} elsif ( $entry{status} eq "partially migrated" ) {
if ( check_recalled_or_fully_migrated ( $entry{name} ) ) {
# Report the newly detected migration.
print "t=".elapsed_time()."s. File ".$entry{name}." now fully migrated to tape (from stager's point of view).\n";
$remote_files[$i]->{status} = "migrated";
# Check that dual tape copies got mirgated as expected (and on different tapes)
$nslsresult = `su $environment{username} -c \"nsls --class $entry{name}\"`;
if ( $nslsresult =~ /^\s+(\d+)\s+\/castor/ ) {
......@@ -421,23 +434,28 @@ sub check_remote_entries ()
} else {
print "ERROR: Failed to extract class for file ".$entry{name}."\n";
}
# Invalidate and recall the file
$changed_entries ++;
}
$changed_entries ++;
}
# check the invalidation status
} elsif ($entry{status} eq "invalidation requested" ) {
if ( check_invalid $entry{name} ) {
print "t=".elapsed_time()."s. File ".$entry{name}." reported as invalid by the stager.\n";
$remote_files[$i]->{status} = "on tape";
$changed_entries ++;
}
# check the recall status, rfcp in and compare checksums.
} elsif ($entry{status} eq "being recalled" ) {
if ( check_recalled ( $entry{name} ) ) {
if ( check_recalled_or_fully_migrated ( $entry{name} ) ) {
print "t=".elapsed_time()."s. File ".$entry{name}." now recalled to disk.\n";
$remote_files[$i]->{status} eq "being recalled";
$remote_files[$i]->{status} = "recalled";
# rfcp in the file, check size and checksum.
my $local_copy=`mktemp`;
chomp $local_copy;
# hand over the file to the user
`chown $environment{username} $local_copy`;
# rfcp the recalled copy
`rfcp $entry{name} $local_copy`;
# computer checksum, get size and get rid of file
`su -c \"rfcp $entry{name} $local_copy\"`;
# compute checksum, get size and get rid of file
my $local_size = ( -s $local_copy );
my $local_checksum_string = `adler32 $local_copy`;
my $local_checksum;
......@@ -465,12 +483,13 @@ sub check_remote_entries ()
return $changed_entries;
}
# Get the number of non-migrated files
# Get the number of files for which a move is expected.
sub count_to_be_moved ()
{
my $ret = 0;
for ( @remote_files ) {
if ( ($_->{type} eq "file" ) && ($_ ->{status} =~ /rfcped|being recalled/ ) ) {
if ( ($_->{type} eq "file" ) && ($_ ->{status} =~
/rfcped|partially migrated|invalidation requested|being recalled/ ) ) {
$ret++;
}
}
......@@ -478,24 +497,59 @@ sub count_to_be_moved ()
}
# Check that all the files have migrated
sub poll_moving_entries ( $$ )
sub poll_moving_entries ( $$$ )
{
my ( $poll_interval, $timeout ) = ( shift, shift );
my ( $poll_interval, $timeout, $options ) = ( shift, shift );
my $starttime = `date +%s`;
while ( count_to_be_moved() > 0 && ((`date +%s` - $starttime) < $timeout) ) {
if ( check_remote_entries () ) {
print "t=".elapsed_time()."s. Saw at least one new migration...\n";
$starttime = `date +%s`;
}
if ( $options =~ /cleanup_migrated/ ) {
cleanup_migrated();
}
if ( $options =~ /stager_reget_from_tape/ ) {
stager_reget_from_tape();
}
sleep ( $poll_interval );
}
if (count_to_be_moved() == 0 ) {
print
print "t=".elapsed_time()."s. All expected moves completed.\n";
return;
}
die "Timeout with ".count_to_be_migrated()." files to be migrated after $timeout s.";
}
# Collection of special functions which introduce broken structures in the system
# rfcp file, but give it a special traetement to asses the behaviour of the migration with bad/broken files
sub rfcp_localfile_break ( $$ )
{
my $breaking_type = shift;
die "TODO";
if ($breaking_type eq "missing castorfile") {
}
}
sub cleanup_migrated_break ()
{
die "TODO";
}
sub stager_reget_from_tape_break ()
{
die "TODO";
}
# Breaking can be introduced on the occasion of a transition detection as well.
sub check_remote_entries_break ()
{
die "TODO";
}
# Returns the value of the specified ORASTAGERCONFIG parameter.
#
# This subroutine prints an error message and aborts the entire tes script if
......
......@@ -186,7 +186,7 @@ sub goodDaySingleAndDualCopyTest ( $$ )
CastorTapeTests::rfcp_localfile ( $local_index, $sd );
}
}
CastorTapeTests::poll_moving_entries ( $poll, $timeout );
CastorTapeTests::poll_moving_entries ( $poll, $timeout, "cleanup_migrated stager_reget_from_tape" );
}
# Inject error conditions to chekc on the reactions of the tape system
......
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