Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package os-autoinst for openSUSE:Factory checked in at 2025-03-15 16:16:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/os-autoinst (Old) and /work/SRC/openSUSE:Factory/.os-autoinst.new.19136 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "os-autoinst" Sat Mar 15 16:16:55 2025 rev:507 rq:1253339 version:5.1742031910.117e1ea Changes: -------- --- /work/SRC/openSUSE:Factory/os-autoinst/os-autoinst.changes 2025-03-14 23:51:52.836102062 +0100 +++ /work/SRC/openSUSE:Factory/.os-autoinst.new.19136/os-autoinst.changes 2025-03-15 16:17:38.511987589 +0100 @@ -1,0 +2,10 @@ +Sat Mar 15 11:13:43 UTC 2025 - ok...@suse.com + +- Update to version 5.1742031910.117e1ea: + * Fix regression from 055d2e67 in _set_ip arguments + * Ensure full coverage in the project + * Create test for script os-autoinst-openvswitch + * Enable is_shutdown to be used after "power('off')" on qemu + * Retry asset sync in svirt backend after timeouts + +------------------------------------------------------------------- Old: ---- os-autoinst-5.1741888574.cd102e5.obscpio New: ---- os-autoinst-5.1742031910.117e1ea.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ os-autoinst-devel-test.spec ++++++ --- /var/tmp/diff_new_pack.fiBe2i/_old 2025-03-15 16:17:39.300020637 +0100 +++ /var/tmp/diff_new_pack.fiBe2i/_new 2025-03-15 16:17:39.304020806 +0100 @@ -18,7 +18,7 @@ %define short_name os-autoinst-devel Name: %{short_name}-test -Version: 5.1741888574.cd102e5 +Version: 5.1742031910.117e1ea Release: 0 Summary: Test package for %{short_name} License: GPL-2.0-or-later ++++++ os-autoinst-openvswitch-test.spec ++++++ --- /var/tmp/diff_new_pack.fiBe2i/_old 2025-03-15 16:17:39.328021812 +0100 +++ /var/tmp/diff_new_pack.fiBe2i/_new 2025-03-15 16:17:39.332021979 +0100 @@ -19,7 +19,7 @@ %define name_ext -test %define short_name os-autoinst-openvswitch Name: %{short_name}%{?name_ext} -Version: 5.1741888574.cd102e5 +Version: 5.1742031910.117e1ea Release: 0 Summary: test package for %{short_name} License: GPL-2.0-or-later ++++++ os-autoinst-test.spec ++++++ --- /var/tmp/diff_new_pack.fiBe2i/_old 2025-03-15 16:17:39.356022986 +0100 +++ /var/tmp/diff_new_pack.fiBe2i/_new 2025-03-15 16:17:39.360023154 +0100 @@ -19,7 +19,7 @@ %define name_ext -test %define short_name os-autoinst Name: %{short_name}%{?name_ext} -Version: 5.1741888574.cd102e5 +Version: 5.1742031910.117e1ea Release: 0 Summary: test package for os-autoinst License: GPL-2.0-or-later ++++++ os-autoinst.spec ++++++ --- /var/tmp/diff_new_pack.fiBe2i/_old 2025-03-15 16:17:39.388024328 +0100 +++ /var/tmp/diff_new_pack.fiBe2i/_new 2025-03-15 16:17:39.388024328 +0100 @@ -17,7 +17,7 @@ Name: os-autoinst -Version: 5.1741888574.cd102e5 +Version: 5.1742031910.117e1ea Release: 0 Summary: OS-level test automation License: GPL-2.0-or-later ++++++ os-autoinst-5.1741888574.cd102e5.obscpio -> os-autoinst-5.1742031910.117e1ea.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/os-autoinst-5.1741888574.cd102e5/codecov.yml new/os-autoinst-5.1742031910.117e1ea/codecov.yml --- old/os-autoinst-5.1741888574.cd102e5/codecov.yml 2025-03-13 18:56:14.000000000 +0100 +++ new/os-autoinst-5.1742031910.117e1ea/codecov.yml 2025-03-15 10:45:10.000000000 +0100 @@ -11,31 +11,8 @@ changes: false project: default: - target: 94.0 - threshold: 0.1 - fully_covered: target: 100.0 - paths: - - OpenQA/ - - backend/ - - consoles/ - - commands.pm - - distribution.pm - - autotest.pm - - myjsonrpc.pm - - lockapi.pm - - basetest.pm - - bmwqemu.pm - - cv.pm - - log.pm - - mmapi.pm - - osutils.pm - - signalblocker.pm - - testapi.pm - - t/ - - xt/ - - script/check_qemu_oom - - script/vnctest + threshold: 0.1 patch: default: branches: null diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/os-autoinst-5.1741888574.cd102e5/script/os-autoinst-openvswitch new/os-autoinst-5.1742031910.117e1ea/script/os-autoinst-openvswitch --- old/os-autoinst-5.1741888574.cd102e5/script/os-autoinst-openvswitch 2025-03-13 18:56:14.000000000 +0100 +++ new/os-autoinst-5.1742031910.117e1ea/script/os-autoinst-openvswitch 2025-03-15 10:45:10.000000000 +0100 @@ -21,19 +21,12 @@ use Mojo::Base 'Net::DBus::Object', -signatures; use autodie ':all'; use Feature::Compat::Try; -use Getopt::Long; use Net::DBus::Exporter 'org.opensuse.os_autoinst.switch'; require IPC::System::Simple; use IPC::Open3; use Symbol 'gensym'; use Time::Seconds; -sub usage ($r) { require Pod::Usage; Pod::Usage::pod2usage($r) } - -my %options; -GetOptions(\%options, 'help|h|?') or usage(1); -usage(0) if $options{help}; - use constant INIT_TIMEOUT => $ENV{OS_AUTOINST_OPENVSWITCH_INIT_TIMEOUT} // (5 * ONE_MINUTE); sub new ($class, $service) { @@ -43,23 +36,34 @@ return $self; } +# uncoverable statement count:1..3 +sub _wait_for_bridge ($self) { + until (-e "/sys/class/net/$self->{BRIDGE}") { # uncoverable statement + print "Waiting for bridge '$self->{BRIDGE}' to be created and configured...\n"; # uncoverable statement + sleep 1; # uncoverable statement + } # uncoverable statement + system('ovs-vsctl', 'br-exists', $self->{BRIDGE}); # uncoverable statement +} + +# uncoverable statement count:1..5 +sub _add_flow ($self, $rule) { system('ovs-ofctl', 'add-flow', $self->{BRIDGE}, $rule) } + +# uncoverable statement count:1..4 +sub _bridge_conf ($self) { qx{ip addr show $self->{BRIDGE}} } + sub init_switch ($self) { $self->{BRIDGE} = $ENV{OS_AUTOINST_USE_BRIDGE}; $self->{BRIDGE} //= 'br0'; - until (-e "/sys/class/net/$self->{BRIDGE}") { - print "Waiting for bridge '$self->{BRIDGE}' to be created and configured...\n"; - sleep 1; - } - system('ovs-vsctl', 'br-exists', $self->{BRIDGE}); + $self->_wait_for_bridge; for (my $timeout = INIT_TIMEOUT; $timeout > 0; --$timeout) { - my $bridge_conf = qx{ip addr show $self->{BRIDGE}}; + my $bridge_conf = $self->_bridge_conf; $self->{MAC} = $1 if $bridge_conf =~ /ether\s+(([0-9a-f]{2}:){5}[0-9a-f]{2})\s/; $self->{IP} = $1 if $bridge_conf =~ /inet\s+(([0-9]+.){3}[0-9]+\/[0-9]+)\s/; last if $self->{IP}; - print "Waiting for IP on bridge '$self->{BRIDGE}', ${timeout}s left ...\n"; - sleep 1; + print "Waiting for IP on bridge '$self->{BRIDGE}', ${timeout}s left ...\n"; # uncoverable statement + sleep 1; # uncoverable statement } die "can't parse bridge local port MAC" unless $self->{MAC}; @@ -114,10 +118,13 @@ "mod_nw_src:$rewrite_target,move:NXM_OF_ETH_SRC[0..$netmask]->NXM_OF_IP_SRC[0..$netmask],local", ) { - system('ovs-ofctl', 'add-flow', $self->{BRIDGE}, $rule); + $self->_add_flow($rule); } } +# uncoverable statement count:1..4 +sub _check_bridge ($tap) { qx{ovs-vsctl port-to-br $tap} } + # Check if tap and vlan are in the correct format. sub _ovs_check ($tap, $vlan, $bridge) { my $return_output; @@ -132,7 +139,7 @@ return ($return_code, $return_output); } - my $check_bridge = qx{ovs-vsctl port-to-br $tap}; + my $check_bridge = _check_bridge($tap); chomp $check_bridge; if ($check_bridge ne $bridge) { $return_output = "'$tap' is not connected to bridge '$bridge'"; @@ -158,9 +165,13 @@ return $return_code, "@ovs_vsctl_error", "@ovs_vsctl_output"; } +# uncoverable statement count:1..3 +sub _ovs_version () { qx{ovs-vsctl --version} } + sub check_min_ovs_version ($min_ver) { - my $out = qx{ovs-vsctl --version}; + my $out = _ovs_version; return if ($out !~ /\(Open vSwitch\)\s+(\d+\.\d+\.\d+)/m); + my @ver = split(/\./, $1); my @min_ver = split(/\./, $min_ver); return if (@ver != @min_ver); @@ -168,6 +179,9 @@ return sprintf("%04d%04d%04d", @ver) >= sprintf("%04d%04d%04d", @min_ver); } +# uncoverable statement count:1..5 +sub _set_ip ($tap) { system('ip', 'link', 'set', $tap, 'up') } + dbus_method("set_vlan", ["string", "uint32"], ["int32", "string"]); sub set_vlan ($self, $tap, $vlan) { my $return_output; @@ -195,7 +209,7 @@ print $ovs_vsctl_output if length($ovs_vsctl_output) > 0; return $return_code, $ovs_vsctl_error unless $return_code == 0; - $return_code = system('ip', 'link', 'set', $tap, 'up'); + $return_code = _set_ip($tap); return $return_code, $return_code != 0 ? "Failed to set $tap up " : ''; } @@ -221,9 +235,12 @@ return $return_code, $return_code != 0 ? $ovs_vsctl_error : ''; } +# uncoverable statement count:1..3 +sub _ovs_show () { _cmd('ovs-vsctl', 'show') } + dbus_method("show", [], ["int32", "string"]); sub show ($self) { - my ($return_code, undef, $ovs_vsctl_output) = _cmd('ovs-vsctl', 'show'); + my ($return_code, undef, $ovs_vsctl_output) = _ovs_show; return $return_code, $ovs_vsctl_output; } @@ -233,12 +250,22 @@ use Net::DBus; use Net::DBus::Reactor; +use Getopt::Long; -my $bus = Net::DBus->system; +sub usage ($r) { require Pod::Usage; Pod::Usage::pod2usage($r) } -my $service = $bus->export_service("org.opensuse.os_autoinst.switch"); -my $object = OVS->new($service); +sub run_dbus($bus = Net::DBus->system, $reactor_main = Net::DBus::Reactor->main) { + my $service = $bus->export_service("org.opensuse.os_autoinst.switch"); + my $object = OVS->new($service); + $reactor_main->run; +} -Net::DBus::Reactor->main->run; +sub main () { + my %options; + GetOptions(\%options, 'help|h|?') or usage(1); + usage(0) if $options{help}; + run_dbus(); +} -exit 0; +main() unless caller(); +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/os-autoinst-5.1741888574.cd102e5/t/46-os-autoinst-openvswitch.t new/os-autoinst-5.1742031910.117e1ea/t/46-os-autoinst-openvswitch.t --- old/os-autoinst-5.1741888574.cd102e5/t/46-os-autoinst-openvswitch.t 1970-01-01 01:00:00.000000000 +0100 +++ new/os-autoinst-5.1742031910.117e1ea/t/46-os-autoinst-openvswitch.t 2025-03-15 10:45:10.000000000 +0100 @@ -0,0 +1,88 @@ +#!/usr/bin/env perl +# Copyright SUSE LLC +# SPDX-License-Identifier: GPL-2.0-or-later + +use Test::Most; +use Test::Warnings ':report_warnings'; +use Test::MockObject; +use Test::MockModule qw(strict); +use Test::Mock::Time; +use Test::Output qw(stderr_like); +use FindBin '$Bin'; + +use lib "$FindBin::Bin/lib", "$Bin/../external/os-autoinst-common/lib"; + +use OpenQA::Test::TimeLimit '5'; +use Net::DBus; +use Net::DBus::Reactor; + +my $mock_dbus = Test::MockObject->new(); +$mock_dbus->set_isa('Net::DBus'); +$mock_dbus->mock(system => $mock_dbus); +$mock_dbus->mock(session => $mock_dbus); + +my $mock_service = Test::MockObject->new(); +$mock_service->set_isa('Net::DBus::Service'); + +$mock_dbus->mock(export_service => sub { $mock_service }); + +my $mock_reactor = Test::MockModule->new('Net::DBus::Reactor'); +$mock_reactor->redefine(run => undef); + +require "$FindBin::Bin/../script/os-autoinst-openvswitch"; + +subtest 'Main package' => sub { + my $mock_main = Test::MockModule->new('main'); + $mock_main->redefine(run_dbus => 1); + my $result = main::main(); + is($result, 1, 'main::main() should return 1'); +}; + +subtest 'OVS package' => sub { + my $mock_dbus_object = Test::MockModule->new('Net::DBus::Object'); + $mock_dbus_object->redefine('new', {}); + my $mock_main = Test::MockModule->new('OVS', no_auto => 1); + my $wait_for_bridge_called = 0; + $mock_main->redefine(_wait_for_bridge => sub { $wait_for_bridge_called++ }); + $mock_main->redefine(_bridge_conf => "\tlink/ether 01:23:45:67:89:ab brd ff:ff:ff:ff:ff:ff\n\tinet 10.0.2.2/15 brd 10.1.255.255 scope global br0"); + $mock_main->redefine(_add_flow => undef); + my $result = main::run_dbus($mock_dbus); + is $result, undef, 'run_dbus() should return 1'; + is $wait_for_bridge_called, 1, 'wait_for_bridge was called'; + + subtest 'can call _ovs_check' => sub { + $mock_main->redefine(_check_bridge => 'br1'); + is OVS::_ovs_check('tap0', 0, 'br1'), 0, 'success'; + ok OVS::_ovs_check('tap0', 0, 'br0'), 'wrong bridge'; + ok OVS::_ovs_check('something', 0, 'br0'), 'invalid tap name'; + ok OVS::_ovs_check('tap0', 'something', 'br0'), 'invalid vlan format'; + }; + + is((OVS::_cmd('true'))[0], 0, 'can call _cmd'); + + $mock_main->redefine(_ovs_version => '(Open vSwitch) 1.1.1'); + is OVS::check_min_ovs_version('1.1.1'), 1, 'can call check_min_ovs_version'; + + my $ovs = OVS->new($mock_service); + subtest 'can call set_vlan' => sub { + $mock_main->redefine(_ovs_version => '(Open vSwitch) 2.8.1'); + stderr_like { + ok $ovs->set_vlan('tap0', 1), 'tap0 is not in br0'; + } qr/'tap0'/, 'log output for missing tap'; + $mock_main->redefine(_ovs_check => sub { return (0, 1) }); + $mock_main->redefine(_cmd => sub { return (0, '', '') }); + $mock_main->redefine(_set_ip => 0); + is(($ovs->set_vlan('tap0', 1))[0], 0, 'can call set_vlan'); + }; + + $mock_main->redefine(_ovs_check => sub { return (1, 'error') }); + is(($ovs->unset_vlan('tap0', 1))[0], 1, 'unset_vlan handles error'); + $mock_main->redefine(_ovs_check => sub { return (0, 'error') }); + $mock_main->redefine(_cmd => sub { return (0, '', '') }); + is(($ovs->unset_vlan('tap0', 1))[0], 0, 'can call unset_vlan'); + + $mock_main->redefine(_ovs_show => 1); + is(($ovs->show())[0], 1, 'can call show'); +}; + +done_testing(); ++++++ os-autoinst.obsinfo ++++++ --- /var/tmp/diff_new_pack.fiBe2i/_old 2025-03-15 16:17:40.908088077 +0100 +++ /var/tmp/diff_new_pack.fiBe2i/_new 2025-03-15 16:17:40.912088244 +0100 @@ -1,5 +1,5 @@ name: os-autoinst -version: 5.1741888574.cd102e5 -mtime: 1741888574 -commit: cd102e5b8aa2389f334cecc9b6e72da3c9ef05ac +version: 5.1742031910.117e1ea +mtime: 1742031910 +commit: 117e1ea6928c8ea549c2965dc62b1b1391aee3ca