def test_promisc(self):
     '''
     promisc mode testing
     '''
     cmd = "ip link set %s promisc on" % self.iface
     if process.system(cmd, shell=True, ignore_status=True) != 0:
         self.fail("failed to enable promisc mode")
     configure_network.ping_check(self.iface, self.peer,
                                  "100000", flood=True)
     cmd = "ip link set %s promisc off" % self.iface
     if process.system(cmd, shell=True, ignore_status=True) != 0:
         self.fail("failed to disable promisc mode")
     configure_network.ping_check(self.iface, self.peer, "5")
 def ethtool_toggle_priv_flags(self):
     '''
     Toggle the priv flag settings of the driver.
     '''
     priv_pass = []
     priv_fail = []
     for oper in ('toggle', 'setback'):
         for line in self.ret_val.stdout_text.splitlines():
             if "off" in line:
                 val = "on"
             else:
                 val = "off"
             if "flags" not in line:
                 priv_flag = line.split(':')[0]
                 cmd = "ethtool --set-priv-flags %s \"%s\" %s" % \
                       (self.iface, priv_flag.rstrip(), val)
                 ret1 = process.run(cmd, shell=True, verbose=True,
                                    ignore_status=True)
                 if ret1.exit_status == 0 or 'supported' in \
                    ret1.stderr_text:
                     priv_pass.append(priv_flag.rstrip())
                 else:
                     priv_fail.append(priv_flag.rstrip())
         if not configure_network.ping_check(self.iface, self.peer,
                                             '500000', flood=True):
             self.fail("Ping failed oper = %s" % oper)
     if priv_fail:
         self.fail("Private flags could not be toggled: %s" %
                   ",".join(list(set(priv_fail))))
예제 #3
0
 def module_load_unload(self, mod1):
     """
     Unloading and loading the given module
     """
     if linux_modules.module_is_loaded(mod1) is False:
         linux_modules.load_module(mod1)
         time.sleep(self.load_unload_sleep_time)
     sub_mod = linux_modules.get_submodules(mod1)
     if sub_mod:
         for mod in sub_mod:
             linux_modules.unload_module(mod)
             if linux_modules.module_is_loaded(mod) is True:
                 self.error_modules.append(mod)
                 break
     if linux_modules.unload_module(mod1) is False:
         self.fail("Unloading Module %s failed" % mod1)
     time.sleep(self.load_unload_sleep_time)
     cmd = "%s %s=%s" % (mod1, self.param_name, self.param_value)
     if linux_modules.load_module(cmd) is False:
         self.fail("Param %s = Value %s Failed for Module %s" %
                   (self.param_name, self.param_value, mod1))
     time.sleep(self.load_unload_sleep_time)
     if self.sysfs_chk:
         if self.sysfs_value_check() is False:
             self.fail("Sysfs check failed ")
     if not wait.wait_for(configure_network.is_interface_link_up,
                          timeout=120,
                          args=[self.ifaces]):
         self.fail("Link up of interface is taking longer than 120s")
     if not configure_network.ping_check(
             self.ifaces, self.peer, '1000', flood=True):
         self.fail("ping test failed")
 def test_statistics(self):
     '''
     Test Statistics
     '''
     rx_file = "/sys/class/net/%s/statistics/rx_packets" % self.iface
     tx_file = "/sys/class/net/%s/statistics/tx_packets" % self.iface
     rx_before = genio.read_file(rx_file)
     tx_before = genio.read_file(tx_file)
     configure_network.ping_check(self.iface, self.peer, "500000",
                                  flood=True)
     rx_after = genio.read_file(rx_file)
     tx_after = genio.read_file(tx_file)
     if (rx_after <= rx_before) or (tx_after <= tx_before):
         self.log.debug("Before\nrx: %s tx: %s" % (rx_before, tx_before))
         self.log.debug("After\nrx: %s tx: %s" % (rx_after, tx_after))
         self.fail("Statistics not incremented properly")
 def test_floodping(self):
     '''
     Flood ping to peer machine
     '''
     if not configure_network.ping_check(self.iface, self.peer,
                                         '500000', flood=True):
         self.fail("flood ping test failed")
 def test_jumbo_frame(self):
     '''
     Test jumbo frames
     '''
     if not configure_network.ping_check(self.iface, self.peer, "30",
                                         option='-i 0.1 -s %d'
                                         % (int(self.mtu) - 28)):
         self.fail("jumbo frame test failed")
예제 #7
0
 def offload_toggle_test(self, ro_type, ro_type_full):
     '''
     Check to toggle the LRO / GRO / GSO / TSO
     '''
     for state in ["off", "on"]:
         if not self.offload_state_change(ro_type, ro_type_full, state):
             self.fail("%s %s failed" % (ro_type, state))
         if not configure_network.ping_check(
                 self.iface, self.peer, "500000", flood=True):
             self.fail("ping failed in %s %s" % (ro_type, state))
예제 #8
0
 def setUp(self):
     '''
     To check and install dependencies for the test
     '''
     smm = SoftwareManager()
     pkgs = ["ethtool", "net-tools"]
     detected_distro = distro.detect()
     if detected_distro.name == "Ubuntu":
         pkgs.extend(["iputils-ping"])
     elif detected_distro.name == "SuSE":
         pkgs.extend(["iputils"])
     else:
         pkgs.extend(["iputils"])
     for pkg in pkgs:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel("%s package is need to test" % pkg)
     interfaces = netifaces.interfaces()
     interface = self.params.get("interface")
     if interface not in interfaces:
         self.cancel("%s interface is not available" % interface)
     self.iface = interface
     self.ipaddr = self.params.get("host_ip", default="")
     self.netmask = self.params.get("netmask", default="")
     self.peer = self.params.get("peer_ip")
     if not self.peer:
         self.cancel("No peer provided")
     if self.iface[0:2] == 'ib':
         configure_network.set_ip(self.ipaddr,
                                  self.netmask,
                                  self.iface,
                                  interface_type='Infiniband')
     else:
         configure_network.set_ip(self.ipaddr,
                                  self.netmask,
                                  self.iface,
                                  interface_type='Ethernet')
     if not configure_network.ping_check(self.iface, self.peer, "5"):
         self.cancel("No connection to peer")
     self.args = self.params.get("arg", default='')
     self.elapse = self.params.get("action_elapse", default='')
     self.priv_test = self.params.get("privflag_test", default=False)
     if self.priv_test:
         cmd = "ethtool --show-priv-flags %s" % (self.iface)
         self.ret_val = process.run(cmd,
                                    shell=True,
                                    verbose=True,
                                    ignore_status=True)
         if self.ret_val.exit_status:
             self.cancel("Device Doesn't support Private flags")
 def test_ethtool(self):
     '''
     Test the ethtool args provided
     '''
     for state, status in zip(["down", "up"], ["no", "yes"]):
         if not self.interface_state_change(self.iface, state, status):
             self.fail("interface %s failed" % state)
         cmd = "ethtool %s %s %s" % (self.args, self.iface, self.elapse)
         ret = process.run(cmd, shell=True, verbose=True,
                           ignore_status=True)
         if ret.exit_status != 0:
             self.fail("failed")
     if not configure_network.ping_check(self.iface, self.peer,
                                         '10000', flood=True):
         self.fail("flood ping test failed")
     if self.priv_test:
         self.ethtool_toggle_priv_flags()
 def setUp(self):
     '''
     To check and install dependencies for the test
     '''
     smm = SoftwareManager()
     pkgs = ["ethtool", "net-tools"]
     detected_distro = distro.detect()
     if detected_distro.name == "Ubuntu":
         pkgs.extend(["openssh-client", "iputils-ping"])
     elif detected_distro.name == "SuSE":
         pkgs.extend(["openssh", "iputils"])
     else:
         pkgs.extend(["openssh-clients", "iputils"])
     for pkg in pkgs:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel("%s package is need to test" % pkg)
     interfaces = netifaces.interfaces()
     interface = self.params.get("interface")
     if interface not in interfaces:
         self.cancel("%s interface is not available" % interface)
     self.iface = interface
     self.ipaddr = self.params.get("host_ip", default="")
     self.netmask = self.params.get("netmask", default="")
     configure_network.set_ip(self.ipaddr, self.netmask, self.iface)
     if not wait.wait_for(configure_network.is_interface_link_up,
                          timeout=120, args=[self.iface]):
         self.fail("Link up of interface is taking longer than 120 seconds")
     self.peer = self.params.get("peer_ip")
     if not self.peer:
         self.cancel("No peer provided")
     self.mtu = self.params.get("mtu", default=1500)
     self.peer_user = self.params.get("peer_user", default="root")
     self.peer_password = self.params.get("peer_password", '*',
                                          default=None)
     self.peerinfo = PeerInfo(self.peer, peer_user=self.peer_user,
                              peer_password=self.peer_password)
     self.peer_interface = self.peerinfo.get_peer_interface(self.peer)
     self.mtu = self.params.get("mtu", default=1500)
     self.mtu_set()
     if not wait.wait_for(configure_network.is_interface_link_up,
                          timeout=120, args=[self.iface]):
         self.fail("Link up of interface is taking longer than 120 seconds")
     if not configure_network.ping_check(self.iface, self.peer, "5"):
         self.cancel("No connection to peer")
 def test_ping(self):
     '''
     ping to peer machine
     '''
     if not configure_network.ping_check(self.iface, self.peer, '10'):
         self.fail("ping test failed")