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
36 changes: 26 additions & 10 deletions io/net/network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def setUp(self):
device = self.params.get("interface")
if device in interfaces:
self.interface = device
elif local.validate_mac_addr(device) and device in local.get_all_hwaddr():
elif (local.validate_mac_addr(device) and
device in local.get_all_hwaddr()):
self.interface = local.get_interface_by_hwaddr(device).name
else:
self.interface = None
Expand All @@ -70,6 +71,19 @@ def setUp(self):
self.ip_config = self.params.get("ip_config", default=True)
self.hbond = self.params.get("hbond", default=False)
if self.hbond:
# When hbond is True and interface is a slave, get the bond
# master
slave_interface = NetworkInterface(self.interface, local)
try:
bond_master = slave_interface._get_bondingmaster()
self.log.info(f"Detected bond master '{bond_master}' for "
f"slave interface '{self.interface}'")
self.interface = bond_master
except Exception as exc:
self.log.warning(f"Could not detect bond master for "
f"'{self.interface}': {exc}")
self.log.info(f"Assuming '{self.interface}' is already a "
f"bond interface")
self.networkinterface = NetworkInterface(
self.interface, local, if_type='Bond')
else:
Expand Down Expand Up @@ -103,10 +117,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 +222,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 +260,10 @@ 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 Expand Up @@ -346,7 +363,6 @@ def tearDown(self):
self.log.info(
"backup file not available, could not restore file.")
self.remotehost.remote_session.quit()
if hasattr(self, 'remotehost_public'):
self.remotehost_public.remote_session.quit()
self.remotehost_public.remote_session.quit()
if 'scp' or 'ssh' in str(self.name.name):
self.session.quit()
57 changes: 39 additions & 18 deletions io/net/tcpdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def setUp(self):
device = self.params.get("interface", default=None)
if device in interfaces:
self.iface = device
elif localhost.validate_mac_addr(device) and device in localhost.get_all_hwaddr():
elif (localhost.validate_mac_addr(device) and
device in localhost.get_all_hwaddr()):
self.iface = localhost.get_interface_by_hwaddr(device).name
else:
self.cancel("%s interface is not available" % device)
Expand All @@ -62,8 +63,21 @@ def setUp(self):
self.ipaddr = self.params.get("host_ip", default="")
self.netmask = self.params.get("netmask", default="")
if self.hbond:
self.networkinterface = NetworkInterface(self.iface, localhost,
if_type='Bond')
# When hbond is True and interface is a slave, get the bond
# master
slave_interface = NetworkInterface(self.iface, localhost)
try:
bond_master = slave_interface._get_bondingmaster()
self.log.info(f"Detected bond master '{bond_master}' for "
f"slave interface '{self.iface}'")
self.iface = bond_master
except Exception as exc:
self.log.warning(f"Could not detect bond master for "
f"'{self.iface}': {exc}")
self.log.info(f"Assuming '{self.iface}' is already a bond "
f"interface")
self.networkinterface = NetworkInterface(
self.iface, localhost, if_type='Bond')
else:
self.networkinterface = NetworkInterface(self.iface, localhost)
try:
Expand All @@ -87,34 +101,40 @@ 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
smm = SoftwareManager()
detected_distro = distro.detect()
pkgs = ['tcpdump', 'flex', 'bison', 'gcc', 'gcc-c++', 'nmap']
if detected_distro.name == "SuSE" and detected_distro.version == 16:
if (detected_distro.name == "SuSE" and
detected_distro.version == 16):
pkgs.extend(["pcre2-devel"])
for pkg in pkgs:
if not smm.check_installed(pkg) and not smm.install(pkg):
self.cancel("Cannot install package: %s" % pkg)
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,9 @@ 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 All @@ -192,5 +214,4 @@ def tearDown(self):
self.log.info(
"backup file not available, could not restore file.")
self.remotehost.remote_session.quit()
if hasattr(self, 'remotehost_public'):
self.remotehost_public.remote_session.quit()
self.remotehost_public.remote_session.quit()
Loading