Skip to content
Open
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
23 changes: 20 additions & 3 deletions io/net/ethtool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,33 @@ def setUp(self):
interfaces = os.listdir('/sys/class/net')
local = LocalHost()
device = self.params.get("interface")
self.hbond = self.params.get("hbond", default=False)
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.interface = device
elif local.validate_mac_addr(device) and device in local.get_all_hwaddr():
self.interface = local.get_interface_by_hwaddr(device).name
elif (local.validate_mac_addr(device) and
device in local.get_all_hwaddr()):
if self.hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = local.get_interface_by_hwaddr(device)
if iface.is_bond():
self.interface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.interface = bond_master
else:
# regular interface identified by MAC address
self.interface = local.get_interface_by_hwaddr(device).name
else:
self.interface = None
self.cancel("Please check the network device")
self.ipaddr = self.params.get("host_ip", default="")
self.netmask = self.params.get("netmask", default="")
self.hbond = self.params.get("hbond", default=False)
self.peer = self.params.get("peer_ip")
self.tx = self.params.get("tx_channel", default='')
self.rx = self.params.get("rx_channel", default='')
Expand Down
33 changes: 30 additions & 3 deletions io/net/hnv_bond_failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from avocado import Test
from avocado.utils import process
from avocado.utils import wait
from avocado.utils.network.hosts import LocalHost


class HNVBondFailoverTest(Test):
Expand All @@ -39,12 +40,39 @@ def setUp(self):
"""
Set up test parameters and verify bond configuration
"""
self.interface = self.params.get("interface", default=None)
device = self.params.get("interface", default=None)
self.host_ip = self.params.get("host_ip", default=None)
self.peer_ip = self.params.get("peer_ip", default=None)
self.hbond = self.params.get("hbond", default=True)

local = LocalHost()
interfaces = os.listdir('/sys/class/net')
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.interface = device
elif (device and local.validate_mac_addr(device) and
device in local.get_all_hwaddr()):
if self.hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = local.get_interface_by_hwaddr(device)
if iface.is_bond():
self.interface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.interface = bond_master
else:
# regular interface identified by MAC address
self.interface = local.get_interface_by_hwaddr(device).name
else:
self.interface = None

if not self.interface:
self.cancel("Bond interface not specified in YAML configuration")
self.cancel("Bond interface not specified or not available")
if not self.host_ip:
self.cancel("Host IP address not specified in YAML configuration")
if not self.peer_ip:
Expand Down Expand Up @@ -361,4 +389,3 @@ def tearDown(self):
else:
self.log.info("Bond slave configuration intact: %s" %
', '.join(final_slaves))
# Assisted by AI tool
20 changes: 18 additions & 2 deletions io/net/iperf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,33 @@ def setUp(self):
default=None)
interfaces = os.listdir('/sys/class/net')
device = self.params.get("interface", default="")
self.hbond = self.params.get("hbond", default=False)
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.iface = device
elif (localhost.validate_mac_addr(device) and
device in localhost.get_all_hwaddr()):
self.iface = localhost.get_interface_by_hwaddr(device).name
if self.hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = localhost.get_interface_by_hwaddr(device)
if iface.is_bond():
self.iface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.iface = bond_master
else:
# regular interface identified by MAC address
self.iface = localhost.get_interface_by_hwaddr(device).name
else:
self.iface = None
self.cancel("%s interface is not available" % device)
self.ipaddr = self.params.get("host_ip", default="")
self.netmask = self.params.get("netmask", default="")
self.hbond = self.params.get("hbond", default=False)
if self.hbond:
self.networkinterface = NetworkInterface(self.iface, localhost,
if_type='Bond')
Expand Down
19 changes: 17 additions & 2 deletions io/net/irqbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,26 @@ def setUp(self):
interfaces = os.listdir('/sys/class/net')
self.localhost = LocalHost()
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.interface = device
elif (self.localhost.validate_mac_addr(device) and
device in self.localhost.get_all_hwaddr()):
self.interface = (self.localhost.
get_interface_by_hwaddr(device).name)
if self.is_hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = self.localhost.get_interface_by_hwaddr(device)
if iface.is_bond():
self.interface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.interface = bond_master
else:
# regular interface identified by MAC address
self.interface = self.localhost.get_interface_by_hwaddr(device).name
else:
self.cancel("Please check the network device")
if not self.peer_ip:
Expand Down
23 changes: 20 additions & 3 deletions io/net/multicast.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,33 @@ def setUp(self):
self.peer_password = self.params.get("peer_password",
'*', default="None")
device = self.params.get("interface", default=None)
self.hbond = self.params.get("hbond", default=False)
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.iface = device
elif local.validate_mac_addr(device) and device in local.get_all_hwaddr():
self.iface = local.get_interface_by_hwaddr(device).name
elif (local.validate_mac_addr(device) and
device in local.get_all_hwaddr()):
if self.hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = local.get_interface_by_hwaddr(device)
if iface.is_bond():
self.iface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.iface = bond_master
else:
# regular interface identified by MAC address
self.iface = local.get_interface_by_hwaddr(device).name
else:
self.iface = None
self.cancel("%s interface is not available" % device)
self.ipaddr = self.params.get("host_ip", default="")
self.netmask = self.params.get("netmask", default="")
self.hbond = self.params.get("hbond", default=False)
if self.hbond:
self.networkinterface = NetworkInterface(self.iface, local,
if_type='Bond')
Expand Down
39 changes: 29 additions & 10 deletions io/net/network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,34 @@ def setUp(self):
interfaces = os.listdir('/sys/class/net')
local = LocalHost()
device = self.params.get("interface")
self.hbond = self.params.get("hbond", default=False)
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.interface = device
elif local.validate_mac_addr(device) and device in local.get_all_hwaddr():
self.interface = local.get_interface_by_hwaddr(device).name
elif (local.validate_mac_addr(device) and
device in local.get_all_hwaddr()):
if self.hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = local.get_interface_by_hwaddr(device)
if iface.is_bond():
self.interface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.interface = bond_master
else:
# regular interface identified by MAC address
self.interface = local.get_interface_by_hwaddr(device).name
else:
self.interface = None
self.cancel("Please check the network device")
self.ipaddr = self.params.get("host_ip", default="")
self.netmask = self.params.get("netmask", default="")
self.ip_config = self.params.get("ip_config", default=True)
self.hbond = self.params.get("hbond", default=False)
if self.hbond:
self.networkinterface = NetworkInterface(
self.interface, local, if_type='Bond')
Expand Down Expand Up @@ -103,10 +120,11 @@ def setUp(self):
self.peer).name
self.peer_networkinterface = NetworkInterface(self.peer_interface,
self.remotehost)
self.remotehost_public = RemoteHost(self.peer_public_ip, self.peer_user,
self.remotehost_public = RemoteHost(self.peer_public_ip,
self.peer_user,
password=self.peer_password)
self.peer_public_networkinterface = NetworkInterface(self.peer_interface,
self.remotehost_public)
self.peer_public_networkinterface = NetworkInterface(
self.peer_interface, self.remotehost_public)
self.mtu = self.params.get("mtu", default=1500)
self.count = self.params.get("ping_count", default=500000)
self.mtu_set()
Expand Down Expand Up @@ -207,7 +225,8 @@ def test_ipv6_ping(self):
except Exception:
self.cancel(
"Test failing while getting IPV6 address for peer interface")
if self.networkinterface.ping_check(peer_ipv6[0], count=10) is not None:
if self.networkinterface.ping_check(peer_ipv6[0],
count=10) is not None:
self.fail("IPV6 ping test failed")

def test_ssh(self):
Expand Down Expand Up @@ -244,9 +263,9 @@ def test_jumbo_frame(self):
'''
Test jumbo frames
'''
if self.networkinterface.ping_check(self.peer, count=30,
options='-i 0.1 -s %d'
% (int(self.mtu) - 28)) is not None:
if self.networkinterface.ping_check(
self.peer, count=30,
options='-i 0.1 -s %d' % (int(self.mtu) - 28)) is not None:
self.fail("jumbo frame test failed")

def test_statistics(self):
Expand Down
51 changes: 36 additions & 15 deletions io/net/tcpdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,28 @@ def setUp(self):
self.networkinterface = None
interfaces = os.listdir('/sys/class/net')
device = self.params.get("interface", default=None)
self.hbond = self.params.get("hbond", default=False)
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.iface = device
elif localhost.validate_mac_addr(device) and device in localhost.get_all_hwaddr():
self.iface = localhost.get_interface_by_hwaddr(device).name
elif (localhost.validate_mac_addr(device) and
device in localhost.get_all_hwaddr()):
if self.hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = localhost.get_interface_by_hwaddr(device)
if iface.is_bond():
self.iface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.iface = bond_master
else:
# regular interface identified by MAC address
self.iface = localhost.get_interface_by_hwaddr(device).name
else:
self.cancel("%s interface is not available" % device)
self.count = self.params.get("count", default=500)
Expand All @@ -55,7 +73,6 @@ def setUp(self):
self.drop = self.params.get("drop_accepted", default=10)
self.host_ip = self.params.get("host_ip", default="")
self.option = self.params.get("option", default='')
self.hbond = self.params.get("hbond", default=False)
# Check if interface exists in the system
if not self.peer_ip:
self.cancel("peer ip should specify in input")
Expand Down Expand Up @@ -87,13 +104,16 @@ def setUp(self):
self.peer_ip).name
self.peer_networkinterface = NetworkInterface(self.peer_interface,
self.remotehost)
self.remotehost_public = RemoteHost(self.peer_public_ip, self.peer_user,
self.remotehost_public = RemoteHost(self.peer_public_ip,
self.peer_user,
password=self.peer_password)
self.peer_public_networkinterface = NetworkInterface(self.peer_interface,
self.remotehost_public)
if self.peer_networkinterface.set_mtu(self.mtu, timeout=self.mtu_timeout) is not None:
self.peer_public_networkinterface = NetworkInterface(
self.peer_interface, self.remotehost_public)
if self.peer_networkinterface.set_mtu(
self.mtu, timeout=self.mtu_timeout) is not None:
self.cancel("Failed to set mtu in peer")
if self.networkinterface.set_mtu(self.mtu, timeout=self.mtu_timeout) is not None:
if self.networkinterface.set_mtu(
self.mtu, timeout=self.mtu_timeout) is not None:
self.cancel("Failed to set mtu in host")

# Install needed packages
Expand All @@ -108,13 +128,13 @@ def setUp(self):
if detected_distro.name == "SuSE":
self.nmap = os.path.join(self.teststmpdir, 'nmap')
if detected_distro.version == 16:
nmap_download = self.params.get("nmap_download", default="https:"
"//nmap.org/dist/"
"nmap-7.95.tar.bz2")
nmap_download = self.params.get(
"nmap_download",
default="https://nmap.org/dist/nmap-7.95.tar.bz2")
else:
nmap_download = self.params.get("nmap_download", default="https:"
"//nmap.org/dist/"
"nmap-7.80.tar.bz2")
nmap_download = self.params.get(
"nmap_download",
default="https://nmap.org/dist/nmap-7.80.tar.bz2")
tarball = self.fetch_asset(nmap_download)
self.version = os.path.basename(tarball.split('.tar')[0])
self.n_map = os.path.join(self.nmap, self.version)
Expand Down Expand Up @@ -176,7 +196,8 @@ def tearDown(self):
unset ip for host interface
'''
if self.networkinterface:
if self.networkinterface.set_mtu('1500', timeout=self.mtu_timeout) is not None:
if self.networkinterface.set_mtu(
'1500', timeout=self.mtu_timeout) is not None:
self.cancel("Failed to set mtu in host")
try:
self.peer_networkinterface.set_mtu(
Expand Down
20 changes: 18 additions & 2 deletions io/net/uperf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,32 @@ def setUp(self):
self.peer_password = self.params.get("peer_password", '*',
default="None")
device = self.params.get("interface", default=None)
self.hbond = self.params.get("hbond", default=False)
if device in interfaces:
# interface name given directly (bond name or regular interface)
self.iface = device
elif (local.validate_mac_addr(device) and
device in local.get_all_hwaddr()):
self.iface = local.get_interface_by_hwaddr(device).name
if self.hbond:
# is_bond() tells if MAC hit the bond master directly.
iface = local.get_interface_by_hwaddr(device)
if iface.is_bond():
self.iface = iface.name
else:
# got the slave; resolve its bond master
bond_master = iface.get_bond_master()
if not bond_master:
self.cancel(
"Could not resolve bond master for slave %s"
% iface.name)
self.iface = bond_master
else:
# regular interface identified by MAC address
self.iface = local.get_interface_by_hwaddr(device).name
else:
self.cancel("%s interface is not available" % device)
self.ipaddr = self.params.get("host_ip", default="")
self.netmask = self.params.get("netmask", default="")
self.hbond = self.params.get("hbond", default=False)
if self.hbond:
self.networkinterface = NetworkInterface(self.iface, local,
if_type='Bond')
Expand Down
Loading
Loading