Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/OpenQA/Worker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,12 @@ sub is_qemu_running ($self) {
sub is_ovs_dbus_service_running ($self) {
try { defined &Net::DBus::system or require Net::DBus }
catch ($e) { return 0 }
my $bus = ($self->{_system_dbus} //= Net::DBus->system(nomainloop => 1));
try { return defined $bus->get_service('org.opensuse.os_autoinst.switch') }
unless (defined $self->{_system_dbus}) {
$self->{_system_dbus} = Net::DBus->system(nomainloop => 1);
# this avoids piling up signals we never do anything with - POO #183833
$self->{_system_dbus}->get_bus_object->disconnect_from_signal('NameOwnerChanged', 1);
}
try { return defined $self->{_system_dbus}->get_service('org.opensuse.os_autoinst.switch') }
catch ($e) { return 0 }
}

Expand Down
6 changes: 6 additions & 0 deletions t/24-worker-overall.t
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ my $guard = scope_guard sub { chdir $FindBin::Bin };
use Mojo::Base -base;
has availability_error => 'Cache service info error: Connection refused';
}
{
package Test::FakeDBusObject;
use Mojo::Base -base, -signatures;
sub disconnect_from_signal ($self, $signal, $id) { }
}
{
package Test::FakeDBus; # uncoverable statement count:2
use Mojo::Base -base, -signatures;
has mock_service_value => 1;
sub get_service ($self, $service_name) { $self->mock_service_value }
sub get_bus_object ($self) { Test::FakeDBusObject->new }
}

my $dbus_mock = Test::MockModule->new('Net::DBus', no_auto => 1);
Expand Down