Skip to content

Commit

Permalink
Merge pull request #8 from ces/rundelete
Browse files Browse the repository at this point in the history
Extend tests
  • Loading branch information
ces authored Feb 13, 2020
2 parents 504b84f + 13ce04e commit 567150c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
37 changes: 31 additions & 6 deletions t/lib/WTSI/NPG/HTS/PacBio/Sequel/RunDeleteMonitorTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ sub require : Test(1) {
require_ok('WTSI::NPG::HTS::PacBio::Sequel::RunDeleteMonitor');
}

sub delete_runs : Test(7) {
sub delete_runs : Test(14) {
my $uri = URI->new($server->uri . 'QueryJobs');
my $client = WTSI::NPG::HTS::PacBio::Sequel::APIClient->new
(default_interval => 10000,);
Expand All @@ -118,17 +118,19 @@ sub delete_runs : Test(7) {
strict_baton_version => 0);
my $drirods = WTSI::NPG::DriRODS->new(environment => \%ENV,
strict_baton_version => 0);
my $dest_coll = $irods_tmp_coll;

## create tmp runfolder which will be deleted later
my $run_name = 'r54097_20170727_165601';
my $well = '1_A02';

my $data_path = catdir('t/data/pacbio/sequel', $run_name, $well);
my $dest_coll = catdir($irods_tmp_coll, $run_name);

my $runfolder_path = catdir($tmp_dir,$run_name);
mkdir $runfolder_path;
my $runfolder_data = catdir($runfolder_path,$well);
dircopy($data_path,$runfolder_path) or die $!;
mkdir $runfolder_data;
dircopy($data_path,$runfolder_data) or die $!;

## publish data
my $monitor = WTSI::NPG::HTS::PacBio::Sequel::RunMonitor->new
Expand All @@ -140,13 +142,12 @@ sub delete_runs : Test(7) {

my ($num_jobs, $num_processed, $num_errors) =
$monitor->publish_completed_runs;

cmp_ok($num_jobs, '==', scalar @{$test_response},
'Correct number of runs to publish');
cmp_ok($num_processed, '==', $num_jobs, 'All runs processed');
cmp_ok($num_errors, '==', 0, 'No error in any run published');

## delete run
## delete run successfully
my $deletable = WTSI::NPG::HTS::PacBio::Sequel::RunDeleteMonitor->new
(api_client => $client,
check_format => 0,
Expand All @@ -161,9 +162,33 @@ sub delete_runs : Test(7) {
cmp_ok($dnum_runs, '==', scalar @{$test_response},
'Correct number of runs to delete');
cmp_ok($dnum_processed, '==', $num_jobs, 'All run folders processed');
cmp_ok($dnum_processed, '==', $num_jobs, 'All run folders deleted');
cmp_ok($dnum_deleted, '==', $num_jobs, 'All run folders deleted');
cmp_ok($dnum_errors, '==', 0, 'No error in any run deleted');

## recopy and republish
dircopy($data_path,$runfolder_data) or die $!;
my ($num_jobs2, $num_processed2, $num_errors2) =
$monitor->publish_completed_runs;

cmp_ok($num_jobs2, '==', scalar @{$test_response},
'Correct number of runs to publish');
cmp_ok($num_processed2, '==', $num_jobs, 'All runs processed');
cmp_ok($num_errors2, '==', 0, 'No error in any run published');

## remove a file from iRODS so run not deleted
my $file_to_remove = catfile($dest_coll, $well, q[m54097_170727_170646.subreads.bam]);
$irods->remove_object($file_to_remove);

## fail to delete run
my ($dnum_runs2, $dnum_processed2, $dnum_deleted2, $dnum_errors2) =
$deletable->delete_runs();

cmp_ok($dnum_runs2, '==', scalar @{$test_response},
'Correct number of runs to attempt to delete');
cmp_ok($dnum_processed2, '==', $num_jobs, 'All run folders processed');
cmp_ok($dnum_deleted2, '==', $num_jobs -1, 'Modified run not deleted');
cmp_ok($dnum_errors2, '==', 1, 'Error in one run deletion attempt');

}

1;
7 changes: 5 additions & 2 deletions t/lib/WTSI/NPG/HTS/PacBio/Sequel/RunDeleteTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sub require : Test(1) {
require_ok('WTSI::NPG::HTS::PacBio::Sequel::RunDelete');
}

sub delete_run : Test(2) {
sub delete_run : Test(4) {

my $tmp_output_dir = "$tmp_dir/rundeletefolder.$pid";
make_path($tmp_output_dir);
Expand All @@ -35,7 +35,10 @@ sub delete_run : Test(2) {
(runfolder_path => $tmp_output_dir);

isa_ok($deleter, 'WTSI::NPG::HTS::PacBio::Sequel::RunDelete');
ok($deleter->delete_run(), "Deleted runfolder directory");
ok(-d $tmp_output_dir, "Runfolder to be deleted exists");
ok($deleter->delete_run(), "Deleted the runfolder directory");
ok(! -d $tmp_output_dir, "Deleted runfolder doesn't exist");

}

1;

0 comments on commit 567150c

Please sign in to comment.