Esempio n. 1
0
 def test_targetconfig(self):
     """
     Configures the peer NVMf.
     """
     self.session = Session(self.peer_ips[0],
                            user=self.peer_user,
                            password=self.peer_password)
     if not self.session.connect():
         self.fail("failed connecting to peer")
     self.create_cfg_file()
     destination = "%s:/tmp/" % self.peer_ips[0]
     output = self.session.copy_files(self.cfg_file, destination)
     if not output:
         self.cancel("unable to copy the NVMf cfg file into peer machine")
     for mdl in ["nvmet", "nvmet-rdma"]:
         cmd = "modprobe %s" % mdl
         output = self.session.cmd(cmd)
         if output.exit_status:
             self.cancel("%s is not loadable on the peer" % mdl)
     msg = "which nvmetcli"
     output = self.session.cmd(msg)
     if output.exit_status:
         self.cancel("nvmetcli is not installed on the peer")
     msg = "nvmetcli restore /tmp/nvmf.cfg"
     output = self.session.cmd(msg)
     if output.exit_status:
         self.fail("nvmetcli setup config fails on peer")
    def setUp(self):
        '''
        To check and install dependencies for the test
        '''
        self.peer = self.params.get("peer_ip", default="")
        self.user = self.params.get("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="")
        self.hbond = self.params.get("hbond", default=False)
        local = LocalHost()
        if self.hbond:
            self.networkinterface = NetworkInterface(self.iface, local,
                                                     if_type='Bond')
        else:
            self.networkinterface = NetworkInterface(self.iface, local)
        try:
            self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
            self.networkinterface.save(self.ipaddr, self.netmask)
        except Exception:
            self.networkinterface.save(self.ipaddr, self.netmask)
        self.networkinterface.bring_up()

        self.session = Session(self.peer, user=self.user,
                               password=self.peer_password)
        if not self.session.connect():
            self.cancel("failed connecting to peer")
        self.count = self.params.get("count", default="500000")
        smm = SoftwareManager()
        pkgs = ["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)
        if self.peer == "":
            self.cancel("peer ip should specify in input")
        cmd = "ip addr show  | grep %s" % self.peer
        output = self.session.cmd(cmd)
        result = ""
        result = result.join(output.stdout.decode("utf-8"))
        self.peerif = result.split()[-1]
        if self.peerif == "":
            self.cancel("unable to get peer interface")
        cmd = "ip -f inet -o addr show %s | awk '{print $4}' | cut -d / -f1"\
              % self.iface
        self.local_ip = process.system_output(cmd, shell=True).strip()
        if self.local_ip == "":
            self.cancel("unable to get local ip")
Esempio n. 3
0
 def setUp(self):
     '''
     To check and install dependencies for the test
     '''
     detected_distro = distro.detect()
     smm = SoftwareManager()
     depends = []
     # FIXME: "redhat" as the distro name for RHEL is deprecated
     # on Avocado versions >= 50.0.  This is a temporary compatibility
     # enabler for older runners, but should be removed soon
     if detected_distro.name == "Ubuntu":
         depends.extend(["openssh-client", "iputils-ping"])
     elif detected_distro.name in ["rhel", "fedora", "centos", "redhat"]:
         depends.extend(["openssh-clients", "iputils"])
     else:
         depends.extend(["openssh", "iputils"])
     for pkg in depends:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel("%s package is need to test" % pkg)
     self.mode = self.params.get("bonding_mode", default="")
     if 'setup' in str(self.name) or 'run' in str(self.name):
         if not self.mode:
             self.cancel("test skipped because mode not specified")
     interfaces = netifaces.interfaces()
     self.user = self.params.get("user_name", default="root")
     self.password = self.params.get("peer_password", '*', default="None")
     self.host_interfaces = self.params.get("bond_interfaces",
                                            default="").split(",")
     if not self.host_interfaces:
         self.cancel("user should specify host interfaces")
     self.peer_interfaces = self.params.get("peer_interfaces",
                                            default="").split(",")
     for self.host_interface in self.host_interfaces:
         if self.host_interface not in interfaces:
             self.cancel("interface is not available")
     self.peer_first_ipinterface = self.params.get("peer_ip", default="")
     if not self.peer_interfaces or self.peer_first_ipinterface == "":
         self.cancel("peer machine should available")
     self.bond_name = self.params.get("bond_name", default="tempbond")
     self.net_path = "/sys/class/net/"
     self.bond_status = "/proc/net/bonding/%s" % self.bond_name
     self.bond_dir = os.path.join(self.net_path, self.bond_name)
     self.bonding_slave_file = "%s/bonding/slaves" % self.bond_dir
     self.bonding_masters_file = "%s/bonding_masters" % self.net_path
     self.peer_bond_needed = self.params.get("peer_bond_needed",
                                             default=False)
     self.peer_wait_time = self.params.get("peer_wait_time", default=5)
     self.sleep_time = int(self.params.get("sleep_time", default=5))
     self.ib = False
     if self.host_interface[0:2] == 'ib':
         self.ib = True
     self.log.info("Bond Test on IB Interface? = %s", self.ib)
     self.session = Session(self.peer_first_ipinterface,
                            user=self.user,
                            password=self.password)
     self.setup_ip()
     self.err = []
    def setUp(self):
        '''
        set up required packages and gather necessary test inputs
        '''
        self.install_packages()
        self.rsct_service_start()
        self.hmc_ip = self.get_mcp_component("HMCIPAddr")
        if not self.hmc_ip:
            self.cancel("HMC IP not got")
        self.vioses = self.params.get("vioses", default=None)
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
        self.hmc_username = self.params.get("hmc_username", '*', default=None)
        self.count = self.params.get("count", default=1)
        # TO_DO: self.skip_host parameter can be remove
        # if script is self reliable to find bootable disk
        self.skip_host = self.params.get("skip_host", default=None)
        self.vfc_id = self.params.get("vfchost_id", default=None)
        self.vfchost_count = int(self.params.get("vfc_count", default=1))
        # Since the command in each layer doesn't take same time to complete
        # there is delay observed in status reflect (like host and multipath).
        # even though we have used the wait.wait_for funtion, this is not
        # enough to handle the case. since the operation flow reflect in 3
        # stages (lpar, HMC, vios), giving a short sleep time helps the flow
        # to happen smoother. Hence adding the sleep time after each major
        # operation like unamp, map, define, undefine, create, delete.
        # we can remove this sleep time in future if the flow happens smoother
        self.opp_sleep_time = 20
        self.lpar = self.get_partition_name("Partition Name")
        if not self.lpar:
            self.cancel("LPAR Name not got from lparstat command")
        self.session = Session(self.hmc_ip,
                               user=self.hmc_username,
                               password=self.hmc_pwd)
        if not self.session.connect():
            self.cancel("failed connecting to HMC")
        cmd = 'lssyscfg -r sys  -F name'
        output = self.session.cmd(cmd).stdout_text
        self.server = ''
        for line in output.splitlines():
            if line in self.lpar:
                self.server = line
        if not self.server:
            self.cancel("Managed System not got")
        self.dic_list = []
        self.err_mesg = []
        for vios in self.vioses.split(" "):
            for vfchost in self.get_vfchost(vios):
                vfc_dic = {}
                vfc_dic["vios"] = vios
                vfc_dic["vfchost"] = vfchost
                vfc_dic["fcs"] = self.get_fcs_name(vfchost, vios)
                vfc_dic["vfc_client"] = self.get_vfc_client(vfchost, vios)
                vfc_dic["paths"] = self.get_paths(vfc_dic["vfc_client"])
                if vfc_dic["vfc_client"] != self.skip_host:
                    self.dic_list.append(vfc_dic)

        self.log.info("complete list : %s" % self.dic_list)
Esempio n. 5
0
 def _connect(self):
     session = Session(host=self.host,
                       port=self.port,
                       user=self.username,
                       key=self.key,
                       password=self.password)
     if session.connect():
         return session
     msg = f"Failed connecting {self.host}:{self.port}"
     raise NWException(msg)
Esempio n. 6
0
 def setUp(self):
     """
     test parameters
     """
     self.parameters()
     self.switch_login(self.switch_name, self.userid, self.password)
     self.session = Session(self.peer_ip,
                            user=self.peer_user,
                            password=self.peer_password)
     if not self.session.connect():
         self.cancel("failed connecting to peer")
     self.get_ips()
Esempio n. 7
0
    def test_rmdev_viosfailover(self):
        '''
        using mrdev and mkdev command to check vios failover works
        '''

        self.session = Session(self.vios_ip,
                               user=self.vios_user,
                               password=self.vios_pwd)
        if not wait.wait_for(self.session.connect, timeout=30):
            self.fail("Failed connecting to VIOS")

        cmd = "ioscli lsmap -all -vnic -cpid %s" % self.lpar_id
        vnic_servers = self.session.cmd(cmd).stdout_text.splitlines()
        device = self.find_device(self.mac_id[0])
        temp_idx = vnic_servers.index("Client device name:" + device)
        vnic_server = vnic_servers[temp_idx - 5].split()[0]

        cmd = "ioscli lsmap -vnic -vadapter %s" % vnic_server
        output = self.session.cmd(cmd)

        vnic_backing_device = None
        for line in output.stdout_text.splitlines():
            if 'Backing device' in line:
                vnic_backing_device = line.split(':')[-1]

        before = self.get_active_device_logport(self.slot_num[0])
        self.log.debug("Active backing device before : %s", before)

        self.validate_vios_command('rmdev -l %s' % vnic_server, 'Defined')
        if vnic_backing_device:
            self.validate_vios_command('rmdev -l %s' % vnic_backing_device,
                                       'Defined')

        time.sleep(10)

        for backing_dev in self.backing_dev_list().splitlines():
            if backing_dev.startswith('%s,' % self.slot_num[0]):
                backing_dev = backing_dev.strip('%s,"' % self.slot_num[0])
                if 'Powered Off' not in backing_dev:
                    self.fail("Failover did not occur")

        time.sleep(60)

        if vnic_backing_device:
            self.validate_vios_command('mkdev -l %s' % vnic_backing_device,
                                       'Available')
        self.validate_vios_command('mkdev -l %s' % vnic_server, 'Available')

        networkinterface = NetworkInterface(device, self.local)
        if networkinterface.ping_check(self.peer_ip[0], count=5) is not None:
            self.fail("Ping test failed. Network virtualized \
                      vios failover has affected Network connectivity")
        self.check_dmesg_error()
    def test_rmdev_viosfailover(self):
        '''
        using mrdev and mkdev command to check vios failover works
        '''

        self.session = Session(self.vios_ip,
                               user=self.vios_user,
                               password=self.vios_pwd)
        if not self.session.connect():
            self.fail("Failed connecting to VIOS")

        cmd = "ioscli lsmap -all -vnic -cpid %s" % self.lpar_id
        vnic_server = self.session.cmd(
            cmd).stdout_text.splitlines()[2].split()[0]

        cmd = "ioscli lsmap -vnic -vadapter %s" % vnic_server
        output = self.session.cmd(cmd)

        vnic_backing_device = None
        for line in output.stdout_text.splitlines():
            if 'Backing device' in line:
                vnic_backing_device = line.split(':')[-1]

        before = self.get_active_device_logport(self.slot_num[0])
        self.log.debug("Active backing device before : %s", before)

        self.validate_vios_command('rmdev -l %s' % vnic_server, 'Defined')
        if vnic_backing_device:
            self.validate_vios_command('rmdev -l %s' % vnic_backing_device,
                                       'Defined')

        after = self.get_active_device_logport(self.slot_num[0])
        self.log.debug("Active backing device after: %s", after)

        if before == after:
            self.fail("failover not occour")
        time.sleep(20)

        if vnic_backing_device:
            self.validate_vios_command('mkdev -l %s' % vnic_backing_device,
                                       'Available')
        self.validate_vios_command('mkdev -l %s' % vnic_server, 'Available')

        device = self.find_device(self.mac_id[0])
        networkinterface = NetworkInterface(device, self.local)
        if networkinterface.ping_check(self.peer_ip[0], count=5) is not None:
            self.fail("Ping test failed. Network virtualized \
                      vios failover has affected Network connectivity")
        self.check_dmesg_error()
Esempio n. 9
0
 def setUp(self):
     '''
     set up required packages and gather necessary test inputs
     '''
     self.install_packages()
     self.rsct_service_start()
     self.hmc_ip = self.get_mcp_component("HMCIPAddr")
     if not self.hmc_ip:
         self.cancel("HMC IP not got")
     self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
     self.hmc_username = self.params.get("hmc_username", '*', default=None)
     self.count = self.params.get("count", default=1)
     self.skip_drc = self.params.get("skip_drc_name", default=None)
     self.opp_sleep_time = 150
     self.lpar = self.get_partition_name("Partition Name")
     if not self.lpar:
         self.cancel("LPAR Name not got from lparstat command")
     self.session = Session(self.hmc_ip,
                            user=self.hmc_username,
                            password=self.hmc_pwd)
     if not self.session.connect():
         self.cancel("failed connecting to HMC")
     cmd = 'lssyscfg -r sys  -F name'
     output = self.session.cmd(cmd)
     self.server = ''
     for line in output.stdout_text.splitlines():
         if line in self.lpar:
             self.server = line
     if not self.server:
         self.cancel("Managed System not got")
     self.dic_list = []
     cmd = 'lshwres -r virtualio --rsubtype fc --level lpar -m %s \
            --filter "lpar_names=%s"' % (self.server, self.lpar)
     for line in self.session.cmd(cmd).stdout_text.splitlines():
         self.vfc_dic = {}
         for i in line.split(","):
             if i.split("=")[0] == "slot_num":
                 self.vfc_dic["c_slot"] = i.split("=")[-1]
             elif i.split("=")[0] == "remote_slot_num":
                 self.vfc_dic["r_slot"] = i.split("=")[-1]
             elif i.split("=")[0] == "remote_lpar_name":
                 self.vfc_dic["r_lpar"] = i.split("=")[-1]
         self.vfc_dic["wwpn"] = self.get_wwpn(self.vfc_dic["c_slot"])
         self.vfc_dic["drc"] = self.get_drc_name(self.vfc_dic["c_slot"])
         self.vfc_dic["paths"] = self.get_paths(self.vfc_dic["drc"])
         if self.vfc_dic["drc"] != self.skip_drc:
             self.dic_list.append(self.vfc_dic)
     self.log.info("complete list : %s" % self.dic_list)
Esempio n. 10
0
 def setUp(self):
     '''
     Gather necessary test inputs.
     '''
     self.disk = self.params.get('disk', default=None)
     self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
     self.vios_ip = self.params.get('vios_ip', '*', default=None)
     self.vios_user = self.params.get('vios_username', '*', default=None)
     self.vios_pwd = self.params.get('vios_pwd', '*', default=None)
     self.session = Session(self.vios_ip,
                            user=self.vios_user,
                            password=self.vios_pwd)
     self.session.connect()
     cmd = "lscfg -l %s" % self.disk
     for line in process.system_output(cmd, shell=True).decode("utf-8") \
                                                       .splitlines():
         if self.disk in line:
             self.slot = line.split()[-1].split('-')[-2]
     cmd = "ioscli lsdev -slots"
     output = self.session.cmd(cmd)
     for line in output.stdout_text.splitlines():
         if self.slot in line:
             self.host = line.split()[-1]
     self.log.info(self.host)
     cmd = "lsscsi -vl"
     output = process.system_output(cmd, shell=True)
     for line in output.decode("utf-8").splitlines():
         if self.disk in line:
             value = line.split()[0].replace('[', '').replace(']', '')
     for line in output.decode("utf-8").splitlines():
         if value in line:
             if "dir" in line:
                 self.disk_dir = line.split()[-1].replace('[', '') \
                                                 .replace(']', '')
     cmd = r"cat %s/inquiry" % self.disk_dir
     output = process.system_output(cmd, shell=True)
     self.hdisk_name = output.split()[2].strip(b'0001').decode("utf-8")
     self.log.info(self.hdisk_name)
     cmd = "ioscli lsmap -all|grep -p %s" % self.hdisk_name
     output = self.session.cmd(cmd)
     for line in output.stdout_text.splitlines():
         if "VTD" in line:
             self.vscsi = line.split()[-1]
     if not self.vscsi:
         self.cancel("failed to get vscsi")
     self.log.info(self.vscsi)
 def setUp(self):
     '''
     set up required packages and gather necessary test inputs
     '''
     smm = SoftwareManager()
     packages = [
         'src', 'rsct.basic', 'rsct.core.utils', 'rsct.core', 'DynamicRM',
         'powerpc-utils'
     ]
     for pkg in packages:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel('%s is needed for the test to be run' % pkg)
     self.hmc_ip = self.get_mcp_component("HMCIPAddr")
     if not self.hmc_ip:
         self.cancel("HMC IP not got")
     self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
     self.hmc_username = self.params.get("hmc_username", '*', default=None)
     self.lpar = self.get_partition_name("Partition Name")
     if not self.lpar:
         self.cancel("LPAR Name not got from lparstat command")
     self.session = Session(self.hmc_ip,
                            user=self.hmc_username,
                            password=self.hmc_pwd)
     if not self.session.connect():
         self.cancel("failed connetion to HMC")
     cmd = 'lssyscfg -r sys  -F name'
     output = self.session.cmd(cmd)
     self.server = ''
     for line in output.stdout_text.splitlines():
         if line in self.lpar:
             self.server = line
             break
     if not self.server:
         self.cancel("Managed System not got")
     self.sriov_adapter = self.params.get('sriov_adapter',
                                          '*',
                                          default=None).split(' ')
     self.sriov_port = self.params.get('sriov_port', '*',
                                       default=None).split(' ')
     self.ipaddr = self.params.get('ipaddr', '*', default="").split(' ')
     self.netmask = self.params.get('netmasks', '*', default="").split(' ')
     self.peer_ip = self.params.get('peer_ip', '*', default="").split(' ')
     self.mac_id = self.params.get('mac_id',
                                   default="02:03:03:03:03:01").split(' ')
     self.mac_id = [mac.replace(':', '') for mac in self.mac_id]
     self.local = LocalHost()
Esempio n. 12
0
 def test_cleartargetconfig(self):
     """
     Clears the peer NVMf
     """
     self.session = Session(self.peer_ips[0],
                            user=self.peer_user,
                            password=self.peer_password)
     if not self.session.connect():
         self.fail("failed connecting to peer")
     msg = "nvmetcli clear"
     output = self.session.cmd(msg)
     if output.exit_status:
         self.fail("nvmetcli clear config remove on peer")
     msg = "rm -rf /tmp/nvmf.cfg"
     output = self.session.cmd(msg)
     if output.exit_status:
         self.log.warn("removing config file on peer failed")
Esempio n. 13
0
 def setUp(self):
     '''
     Gather necessary test inputs.
     '''
     self.interface = self.params.get('interface', default=None)
     self.ipaddr = self.params.get("host_ip", default="")
     self.netmask = self.params.get("netmask", default="")
     self.peer_ip = self.params.get('peer_ip', default=None)
     self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
     self.vios_ip = self.params.get('vios_ip', '*', default=None)
     self.vios_user = self.params.get('vios_username', '*', default=None)
     self.vios_pwd = self.params.get('vios_pwd', '*', default=None)
     self.session = Session(self.vios_ip,
                            user=self.vios_user,
                            password=self.vios_pwd)
     self.session.connect()
     local = LocalHost()
     self.networkinterface = NetworkInterface(self.interface, local)
     try:
         self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
         self.networkinterface.save(self.ipaddr, self.netmask)
     except Exception:
         self.networkinterface.save(self.ipaddr, self.netmask)
     self.networkinterface.bring_up()
     cmd = "lscfg -l %s" % self.interface
     for line in process.system_output(cmd, shell=True).decode("utf-8") \
                                                       .splitlines():
         if self.interface in line:
             self.slot = line.split()[-1].split('-')[-2]
     cmd = "ioscli lsmap -all -net"
     output = self.session.cmd(cmd)
     for line in output.stdout_text.splitlines():
         if self.slot in line:
             self.iface = line.split()[0]
     cmd = "ioscli lsmap -vadapter %s -net" % self.iface
     output = self.session.cmd(cmd)
     for line in output.stdout_text.splitlines():
         if "SEA" in line:
             self.sea = line.split()[-1]
     if not self.sea:
         self.cancel("failed to get SEA")
     self.log.info(self.sea)
     if self.networkinterface.ping_check(self.peer_ip, count=5) is not None:
         self.cancel("peer connection is failed")
Esempio n. 14
0
 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="")
     localhost = LocalHost()
     self.networkinterface = NetworkInterface(self.iface, localhost)
     try:
         self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
         self.networkinterface.save(self.ipaddr, self.netmask)
     except Exception:
         self.networkinterface.save(self.ipaddr, self.netmask)
     self.networkinterface.bring_up()
     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)
     remotehost = RemoteHost(self.peer_ip,
                             self.peer_user,
                             password=self.peer_password)
     self.peer_interface = remotehost.get_interface_by_ipaddr(
         self.peer_ip).name
     self.peer_networkinterface = NetworkInterface(self.peer_interface,
                                                   remotehost)
     if self.peer_networkinterface.set_mtu(self.mtu) is not None:
         self.cancel("Failed to set mtu in peer")
     if self.networkinterface.set_mtu(self.mtu) is not None:
         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")
Esempio n. 15
0
 def setUp(self):
     """
     To check and install dependencies for the test
     """
     self.peer_ip = self.params.get("peer_ip", default="")
     self.peer_public_ip = self.params.get("peer_public_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="")
     local = LocalHost()
     self.networkinterface = NetworkInterface(self.iface, local)
     try:
         self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
         self.networkinterface.save(self.ipaddr, self.netmask)
     except Exception:
         self.networkinterface.save(self.ipaddr, self.netmask)
     self.networkinterface.bring_up()
     self.session = Session(self.peer_ip, user=self.peer_user,
                            password=self.peer_password)
     if not self.session.connect():
         self.cancel("failed connecting to peer")
     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.remotehost = RemoteHost(self.peer_ip, self.peer_user,
                                  password=self.peer_password)
     self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name
     self.peer_networkinterface = NetworkInterface(self.peer_interface,
                                                   self.remotehost)
     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) is not None:
         self.cancel("Failed to set mtu in peer")
     if self.networkinterface.set_mtu(self.mtu) is not None:
         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")
     destination = "%s:/tmp" % self.peer_ip
     output = self.session.copy_files(self.uperf_dir, destination,
                                      recursive=True)
     if not output:
         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 &"
         cmd = self.session.get_raw_ssh_command(cmd)
         self.obj = SubProcess(cmd)
         self.obj.start()
     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")
Esempio n. 16
0
    def setUp(self):
        '''
        check the availability of perftest package installed
        perftest package should be installed
        '''
        smm = SoftwareManager()
        detected_distro = distro.detect()
        pkgs = ["perftest"]
        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)
        interfaces = netifaces.interfaces()
        self.iface = self.params.get("interface", default="")
        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")
        self.ipaddr = self.params.get("host_ip", default="")
        self.netmask = self.params.get("netmask", default="")
        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')
        self.session = Session(self.peer_ip,
                               user=self.peer_user,
                               password=self.peer_password)
        if self.iface not in interfaces:
            self.cancel("%s interface is not available" % self.iface)
        if self.peer_ip == "":
            self.cancel("%s peer machine is not available" % self.peer_ip)
        self.ca_name = self.params.get("CA_NAME", default="mlx4_0")
        self.port = self.params.get("PORT_NUM", default="1")
        self.peer_ca = self.params.get("PEERCA", default="mlx4_0")
        self.peer_port = self.params.get("PEERPORT", default="1")
        self.tmo = self.params.get("TIMEOUT", default="600")
        self.tool_name = self.params.get("tool")
        if self.tool_name == "":
            self.cancel("should specify tool name")
        self.log.info("test with %s", self.tool_name)
        self.test_op = self.params.get("test_opt", default="")
        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 detected_distro.name == "Ubuntu":
            cmd = "service ufw stop"
        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        elif detected_distro.name in ['rhel', 'fedora', 'redhat']:
            cmd = "systemctl stop firewalld"
        elif detected_distro.name == "SuSE":
            if detected_distro.version == 15:
                cmd = "systemctl stop firewalld"
            else:
                cmd = "rcSuSEfirewall2 stop"
        elif detected_distro.name == "centos":
            cmd = "service iptables stop"
        else:
            self.cancel("Distro not supported")
        if process.system(cmd, ignore_status=True, shell=True) != 0:
            self.cancel("Unable to disable firewall")
        output = self.session.cmd(cmd)
        if not output.exit_status == 0:
            self.cancel("Unable to disable firewall on peer")
Esempio n. 17
0
    def setUp(self):
        '''
        To check and install dependencies for the test
        '''
        detected_distro = distro.detect()
        smm = SoftwareManager()
        depends = []
        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        if detected_distro.name == "Ubuntu":
            depends.extend(["openssh-client", "iputils-ping"])
        elif detected_distro.name in ["rhel", "fedora", "centos", "redhat"]:
            depends.extend(["openssh-clients", "iputils"])
        else:
            depends.extend(["openssh", "iputils"])
        for pkg in depends:
            if not smm.check_installed(pkg) and not smm.install(pkg):
                self.cancel("%s package is need to test" % pkg)
        self.mode = self.params.get("bonding_mode", default="")
        if 'setup' in str(self.name) or 'run' in str(self.name):
            if not self.mode:
                self.cancel("test skipped because mode not specified")
        interfaces = netifaces.interfaces()
        self.peer_public_ip = self.params.get("peer_public_ip", default="")
        self.user = self.params.get("user_name", default="root")
        self.password = self.params.get("peer_password", '*', default="None")
        self.host_interfaces = self.params.get("bond_interfaces",
                                               default="").split(" ")
        if not self.host_interfaces:
            self.cancel("user should specify host interfaces")
        self.peer_interfaces = self.params.get("peer_interfaces",
                                               default="").split(" ")
        for self.host_interface in self.host_interfaces:
            if self.host_interface not in interfaces:
                self.cancel("interface is not available")
        self.peer_first_ipinterface = self.params.get("peer_ips",
                                                      default="").split(" ")
        if not self.peer_interfaces or self.peer_first_ipinterface == "":
            self.cancel("peer machine should available")
        self.ipaddr = self.params.get("host_ips", default="").split(" ")
        self.netmask = self.params.get("netmask", default="")
        self.peer_bond_needed = self.params.get("peer_bond_needed",
                                                default=False)
        self.localhost = LocalHost()
        if 'setup' in str(self.name.name):
            for ipaddr, interface in zip(self.ipaddr, self.host_interfaces):
                networkinterface = NetworkInterface(interface, self.localhost)
                try:
                    networkinterface.flush_ipaddr()
                    networkinterface.add_ipaddr(ipaddr, self.netmask)
                    networkinterface.save(ipaddr, self.netmask)
                except Exception:
                    networkinterface.save(ipaddr, self.netmask)
                networkinterface.bring_up()
            for ipaddr, interface in zip(self.peer_first_ipinterface,
                                         self.peer_interfaces):
                if self.peer_bond_needed:
                    self.remotehost = RemoteHost(self.peer_public_ip,
                                                 self.user,
                                                 password=self.password)
                    peer_networkinterface = NetworkInterface(
                        interface, self.remotehost)
                    try:
                        peer_networkinterface.flush_ipaddr()
                        peer_networkinterface.add_ipaddr(ipaddr, self.netmask)
                        peer_networkinterface.save(ipaddr, self.netmask)
                    except Exception:
                        peer_networkinterface.save(ipaddr, self.netmask)
                    networkinterface.bring_up()
        self.miimon = self.params.get("miimon", default="100")
        self.fail_over_mac = self.params.get("fail_over_mac", default="2")
        self.downdelay = self.params.get("downdelay", default="0")
        self.bond_name = self.params.get("bond_name", default="tempbond")
        self.net_path = "/sys/class/net/"
        self.bond_status = "/proc/net/bonding/%s" % self.bond_name
        self.bond_dir = os.path.join(self.net_path, self.bond_name)
        self.bonding_slave_file = "%s/bonding/slaves" % self.bond_dir
        self.bonding_masters_file = "%s/bonding_masters" % self.net_path
        self.peer_bond_needed = self.params.get("peer_bond_needed",
                                                default=False)
        self.peer_wait_time = self.params.get("peer_wait_time", default=20)
        self.sleep_time = int(self.params.get("sleep_time", default=10))
        self.peer_wait_time = self.params.get("peer_wait_time", default=5)
        self.sleep_time = int(self.params.get("sleep_time", default=5))
        self.mtu = self.params.get("mtu", default=1500)
        for root, dirct, files in os.walk("/root/.ssh"):
            for file in files:
                if file.startswith("avocado-master-"):
                    path = os.path.join(root, file)
                    os.remove(path)
        self.ib = False
        if self.host_interface[0:2] == 'ib':
            self.ib = True
        self.log.info("Bond Test on IB Interface? = %s", self.ib)
        '''
        An individual interface, that has a LACP PF, cannot communicate without
        being bonded. So the test uses the public ip address to create an SSH
        session instead of the private one when setting up a bonding interface.
        '''
        if self.mode == "4" and "setup" in str(self.name.name):
            self.session = Session(self.peer_public_ip,
                                   user=self.user,
                                   password=self.password)
        else:
            self.session = Session(self.peer_first_ipinterface[0],
                                   user=self.user,
                                   password=self.password)

        if not self.session.connect():
            '''
            LACP bond interface takes some time to get it to ping peer after it
            is setup. This code block tries at most 5 times to get it to connect
            to the peer.
            '''
            if self.mode == "4":
                connect = False
                for _ in range(5):
                    if self.session.connect():
                        connect = True
                        self.log.info("Was able to connect to peer.")
                        break
                    time.sleep(5)
                if not connect:
                    self.cancel("failed connecting to peer")
            else:
                self.cancel("failed connecting to peer")
        self.setup_ip()
        self.err = []
        if self.mode == "4" and "setup" in str(self.name.name):
            self.remotehost = RemoteHost(self.peer_public_ip,
                                         self.user,
                                         password=self.password)
        else:
            self.remotehost = RemoteHost(self.peer_first_ipinterface[0],
                                         self.user,
                                         password=self.password)

        if 'setup' in str(self.name.name):
            for interface in self.peer_interfaces:
                peer_networkinterface = NetworkInterface(
                    interface, self.remotehost)
                if peer_networkinterface.set_mtu(self.mtu) is not None:
                    self.cancel("Failed to set mtu in peer")
            for host_interface in self.host_interfaces:
                self.networkinterface = NetworkInterface(
                    host_interface, self.localhost)
                if self.networkinterface.set_mtu(self.mtu) is not None:
                    self.cancel("Failed to set mtu in host")
 def setUp(self):
     '''
     set up required packages and gather necessary test inputs
     '''
     self.install_packages()
     self.hmc_ip = self.get_mcp_component("HMCIPAddr")
     if not self.hmc_ip:
         self.cancel("HMC IP not got")
     self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
     self.hmc_username = self.params.get("hmc_username", '*', default=None)
     self.lpar = self.get_partition_name("Partition Name")
     if not self.lpar:
         self.cancel("LPAR Name not got from lparstat command")
     for root, dirct, files in os.walk("/root/.ssh"):
         for file in files:
             if file.startswith("avocado-master-root"):
                 path = os.path.join(root, file)
                 os.remove(path)
     self.session_hmc = Session(self.hmc_ip,
                                user=self.hmc_username,
                                password=self.hmc_pwd)
     if not self.session_hmc.connect():
         self.cancel("failed connecting to HMC")
     cmd = 'lssyscfg -r sys  -F name'
     output = self.session_hmc.cmd(cmd)
     self.server = ''
     for line in output.stdout_text.splitlines():
         if line in self.lpar:
             self.server = line
             break
     if not self.server:
         self.cancel("Managed System not got")
     self.slot_num = self.params.get("slot_num", '*', default=None)
     self.slot_num = self.slot_num.split(' ')
     for slot in self.slot_num:
         if int(slot) < 3 or int(slot) > 2999:
             self.cancel("Slot invalid. Valid range: 3 - 2999")
     self.vios_name = self.params.get("vios_names", '*',
                                      default=None).split(' ')
     self.sriov_port = self.params.get("sriov_ports", '*',
                                       default=None).split(' ')
     self.backing_adapter = self.params.get("sriov_adapters",
                                            '*',
                                            default=None).split(' ')
     if len(self.sriov_port) != len(self.backing_adapter):
         self.cancel('Backing Device counts and port counts differ')
     if len(self.vios_name) != len(self.backing_adapter):
         self.cancel('Backing Device counts and vios name counts differ')
     self.backingdev_count = len(self.backing_adapter)
     self.bandwidth = self.params.get("bandwidth", '*', default=None)
     self.vnic_priority = self.params.get("priority", '*', default=None)
     if not self.vnic_priority:
         self.vnic_priority = [50] * len(self.backing_adapter)
     else:
         self.vnic_priority = self.vnic_priority.split(' ')
     if len(self.vnic_priority) != len(self.backing_adapter):
         self.cancel('Backing Device counts and priority counts differ')
     self.auto_failover = self.params.get("auto_failover",
                                          '*',
                                          default=None)
     if self.auto_failover not in ['0', '1']:
         self.auto_failover = '1'
     self.vios_ip = self.params.get('vios_ip', '*', default=None)
     self.vios_user = self.params.get('vios_username', '*', default=None)
     self.vios_pwd = self.params.get('vios_pwd', '*', default=None)
     self.count = int(self.params.get('vnic_test_count', default="1"))
     self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
     self.device_ip = self.params.get('device_ip', '*',
                                      default=None).split(' ')
     self.mac_id = self.params.get('mac_id',
                                   default="02:03:03:03:03:01").split(' ')
     self.mac_id = [mac.replace(':', '') for mac in self.mac_id]
     self.netmask = self.params.get('netmasks', '*',
                                    default=None).split(' ')
     self.peer_ip = self.params.get('peer_ip', default=None).split(' ')
     dmesg.clear_dmesg()
     self.session_hmc.cmd("uname -a")
     cmd = 'lssyscfg -m ' + self.server + \
           ' -r lpar --filter lpar_names=' + self.lpar + \
           ' -F lpar_id'
     self.lpar_id = self.session_hmc.cmd(cmd).stdout_text.split()[0]
     self.vios_id = []
     for vios_name in self.vios_name:
         cmd = 'lssyscfg -m ' + self.server + \
               ' -r lpar --filter lpar_names=' + vios_name + \
               ' -F lpar_id'
         self.vios_id.append(
             self.session_hmc.cmd(cmd).stdout_text.split()[0])
     cmd = 'lshwres -m %s -r sriov --rsubtype adapter -F \
           phys_loc:adapter_id' % self.server
     adapter_id_output = self.session_hmc.cmd(cmd).stdout_text
     self.backing_adapter_id = []
     for backing_adapter in self.backing_adapter:
         for line in adapter_id_output.splitlines():
             if str(backing_adapter) in line:
                 self.backing_adapter_id.append(line.split(':')[1])
     if not self.backing_adapter_id:
         self.cancel("SRIOV adapter provided was not found.")
     self.rsct_service_start()
     if len(self.slot_num) > 1:
         if 'backing' in str(self.name.name) or \
            'failover' in str(self.name.name):
             self.cancel("this test is not needed")
     self.local = LocalHost()
     cmd = "echo 'module ibmvnic +p; func send_subcrq -p' > /sys/kernel/debug/dynamic_debug/control"
     result = process.run(cmd, shell=True, ignore_status=True)
     if result.exit_status:
         self.fail("failed to enable debug mode")
Esempio n. 19
0
import time

from avocado.utils.process import SubProcess
from avocado.utils.ssh import Session

with Session("host", user="******", key="/path/to/key") as s:
    print("connected")
    procs = []
    cmd = s.get_raw_ssh_command("sleep 5")
    for i in range(10):
        p = SubProcess(cmd)
        print(p.start())
        procs.append(p)

    while True:
        for proc in procs:
            proc.poll()

        if all([p.result.exit_status is not None for p in procs]):
            print("all finished")
            break

        time.sleep(1)
        print("working...")

print("session closed")
Esempio n. 20
0
    def setUp(self):
        '''
        set up required packages and gather necessary test inputs
        '''
        self.install_packages()
        self.rsct_service_start()

        self.hmc_ip = self.get_mcp_component("HMCIPAddr")
        if not self.hmc_ip:
            self.cancel("HMC IP not got from lsrsrc command")
        self.hmc_user = self.params.get("hmc_username", default='hscroot')
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default='********')
        self.options = self.params.get("options", default='')
        self.net_device_type = self.params.get("net_device_type", default='')
        self.lpar = self.get_partition_name("Partition Name")
        if not self.lpar:
            self.cancel("LPAR Name not got from lparstat command")
        self.lpar_ip = self.get_mcp_component("MNName")
        if not self.lpar_ip:
            self.cancel("LPAR IP not got from lsrsrc command")
        self.session = Session(self.hmc_ip,
                               user=self.hmc_user,
                               password=self.hmc_pwd)
        if not self.session.connect():
            self.cancel("failed connecting to HMC")
        cmd = 'lssyscfg -r sys -F name'
        output = self.session.cmd(cmd)
        self.server = ''
        for line in output.stdout_text.splitlines():
            if line in self.lpar:
                self.server = line
                break
        if not self.server:
            self.cancel("Managed System not got")

        self.remote_server = self.params.get("remote_server", default=None)
        if not self.remote_server:
            self.cancel("No Remote Server specified for LPM")

        if 'back' in str(self.name.name):
            current_server = self.remote_server
        else:
            current_server = self.server

        if not self.is_lpar_in_server(current_server, self.lpar):
            self.cancel("%s not in %s" % (self.lpar, current_server))

        if 'vnic' in self.net_device_type:
            self.slot_num = str(self.params.get("slot_num", '*', default=3))
            if int(self.slot_num) < 3 or int(self.slot_num) > 2999:
                self.cancel("Slot invalid. Valid range: 3 - 2999")

            self.bandwidth = str(self.params.get("bandwidth", default=2))

            self.vios_name = self.params.get("vios_names", '*',
                                             default=None).split(' ')
            self.vios_id = []
            for vios_name in self.vios_name:
                self.vios_id.append(self.get_lpar_id(self.server, vios_name))
            self.remote_vios_name = self.params.get("remote_vios_names",
                                                    '*',
                                                    default=None).split(' ')
            self.remote_vios_id = []
            for vios_name in self.remote_vios_name:
                self.remote_vios_id.append(
                    self.get_lpar_id(self.remote_server, vios_name))

            for vios in self.vios_id:
                self.set_msp(self.server, vios)
            for vios in self.remote_vios_id:
                self.set_msp(self.remote_server, vios)

            self.adapters = self.params.get("sriov_adapters",
                                            default='').split(' ')
            self.remote_adapters = self.params.get("remote_sriov_adapters",
                                                   default='').split(' ')
            self.ports = self.params.get("sriov_ports", default='').split(' ')
            self.remote_ports = self.params.get("remote_sriov_ports",
                                                default='').split(' ')

            self.adapter_id = []
            for adapter in self.adapters:
                self.adapter_id.append(
                    self.get_adapter_id(self.server, adapter))
            self.remote_adapter_id = []
            for adapter in self.remote_adapters:
                self.remote_adapter_id.append(
                    self.get_adapter_id(self.remote_server, adapter))
        dmesg.clear_dmesg()
Esempio n. 21
0
 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="")
     local = LocalHost()
     self.networkinterface = NetworkInterface(self.iface, local)
     try:
         self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
         self.networkinterface.save(self.ipaddr, self.netmask)
     except Exception:
         self.networkinterface.save(self.ipaddr, self.netmask)
     self.networkinterface.bring_up()
     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)
     remotehost = RemoteHost(self.peer_ip,
                             username=self.peer_user,
                             password=self.peer_password)
     self.peer_interface = remotehost.get_interface_by_ipaddr(
         self.peer_ip).name
     self.peer_networkinterface = NetworkInterface(self.peer_interface,
                                                   remotehost)
     if self.peer_networkinterface.set_mtu(self.mtu) is not None:
         self.cancel("Failed to set mtu in peer")
     if self.networkinterface.set_mtu(self.mtu) is not None:
         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='')
Esempio n. 22
0
    def setUp(self):
        '''
        Gather necessary test inputs.
        Test all services.
        '''
        self.session = None
        self.install_packages()
        self.rsct_service_start()
        self.hmc_ip = self.get_mcp_component("HMCIPAddr")
        if not self.hmc_ip:
            self.cancel("HMC IP not got")
        self.hmc_user = self.params.get("hmc_username", default='hscroot')
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default='********')
        self.sriov = self.params.get("sriov", default="no")
        self.lpar_1 = self.get_partition_name("Partition Name")
        if not self.lpar_1:
            self.cancel("LPAR Name not got from lparstat command")
        self.session = Session(self.hmc_ip, user=self.hmc_user,
                               password=self.hmc_pwd)
        if not self.session.connect():
            self.cancel("failed connecting to HMC")
        cmd = 'lssyscfg -r sys  -F name'
        output = self.session.cmd(cmd)
        self.server = ''
        for line in output.stdout_text.splitlines():
            if line in self.lpar_1:
                self.server = line
                break
        if not self.server:
            self.cancel("Managed System not got")
        self.lpar_2 = self.params.get("lpar_2", '*', default=None)
        if self.lpar_2 is not None:
            cmd = 'lshwres -r io -m %s --rsubtype slot --filter \
                   lpar_names=%s -F lpar_id' % (self.server, self.lpar_2)
            output = self.session.cmd(cmd)
            self.lpar2_id = output.stdout_text[0]
        self.pci_device = self.params.get("pci_device", '*', default=None)
        self.loc_code = pci.get_slot_from_sysfs(self.pci_device)
        self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
        if self.loc_code is None:
            self.cancel("Failed to get the location code for the pci device")
        self.session.cmd("uname -a")
        if self.sriov == "yes":
            cmd = "lshwres -r sriov --rsubtype logport -m %s \
            --level eth --filter lpar_names=%s -F \
            'adapter_id,logical_port_id,phys_port_id,lpar_id,location_code,drc_name'" \
                   % (self.server, self.lpar_1)
            output = self.session.cmd(cmd)
            for line in output.stdout_text.splitlines():
                if self.loc_code in line:
                    self.adapter_id = line.split(',')[0]
                    self.logical_port_id = line.split(',')[1]
                    self.phys_port_id = line.split(',')[2]
                    self.lpar_id = line.split(',')[3]
                    self.location_code = line.split(',')[4]
                    self.phb = line.split(',')[5].split(' ')[1]
                    break
            self.log.info("lpar_id : %s, loc_code: %s",
                          self.lpar_id, self.loc_code)
        else:
            cmd = 'lshwres -r io -m %s --rsubtype slot \
                   --filter lpar_names=%s -F drc_index,lpar_id,drc_name,bus_id' \
                   % (self.server, self.lpar_1)
            output = self.session.cmd(cmd)
            for line in output.stdout_text.splitlines():
                if self.loc_code in line:
                    self.drc_index = line.split(',')[0]
                    self.lpar_id = line.split(',')[1]
                    self.phb = line.split(',')[3]
                    break

            self.log.info("lpar_id : %s, loc_code: %s, drc_index: %s, phb: %s",
                          self.lpar_id, self.loc_code, self.drc_index,
                          self.phb)
Esempio n. 23
0
 def setUp(self):
     '''
     set up required packages and gather necessary test inputs
     '''
     smm = SoftwareManager()
     packages = [
         'src', 'rsct.basic', 'rsct.core.utils', 'NetworkManager',
         'rsct.core', 'DynamicRM', 'powerpc-utils'
     ]
     for pkg in packages:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel('%s is needed for the test to be run' % pkg)
     self.hmc_ip = self.get_mcp_component("HMCIPAddr")
     if not self.hmc_ip:
         self.cancel("HMC IP not got")
     self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
     self.hmc_username = self.params.get("hmc_username", '*', default=None)
     self.lpar = self.get_partition_name("Partition Name")
     if not self.lpar:
         self.cancel("LPAR Name not got from lparstat command")
     self.session = Session(self.hmc_ip,
                            user=self.hmc_username,
                            password=self.hmc_pwd)
     if not self.session.connect():
         self.cancel("failed connetion to HMC")
     cmd = 'lssyscfg -r sys  -F name'
     output = self.session.cmd(cmd)
     self.server = ''
     for line in output.stdout_text.splitlines():
         if line in self.lpar:
             self.server = line
             break
     if not self.server:
         self.cancel("Managed System not got")
     self.sriov_adapter = self.params.get('sriov_adapter',
                                          '*',
                                          default=None).split(' ')
     self.sriov_port = self.params.get('sriov_port', '*',
                                       default=None).split(' ')
     self.ipaddr = self.params.get('ipaddr', '*', default="").split(' ')
     self.netmask = self.params.get('netmasks', '*', default="").split(' ')
     self.prefix = self.netmask_to_cidr(self.netmask[0])
     self.peer_ip = self.params.get('peer_ip', '*', default="").split(' ')
     self.mac_id = self.params.get('mac_id',
                                   default="02:03:03:03:03:01").split(' ')
     self.mac_id = [mac.replace(':', '') for mac in self.mac_id]
     self.migratable = self.params.get('migratable', '*', default=0)
     self.backup_device_type = self.params.get('backup_device_type',
                                               '*',
                                               default='')
     self.backup_device_slot_num = self.params.get('backup_device_slot_num',
                                                   '*',
                                                   default=None)
     self.backup_veth_vnetwork = self.params.get('backup_veth_vnetwork',
                                                 '*',
                                                 default=None)
     if 'vnic' in self.backup_device_type:
         self.vnic_sriov_adapter = self.params.get('vnic_sriov_adapter',
                                                   '*',
                                                   default=None)
         self.vnic_port_id = self.params.get('vnic_port_id',
                                             '*',
                                             default=None)
         self.vnic_adapter_id = self.get_adapter_id(self.vnic_sriov_adapter)
         self.priority = self.params.get('failover_priority',
                                         '*',
                                         default='50')
         self.max_capacity = self.params.get('max_capacity',
                                             '*',
                                             default='10')
         self.capacity = self.params.get('capacity', '*', default='2')
         self.vios_name = self.params.get('vios_name', '*', default=None)
         cmd = 'lssyscfg -m %s -r lpar --filter lpar_names=%s -F lpar_id' % (
             self.server, self.vios_name)
         self.vios_id = self.session.cmd(cmd).stdout_text.split()[0]
         self.backup_vnic_backing_device = 'sriov/%s/%s/%s/%s/%s/%s/%s' % \
             (self.vios_name, self.vios_id, self.vnic_adapter_id, self.vnic_port_id,
              self.capacity, self.priority, self.max_capacity)
     self.local = LocalHost()
Esempio n. 24
0
 def setUp(self):
     '''
     To check and install dependencies for the test
     '''
     detected_distro = distro.detect()
     smm = SoftwareManager()
     depends = []
     # FIXME: "redhat" as the distro name for RHEL is deprecated
     # on Avocado versions >= 50.0.  This is a temporary compatibility
     # enabler for older runners, but should be removed soon
     if detected_distro.name == "Ubuntu":
         depends.extend(["openssh-client", "iputils-ping"])
     elif detected_distro.name in ["rhel", "fedora", "centos", "redhat"]:
         depends.extend(["openssh-clients", "iputils"])
     else:
         depends.extend(["openssh", "iputils"])
     for pkg in depends:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel("%s package is need to test" % pkg)
     self.mode = self.params.get("bonding_mode", default="")
     if 'setup' in str(self.name) or 'run' in str(self.name):
         if not self.mode:
             self.cancel("test skipped because mode not specified")
     interfaces = netifaces.interfaces()
     self.peer_public_ip = self.params.get("peer_public_ip", default="")
     self.user = self.params.get("user_name", default="root")
     self.password = self.params.get("peer_password", '*', default="None")
     self.host_interfaces = self.params.get("bond_interfaces",
                                            default="").split(" ")
     if not self.host_interfaces:
         self.cancel("user should specify host interfaces")
     self.peer_interfaces = self.params.get("peer_interfaces",
                                            default="").split(" ")
     for self.host_interface in self.host_interfaces:
         if self.host_interface not in interfaces:
             self.cancel("interface is not available")
     self.peer_first_ipinterface = self.params.get("peer_ip", default="")
     if not self.peer_interfaces or self.peer_first_ipinterface == "":
         self.cancel("peer machine should available")
     self.ipaddr = self.params.get("host_ips", default="").split(" ")
     self.netmask = self.params.get("netmask", default="")
     self.localhost = LocalHost()
     if 'setup' in str(self.name.name):
         for ipaddr, interface in zip(self.ipaddr, self.host_interfaces):
             networkinterface = NetworkInterface(interface, self.localhost)
             try:
                 networkinterface.add_ipaddr(ipaddr, self.netmask)
                 networkinterface.save(ipaddr, self.netmask)
             except Exception:
                 networkinterface.save(ipaddr, self.netmask)
             networkinterface.bring_up()
     self.miimon = self.params.get("miimon", default="100")
     self.fail_over_mac = self.params.get("fail_over_mac", default="2")
     self.downdelay = self.params.get("downdelay", default="0")
     self.bond_name = self.params.get("bond_name", default="tempbond")
     self.net_path = "/sys/class/net/"
     self.bond_status = "/proc/net/bonding/%s" % self.bond_name
     self.bond_dir = os.path.join(self.net_path, self.bond_name)
     self.bonding_slave_file = "%s/bonding/slaves" % self.bond_dir
     self.bonding_masters_file = "%s/bonding_masters" % self.net_path
     self.peer_bond_needed = self.params.get("peer_bond_needed",
                                             default=False)
     self.peer_wait_time = self.params.get("peer_wait_time", default=5)
     self.sleep_time = int(self.params.get("sleep_time", default=5))
     self.mtu = self.params.get("mtu", default=1500)
     self.ib = False
     if self.host_interface[0:2] == 'ib':
         self.ib = True
     self.log.info("Bond Test on IB Interface? = %s", self.ib)
     self.session = Session(self.peer_first_ipinterface,
                            user=self.user,
                            password=self.password)
     if not self.session.connect():
         self.cancel("failed connecting to peer")
     self.setup_ip()
     self.err = []
     self.remotehost = RemoteHost(self.peer_first_ipinterface,
                                  self.user,
                                  password=self.password)
     self.remotehost_public = RemoteHost(self.peer_public_ip,
                                         self.user,
                                         password=self.password)
     if 'setup' in str(self.name.name):
         for interface in self.peer_interfaces:
             peer_networkinterface = NetworkInterface(
                 interface, self.remotehost)
             if peer_networkinterface.set_mtu(self.mtu) is not None:
                 self.cancel("Failed to set mtu in peer")
         for host_interface in self.host_interfaces:
             self.networkinterface = NetworkInterface(
                 host_interface, self.localhost)
             if self.networkinterface.set_mtu(self.mtu) is not None:
                 self.cancel("Failed to set mtu in host")
Esempio n. 25
0
 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")
Esempio n. 26
0
from avocado.utils.ssh import Session
from avocado.utils.process import SubProcess
import time

with Session('host', user='******', key='/path/to/key') as s:
    print('connected')
    procs = []
    cmd = s.get_raw_ssh_command('sleep 5')
    for i in range(10):
        p = SubProcess(cmd)
        print(p.start())
        procs.append(p)

    while True:
        for proc in procs:
            proc.poll()

        if all([p.result.exit_status is not None for p in procs]):
            print('all finished')
            break

        time.sleep(1)
        print('working...')

print('session closed')
Esempio n. 27
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(["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="")
     self.ip_config = self.params.get("ip_config", default=True)
     local = LocalHost()
     self.networkinterface = NetworkInterface(self.iface, local)
     if self.ip_config:
         try:
             self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
             self.networkinterface.save(self.ipaddr, self.netmask)
         except Exception:
             self.networkinterface.save(self.ipaddr, self.netmask)
         self.networkinterface.bring_up()
     if not wait.wait_for(self.networkinterface.is_link_up, timeout=120):
         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_public_ip = self.params.get("peer_public_ip", default="")
     self.peer_user = self.params.get("peer_user", default="root")
     self.peer_password = self.params.get("peer_password",
                                          '*',
                                          default=None)
     if 'scp' or 'ssh' in str(self.name.name):
         self.session = Session(self.peer,
                                user=self.peer_user,
                                password=self.peer_password)
         if not self.session.connect():
             self.cancel("failed connecting to peer")
     self.remotehost = RemoteHost(self.peer,
                                  self.peer_user,
                                  password=self.peer_password)
     self.peer_interface = self.remotehost.get_interface_by_ipaddr(
         self.peer).name
     self.peer_networkinterface = NetworkInterface(self.peer_interface,
                                                   self.remotehost)
     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.mtu = self.params.get("mtu", default=1500)
     self.mtu_set()
     if self.networkinterface.ping_check(self.peer, count=5) is not None:
         self.cancel("No connection to peer")
Esempio n. 28
0
    def setUp(self):
        """
        To check and install dependencies for the test
        """
        self.peer_user = self.params.get("peer_user", default="root")
        self.peer_ip = self.params.get("peer_ip", default="")
        self.peer_public_ip = self.params.get("peer_public_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="")
        self.hbond = self.params.get("hbond", default=False)
        localhost = LocalHost()
        if self.hbond:
            self.networkinterface = NetworkInterface(self.iface,
                                                     localhost,
                                                     if_type='Bond')
        else:
            self.networkinterface = NetworkInterface(self.iface, localhost)
        try:
            self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
            self.networkinterface.save(self.ipaddr, self.netmask)
        except Exception:
            self.networkinterface.save(self.ipaddr, self.netmask)
        self.networkinterface.bring_up()
        self.session = Session(self.peer_ip,
                               user=self.peer_user,
                               password=self.peer_password)
        if not self.session.connect():
            self.cancel("failed connecting to peer")
        smm = SoftwareManager()
        for pkg in ["gcc", "autoconf", "perl", "m4", "libtool", "gcc-c++"]:
            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)

        detected_distro = distro.detect()
        pkg = "nmap"
        if detected_distro.name == 'rhel':
            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)

        if self.peer_ip == "":
            self.cancel("%s peer machine is not available" % self.peer_ip)
        self.mtu = self.params.get("mtu", default=1500)
        self.remotehost = RemoteHost(self.peer_ip,
                                     self.peer_user,
                                     password=self.peer_password)
        self.peer_interface = self.remotehost.get_interface_by_ipaddr(
            self.peer_ip).name
        self.peer_networkinterface = NetworkInterface(self.peer_interface,
                                                      self.remotehost)
        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) is not None:
            self.cancel("Failed to set mtu in peer")
        if self.networkinterface.set_mtu(self.mtu) is not None:
            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:"
                                         "//sourceforge.net/projects/iperf2/"
                                         "files/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)
        destination = "%s:/tmp" % self.peer_ip
        output = self.session.copy_files(self.iperf_dir,
                                         destination,
                                         recursive=True)
        if not output:
            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")
Esempio n. 29
0
    def setUp(self):
        """
        Setup and install dependencies for the test.
        """
        self.test_name = "udaddy"
        self.basic = self.params.get("basic_option", default="None")
        self.ext = self.params.get("ext_option", default="None")
        self.flag = self.params.get("ext_flag", default="0")
        if self.basic == "None" and self.ext == "None":
            self.cancel("No option given")
        if self.flag == "1" and self.ext != "None":
            self.option = self.ext
        else:
            self.option = self.basic
        if process.system("ibstat", shell=True, ignore_status=True) != 0:
            self.cancel("MOFED is not installed. Skipping")
        detected_distro = distro.detect()
        pkgs = []
        smm = SoftwareManager()
        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("Not able to install %s" % pkg)
        interfaces = netifaces.interfaces()
        self.iface = self.params.get("interface", default="")
        self.peer_ip = self.params.get("peer_ip", default="")
        self.peer_user = self.params.get("peer_user", default="root")
        self.peer_password = self.params.get("peer_password", '*',
                                             default="None")
        self.ipaddr = self.params.get("host_ip", default="")
        self.netmask = self.params.get("netmask", default="")
        local = LocalHost()
        if self.iface[0:2] == 'ib':
            self.networkinterface = NetworkInterface(self.iface, local,
                                                     if_type='Infiniband')
            try:
                self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
                self.networkinterface.save(self.ipaddr, self.netmask)
            except Exception:
                self.networkinterface.save(self.ipaddr, self.netmask)
        else:
            self.networkinterface = NetworkInterface(self.iface, local)
            try:
                self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
                self.networkinterface.save(self.ipaddr, self.netmask)
            except Exception:
                self.networkinterface.save(self.ipaddr, self.netmask)
        self.networkinterface.bring_up()
        self.session = Session(self.peer_ip, user=self.peer_user,
                               password=self.peer_password)
        if self.iface not in interfaces:
            self.cancel("%s interface is not available" % self.iface)
        if self.peer_ip == "":
            self.cancel("%s peer machine is not available" % self.peer_ip)
        self.timeout = "2m"
        self.local_ip = netifaces.ifaddresses(self.iface)[AF_INET][0]['addr']
        self.mtu = self.params.get("mtu", default=1500)
        self.remotehost = RemoteHost(self.peer_ip, self.peer_user,
                                     password=self.peer_password)
        self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name
        self.peer_networkinterface = NetworkInterface(self.peer_interface,
                                                      self.remotehost)

        if detected_distro.name == "Ubuntu":
            cmd = "service ufw stop"
        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        elif detected_distro.name in ['rhel', 'fedora', 'redhat']:
            cmd = "systemctl stop firewalld"
        elif detected_distro.name == "SuSE":
            if detected_distro.version == 15:
                cmd = "systemctl stop firewalld"
            else:
                cmd = "rcSuSEfirewall2 stop"
        elif detected_distro.name == "centos":
            cmd = "service iptables stop"
        else:
            self.cancel("Distro not supported")
        if process.system(cmd, ignore_status=True, shell=True) != 0:
            self.cancel("Unable to disable firewall")
        output = self.session.cmd(cmd)
        if not output.exit_status == 0:
            self.cancel("Unable to disable firewall on peer")
Esempio n. 30
0
 def setUp(self):
     '''
     To check and install dependencies for the test
     '''
     interfaces = netifaces.interfaces()
     self.flag = self.params.get("ext_flag", default="0")
     self.iface = self.params.get("interface", default="")
     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")
     self.ipaddr = self.params.get("host_ip", default="")
     self.netmask = self.params.get("netmask", default="")
     local = LocalHost()
     if self.iface[0:2] == 'ib':
         self.networkinterface = NetworkInterface(self.iface, local,
                                                  if_type='Infiniband')
         try:
             self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
             self.networkinterface.save(self.ipaddr, self.netmask)
         except Exception:
             self.networkinterface.save(self.ipaddr, self.netmask)
     else:
         self.networkinterface = NetworkInterface(self.iface, local)
         try:
             self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)
             self.networkinterface.save(self.ipaddr, self.netmask)
         except Exception:
             self.networkinterface.save(self.ipaddr, self.netmask)
     self.networkinterface.bring_up()
     self.session = Session(self.peer_ip, user=self.peer_user,
                            password=self.peer_password)
     if self.iface not in interfaces:
         self.cancel("%s interface is not available" % self.iface)
     if self.peer_ip == "":
         self.cancel("%s peer machine is not available" % self.peer_ip)
     self.ca_name = self.params.get("CA_NAME", default="mlx4_0")
     self.gid = int(self.params.get("GID_NUM", default="0"))
     self.port = int(self.params.get("PORT_NUM", default="1"))
     self.peer_ca = self.params.get("PEERCA", default="mlx4_0")
     self.peer_gid = int(self.params.get("PEERGID", default="0"))
     self.peer_port = int(self.params.get("PEERPORT", default="1"))
     self.tmo = self.params.get("TIMEOUT", default="120")
     self.mtu = self.params.get("mtu", default=1500)
     self.remotehost = RemoteHost(self.peer_ip, self.peer_user,
                                  password=self.peer_password)
     self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name
     self.peer_networkinterface = NetworkInterface(self.peer_interface,
                                                   self.remotehost)
     smm = SoftwareManager()
     detected_distro = distro.detect()
     pkgs = []
     if detected_distro.name == "Ubuntu":
         pkgs.extend(["ibverbs-utils", 'openssh-client'])
         cmd = "service ufw stop"
     # FIXME: "redhat" as the distro name for RHEL is deprecated
     # on Avocado versions >= 50.0.  This is a temporary compatibility
     # enabler for older runners, but should be removed soon
     elif detected_distro.name in ['rhel', 'fedora', 'redhat']:
         pkgs.extend(["libibverbs", 'openssh-clients'])
         cmd = "systemctl stop firewalld"
     elif detected_distro.name == "SuSE":
         pkgs.append('openssh')
         if detected_distro.version == 15:
             cmd = "systemctl stop firewalld"
         else:
             cmd = "rcSuSEfirewall2 stop"
     elif detected_distro.name == "centos":
         pkgs.extend(['libibverbs', 'openssh-clients'])
         cmd = "service iptables stop"
     else:
         self.cancel("Distro not supported")
     if process.system(cmd, ignore_status=True, shell=True) != 0:
         self.cancel("Unable to disable firewall")
     output = self.session.cmd(cmd)
     if not output.exit_status == 0:
         self.cancel("Unable to disable firewall on peer")
     for pkg in pkgs:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel("%s package is need to test" % pkg)
     if process.system("ibstat", shell=True, ignore_status=True) != 0:
         self.cancel("infiniband adaptors not available")
     self.tool_name = self.params.get("tool")
     self.log.info("test with %s", self.tool_name)
     self.peer_iface = ''
     cmd = "ip addr show"
     output = self.session.cmd(cmd)
     for line in output.stdout.decode("utf-8").splitlines():
         if self.peer_ip in line:
             self.peer_iface = line.split()[-1]
             break