Skip to content

Commit

Permalink
Read network device names from Network Manager config
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmanzo committed Dec 11, 2023
1 parent f69e77d commit deff529
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/microos/network_bonding.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ sub test_failover {
sub run {
my ($self) = @_;
select_console 'root-console';
# remove existing NM-managed connections (except loopback)
my @interfaces = grep { !/^lo/ } split('\n', script_output 'nmcli -t -f NAME con');
assert_script_run "nmcli con delete '$_'" for @interfaces;
# remove existing NM-managed connections (except loopback).
my @devices; # array of device names
my %connections; # many device can share the same id, so we use hash keys to dedup
foreach (split('\n', script_output 'nmcli -g DEVICE,UUID conn show --active')) {
next if /^lo:/; # skip loopback device
my @item=split /:/;
push @devices, $item[0];
%connections{$item[1]} = 1;
}
assert_script_run "nmcli con delete '$_'" for keys %connections;
# create a new bonding interface and connect the two ethernet
assert_script_run "nmcli con add type bond ifname bond0 con-name bond0";
assert_script_run "nmcli con add type ethernet ifname $_ master bond0" for qw{eth0 eth1};
assert_script_run "nmcli con add type ethernet ifname $_ master bond0" for @devices;
# bring up bond interface
assert_script_run "nmcli con up bond0";
# reboot to ensure connection properly comes up at start
Expand All @@ -41,8 +48,7 @@ sub run {
# first connectivity check
assert_script_run 'ping -c1 -I bond0 conncheck.opensuse.org';
# check device failover
test_failover $_ for qw{eth0 eth1};
test_failover $_ for @devices;
}

1;

0 comments on commit deff529

Please sign in to comment.