def tearDown(self): if not configure_network.set_mtu_host(self.iface, '1500'): self.fail("Failed to set mtu in host") if not self.peerinfo.set_mtu_peer(self.peer_interface, '1500'): self.fail("Failed to set mtu in peer") time.sleep(10) configure_network.unset_ip(self.iface)
def setUp(self): """ Set up. """ self.iface = self.params.get("interface", default="") self.count = self.params.get("count", default="500") self.nping_count = self.params.get("nping_count", default="") self.peer_ip = self.params.get("peer_ip", default="") 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='') # Check if interface exists in the system interfaces = netifaces.interfaces() if self.iface not in interfaces: self.cancel("%s interface is not available" % self.iface) if not self.peer_ip: self.cancel("peer ip should specify in input") 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.cancel( "Link up of interface is taking longer than 120 seconds") self.peer_user = self.params.get("peer_user", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") self.mtu = self.params.get("mtu", default=1500) self.peerinfo = PeerInfo(self.peer_ip, peer_user=self.peer_user, peer_password=self.peer_password) self.peer_interface = self.peerinfo.get_peer_interface(self.peer_ip) if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.cancel("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): 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'] for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("%s package Can not install" % pkg) if detected_distro.name == "SuSE": self.nmap = os.path.join(self.teststmpdir, 'nmap') 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) archive.extract(tarball, self.nmap) os.chdir(self.n_map) process.system('./configure ppc64le', shell=True) build.make(self.n_map) process.system('./nping/nping -h', shell=True)
def test(self): """ Test udaddy """ if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.fail("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): self.fail("Failed to set mtu in host") self.log.info(self.test_name) logs = "> /tmp/ib_log 2>&1 &" cmd = " timeout %s %s -b %s %s %s" % (self.timeout, self.test_name, self.peer_ip, self.option, logs) output = self.session.cmd(cmd) if not output.exit_status == 0: self.fail("SSH connection (or) Server command failed") time.sleep(5) self.log.info("Client data - %s(%s)" % (self.test_name, self.option)) cmd = "timeout %s %s -s %s -b %s %s" \ % (self.timeout, self.test_name, self.peer_ip, self.local_ip, self.option) if process.system(cmd, shell=True, ignore_status=True) != 0: self.fail("Client command failed") time.sleep(5) self.log.info("Server data - %s(%s)" % (self.test_name, self.option)) cmd = "timeout %s cat /tmp/ib_log && rm -rf /tmp/ib_log" \ % (self.timeout) output = self.session.cmd(cmd) if not output.exit_status == 0: self.fail("Server output retrieval failed")
def test_ib_pingpong(self): ''' test options are mandatory ext test options are depends upon user ''' # change MTU to 9000 for non-IB tests if "ib" not in self.iface and self.tool_name == "ibv_ud_pingpong": self.mtu = "9000" if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.fail("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): self.fail("Failed to set mtu in host") time.sleep(10) val1 = "" val2 = "" test_op = self.params.get("test_opt", default="").split(",") for val in test_op: try: val1, val2 = val.split() except ValueError: pass self.pingpong_exec(self.tool_name, val1, val2) ext_test_op = self.params.get("ext_test_opt", default="").split(",") if self.flag == "1": for val in ext_test_op: self.pingpong_exec(self.tool_name, val, "") else: self.log.info("Extended test option skipped")
def mtu_set(self): ''' set mtu size ''' if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.cancel("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): self.cancel("Failed to set mtu in host")
def mtu_set_back(self): ''' Test set mtu back to 1500 ''' if not configure_network.set_mtu_host(self.iface, '1500'): self.cancel("Failed to set mtu in host") if not self.peerinfo.set_mtu_peer(self.peer_interface, '1500'): self.cancel("Failed to set mtu in peer")
def tearDown(self): ''' unset ip for host interface ''' if not configure_network.set_mtu_host(self.iface, '1500'): self.cancel("Failed to set mtu in host") if not self.peerinfo.set_mtu_peer(self.peer_interface, '1500'): self.cancel("Failed to set mtu in peer") configure_network.unset_ip(self.iface)
def test(self): ''' test options are mandatory ''' if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.fail("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): self.fail("Failed to set mtu in host") if self.rdma_exec(self.tool_name, self.test_op, "") != 0: self.fail("Client cmd: %s %s" % (self.tool_name, self.test_op))
def tearDown(self): """ removing the data in peer machine """ cmd = "pkill netserver; rm -rf /tmp/%s" % self.version output = self.session.cmd(cmd) if not output.exit_status == 0: self.fail("test failed because peer sys not connected") if not configure_network.set_mtu_host(self.iface, '1500'): self.cancel("Failed to set mtu in host") if not self.peerinfo.set_mtu_peer(self.peer_interface, '1500'): self.cancel("Failed to set mtu in peer") configure_network.unset_ip(self.iface)
def tearDown(self): ''' unset ip for host interface ''' for host_interface in self.host_interfaces: if not configure_network.set_mtu_host(host_interface, '1500'): self.cancel("Failed to set mtu in host") for peer_ip in self.peer_ips: self.peer_interface = self.peerinfo.get_peer_interface(peer_ip) if not self.peerinfo.set_mtu_peer(self.peer_interface, '1500'): self.cancel("Failed to set mtu in peer") for interface in self.host_interfaces: configure_network.unset_ip(interface)
def tearDown(self): """ Killing Uperf process in peer machine """ cmd = "pkill uperf; rm -rf /tmp/uperf-master" output = self.session.cmd(cmd) if not output.exit_status == 0: self.fail("Either the ssh to peer machine machine\ failed or uperf process was not killed") if not configure_network.set_mtu_host(self.iface, '1500'): self.cancel("Failed to set mtu in host") if not self.peerinfo.set_mtu_peer(self.peer_interface, '1500'): self.cancel("Failed to set mtu in peer") configure_network.unset_ip(self.iface)
def setUp(self): ''' To check and install dependencies for the test ''' self.host_interfaces = self.params.get("host_interfaces", default="").split(",") if not self.host_interfaces: self.cancel("user should specify host interfaces") smm = SoftwareManager() if distro.detect().name == 'Ubuntu': pkg = 'iputils-ping' else: pkg = 'iputils' if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("Package %s is needed to test" % pkg) self.peer_ips = self.params.get("peer_ips", default="").split(",") interfaces = netifaces.interfaces() for self.host_interface in self.host_interfaces: if self.host_interface not in interfaces: self.cancel("interface is not available") self.count = self.params.get("count", default="1000") self.ipaddr = self.params.get("host_ips", default="").split(",") self.netmask = self.params.get("netmask", default="") for ipaddr, interface in zip(self.ipaddr, self.host_interfaces): configure_network.set_ip(ipaddr, self.netmask, interface) self.peer_user = self.params.get("peer_user", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") self.mtu = self.params.get("mtu", default=1500) self.peerinfo = PeerInfo(self.peer_ips[0], peer_user=self.peer_user, peer_password=self.peer_password) for peer_ip in self.peer_ips: self.peer_interface = self.peerinfo.get_peer_interface(peer_ip) if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.cancel("Failed to set mtu in peer") for host_interface in self.host_interfaces: if not configure_network.set_mtu_host(host_interface, self.mtu): self.cancel("Failed to set mtu in host")
def run(test, params, env): """ Expose host MTU to guest test 1) Boot up guest with param 'host_mtu=4000' in nic part 2) Disable NetworkManager in guest 3) set mtu of guest tap (eg: tap0) and physical nic (eg: eno1) to 4000 in host 4) check the mtu in guest 5) ping from guest to external host with packet size 3972 :param test: kvm test object :param params: Dictionary with the test parameters :param env: Dictionary with test environment """ def cleanup_ovs_ports(netdst, ports): """ Clean up created ovs ports in this case :param netdst: netdst get from command line :param ports: existing ports need to be remain before this test """ host_bridge = utils_net.find_bridge_manager(netdst) if utils_net.ovs_br_exists(netdst) is True: ports = set(host_bridge.list_ports(netdst)) - set(ports) for p in ports: utils_net.find_bridge_manager(netdst).del_port(netdst, p) netdst = params.get("netdst", "switch") mtu_value = params.get_numeric("mtu_value") host_bridge = utils_net.find_bridge_manager(netdst) localhost = LocalHost() try: if netdst in utils_net.Bridge().list_br(): host_hw_interface = utils_net.Bridge().list_iface(netdst)[0] else: host_hw_interface = host_bridge.list_ports(netdst) tmp_ports = re.findall(r"t[0-9]{1,}-[a-zA-Z0-9]{6}", ' '.join(host_hw_interface)) if tmp_ports: for p in tmp_ports: host_bridge.del_port(netdst, p) host_hw_interface = host_bridge.list_ports(netdst) except IndexError: host_hw_interface = netdst params["start_vm"] = "yes" env_process.preprocess_vm(test, params, env, params["main_vm"]) vm = env.get_vm(params["main_vm"]) vm.verify_alive() vm_iface = vm.get_ifname() # Get host interface original mtu value before setting if netdst in utils_net.Bridge().list_br(): host_hw_iface = NetworkInterface(host_hw_interface, localhost) elif utils_net.ovs_br_exists(netdst) is True: host_hw_iface = NetworkInterface(' '.join(host_hw_interface), localhost) host_mtu_origin = host_hw_iface.get_mtu() set_mtu_host(vm_iface, mtu_value) host_hw_iface.set_mtu(mtu_value) os_type = params.get("os_type", "linux") login_timeout = float(params.get("login_timeout", 360)) session = vm.wait_for_login(timeout=login_timeout) host_ip = utils_net.get_ip_address_by_interface(params["netdst"]) if os_type == "linux": session.cmd_output_safe(params["nm_stop_cmd"]) guest_ifname = utils_net.get_linux_ifname(session, vm.get_mac_address()) output = session.cmd_output_safe(params["check_linux_mtu_cmd"] % guest_ifname) error_context.context(output, logging.info) match_string = "mtu %s" % params["mtu_value"] if match_string not in output: test.fail("host mtu %s not exposed to guest" % params["mtu_value"]) elif os_type == "windows": connection_id = utils_net.get_windows_nic_attribute( session, "macaddress", vm.get_mac_address(), "netconnectionid") output = session.cmd_output_safe(params["check_win_mtu_cmd"] % connection_id) error_context.context(output, logging.info) lines = output.strip().splitlines() lines_len = len(lines) line_table = lines[0].split(' ') line_value = lines[2].split(' ') while '' in line_table: line_table.remove('') while '' in line_value: line_value.remove('') index = 0 for name in line_table: if re.findall("MTU", name): break index += 1 guest_mtu_value = line_value[index] logging.info("MTU is %s", guest_mtu_value) if not int(guest_mtu_value) == mtu_value: test.fail("Host mtu %s is not exposed to " "guest!" % params["mtu_value"]) logging.info("Ping from guest to host with packet size 3972") status, output = utils_test.ping(host_ip, 10, packetsize=3972, timeout=30, session=session) ratio = utils_test.get_loss_ratio(output) if ratio != 0: test.fail("Loss ratio is %s", ratio) # Restore host mtu after finish testing set_mtu_host(vm_iface, host_mtu_origin) host_hw_iface.set_mtu(host_mtu_origin) if netdst not in utils_net.Bridge().list_br(): cleanup_ovs_ports(netdst, host_hw_interface) session.close()
def setUp(self): """ To check and install dependencies for the test """ self.peer_ip = self.params.get("peer_ip", default="") self.peer_user = self.params.get("peer_user_name", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") interfaces = netifaces.interfaces() self.iface = self.params.get("interface", default="") if self.iface not in interfaces: self.cancel("%s interface is not available" % self.iface) 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) self.session = Session(self.peer_ip, user=self.peer_user, password=self.peer_password) smm = SoftwareManager() detected_distro = distro.detect() pkgs = ["gcc", "autoconf", "perl", "m4", "git-core", "automake"] if detected_distro.name == "Ubuntu": pkgs.extend(["libsctp1", "libsctp-dev", "lksctp-tools"]) else: pkgs.extend(["lksctp-tools", "lksctp-tools-devel"]) for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("%s package is need to test" % pkg) cmd = "%s install %s" % (smm.backend.base_command, pkg) output = self.session.cmd(cmd) if not output.exit_status == 0: self.cancel( "unable to install the package %s on peer machine " % pkg) if self.peer_ip == "": self.cancel("%s peer machine is not available" % self.peer_ip) self.mtu = self.params.get("mtu", default=1500) self.peerinfo = PeerInfo(self.peer_ip, peer_user=self.peer_user, peer_password=self.peer_password) self.peer_interface = self.peerinfo.get_peer_interface(self.peer_ip) if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.cancel("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): self.cancel("Failed to set mtu in host") uperf_download = self.params.get("uperf_download", default="https:" "//github.com/uperf/uperf/" "archive/master.zip") tarball = self.fetch_asset("uperf.zip", locations=[uperf_download], expire='7d') archive.extract(tarball, self.teststmpdir) self.uperf_dir = os.path.join(self.teststmpdir, "uperf-master") cmd = "scp -r %s %s@%s:/tmp" % (self.uperf_dir, self.peer_user, self.peer_ip) if process.system(cmd, shell=True, ignore_status=True) != 0: self.cancel("unable to copy the uperf into peer machine") cmd = "cd /tmp/uperf-master;autoreconf -fi;./configure ppc64le;make" output = self.session.cmd(cmd) if not output.exit_status == 0: self.cancel("Unable to compile Uperf into peer machine") self.uperf_run = str(self.params.get("UPERF_SERVER_RUN", default=0)) if self.uperf_run == '1': cmd = "/tmp/uperf-master/src/uperf -s &" output = self.session.cmd(cmd) if not output.exit_status == 0: self.log.debug("Command %s failed %s", cmd, output) os.chdir(self.uperf_dir) process.system('autoreconf -fi', shell=True) process.system('./configure ppc64le', shell=True) build.make(self.uperf_dir) self.expected_tp = self.params.get("EXPECTED_THROUGHPUT", default="85")
def setUp(self): """ To check and install dependencies for the test """ self.peer_user = self.params.get("peer_user_name", default="root") self.peer_ip = self.params.get("peer_ip", default="") self.peer_password = self.params.get("peer_password", '*', default="None") interfaces = netifaces.interfaces() self.iface = self.params.get("interface", default="") if self.iface not in interfaces: self.cancel("%s interface is not available" % self.iface) 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) self.session = Session(self.peer_ip, user=self.peer_user, password=self.peer_password) smm = SoftwareManager() detected_distro = distro.detect() pkgs = ['gcc'] if detected_distro.name == "Ubuntu": pkgs.append('openssh-client') elif detected_distro.name == "SuSE": pkgs.append('openssh') else: pkgs.append('openssh-clients') for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("%s package is need to test" % pkg) cmd = "%s install %s" % (smm.backend.base_command, pkg) output = self.session.cmd(cmd) if not output.exit_status == 0: self.cancel( "unable to install the package %s on peer machine " % pkg) if self.peer_ip == "": self.cancel("%s peer machine is not available" % self.peer_ip) self.timeout = self.params.get("TIMEOUT", default="600") self.mtu = self.params.get("mtu", default=1500) self.peerinfo = PeerInfo(self.peer_ip, peer_user=self.peer_user, peer_password=self.peer_password) self.peer_interface = self.peerinfo.get_peer_interface(self.peer_ip) if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.cancel("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): self.cancel("Failed to set mtu in host") self.netperf_run = str(self.params.get("NETSERVER_RUN", default=0)) self.netperf = os.path.join(self.teststmpdir, 'netperf') netperf_download = self.params.get("netperf_download", default="https:" "//github.com/HewlettPackard/" "netperf/archive/netperf-2.7.0.zip") tarball = self.fetch_asset(netperf_download, expire='7d') archive.extract(tarball, self.netperf) self.version = "%s-%s" % ("netperf", os.path.basename(tarball.split('.zip')[0])) self.neperf = os.path.join(self.netperf, self.version) cmd = "scp -r %s %s@%s:/tmp/" % (self.neperf, self.peer_user, self.peer_ip) if process.system(cmd, shell=True, ignore_status=True) != 0: self.cancel("unable to copy the netperf into peer machine") cmd = "cd /tmp/%s;./configure ppc64le;make" % self.version output = self.session.cmd(cmd) if not output.exit_status == 0: self.fail("test failed because command failed in peer machine") os.chdir(self.neperf) process.system('./configure ppc64le', shell=True) build.make(self.neperf) self.perf = os.path.join(self.neperf, 'src', 'netperf') self.expected_tp = self.params.get("EXPECTED_THROUGHPUT", default="90") self.duration = self.params.get("duration", default="300") self.min = self.params.get("minimum_iterations", default="1") self.max = self.params.get("maximum_iterations", default="15") self.option = self.params.get("option", default='')
def setUp(self): """ To check and install dependencies for the test """ self.peer_user = self.params.get("peer_user_name", default="root") self.peer_ip = self.params.get("peer_ip", default="") self.peer_password = self.params.get("peer_password", '*', default=None) interfaces = netifaces.interfaces() self.iface = self.params.get("interface", default="") if self.iface not in interfaces: self.cancel("%s interface is not available" % self.iface) 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) self.session = Session(self.peer_ip, user=self.peer_user, password=self.peer_password) smm = SoftwareManager() for pkg in ["gcc", "autoconf", "perl", "m4", "libtool"]: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("%s package is need to test" % pkg) cmd = "%s install %s" % (smm.backend.base_command, pkg) output = self.session.cmd(cmd) if not output.exit_status == 0: self.cancel( "unable to install the package %s on peer machine " % pkg) if self.peer_ip == "": self.cancel("%s peer machine is not available" % self.peer_ip) self.mtu = self.params.get("mtu", default=1500) self.peerinfo = PeerInfo(self.peer_ip, peer_user=self.peer_user, peer_password=self.peer_password) self.peer_interface = self.peerinfo.get_peer_interface(self.peer_ip) if not self.peerinfo.set_mtu_peer(self.peer_interface, self.mtu): self.cancel("Failed to set mtu in peer") if not configure_network.set_mtu_host(self.iface, self.mtu): self.cancel("Failed to set mtu in host") self.iperf = os.path.join(self.teststmpdir, 'iperf') iperf_download = self.params.get("iperf_download", default="https:" "//excellmedia.dl.sourceforge.net/" "project/iperf2/iperf-2.0.13.tar.gz") tarball = self.fetch_asset(iperf_download, expire='7d') archive.extract(tarball, self.iperf) self.version = os.path.basename(tarball.split('.tar')[0]) self.iperf_dir = os.path.join(self.iperf, self.version) cmd = "scp -r %s %s@%s:/tmp" % (self.iperf_dir, self.peer_user, self.peer_ip) if process.system(cmd, shell=True, ignore_status=True) != 0: self.cancel("unable to copy the iperf into peer machine") cmd = "cd /tmp/%s;./configure ppc64le;make" % self.version output = self.session.cmd(cmd) if not output.exit_status == 0: self.cancel("Unable to compile Iperf into peer machine") self.iperf_run = str(self.params.get("IPERF_SERVER_RUN", default=0)) if self.iperf_run == '1': cmd = "/tmp/%s/src/iperf -s" % self.version cmd = self.session.get_raw_ssh_command(cmd) self.obj = SubProcess(cmd) self.obj.start() os.chdir(self.iperf_dir) process.system('./configure', shell=True) build.make(self.iperf_dir) self.iperf = os.path.join(self.iperf_dir, 'src') self.expected_tp = self.params.get("EXPECTED_THROUGHPUT", default="85")