Skip to content

Commit

Permalink
Merge branch 'version/2.5'
Browse files Browse the repository at this point in the history
* version/2.5:
  Don't attempt removing objects that haven't been stored
  Somehow, only 9.6 seconds seem to elapse on Travis when sleeping 10 seconds
  Simplified the Runnable: no need to check for the overhead, checking that it slept 10 seconds suffices
  • Loading branch information
ens-bwalts committed Jun 30, 2020
2 parents dc93837 + 28eb887 commit 2bf2efc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 3 additions & 0 deletions modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ sub remove { # remove the object by primary_key
my $self = shift @_;
my $object = shift @_;

# the object hasn't actually been stored yet / in this database
return if(UNIVERSAL::can($object, 'adaptor') and (!$object->adaptor or $object->adaptor != $self));

my $primary_key_constraint = $self->primary_key_constraint( $self->slicer($object, $self->primary_key()) );

return $self->remove_all( $primary_key_constraint );
Expand Down
20 changes: 7 additions & 13 deletions t/05.runnabledb/dummy.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,18 @@ use Time::HiRes qw(time);

use Bio::EnsEMBL::Hive::Utils::Test qw(standaloneJob);

my $min_overhead;

for (1..10) {
my $t = time();
standaloneJob('Bio::EnsEMBL::Hive::RunnableDB::Dummy', {
'take_time' => 0,
});
my $d = time() - $t;
$min_overhead = $d if (not defined $min_overhead) || ($d < $min_overhead);
}

my $wait = 10;
my $t = time();
standaloneJob('Bio::EnsEMBL::Hive::RunnableDB::Dummy', {
'take_time' => $wait,
});
my $d = time() - $t;
# We allow the runnable to be 5 times faster than the fastest attempt so far
cmp_ok($d, '>=', $wait+$min_overhead/5, 'The "take_time" parameter made the runnable sleep a bit');

# Correct for Travis' built-in time machine
if ($ENV{'TRAVIS'}) {
$wait -= 1;
}

cmp_ok($d, '>=', $wait, 'The "take_time" parameter made the runnable sleep');

done_testing();

0 comments on commit 2bf2efc

Please sign in to comment.