Exemplo n.º 1
0
    def test_kdump_no_specify_cpu(self):
        '''
        bz: 1654962
        polarion_id: RHEL7-58669
        '''
        for cmd in ['sudo kdumpctl showmem','cat /proc/cmdline','systemctl is-active kdump']:
            utils_lib.run_cmd(self, cmd, expect_ret=0)
        output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        product_id = utils_lib.get_product_id(self)
        if utils_lib.is_arch(self, 'aarch64') and not utils_lib.is_metal(self) and float(product_id) < 8.6:
            self.skipTest("Cancel as bug 1654962 in arm guest earlier than 8.6 2082405" )
        utils_lib.run_cmd(self,
                    r'sudo rm -rf /var/crash/*',
                    expect_ret=0,
                    msg='clean /var/crash firstly')
        utils_lib.run_cmd(self, r'sudo sync', expect_ret=0)
        self.log.info("Before system crash")
        utils_lib.run_cmd(self,
                    r'find /var/crash',
                    expect_ret=0,
                    msg='list /var/crash')
        utils_lib.run_cmd(self, "sudo bash -c \"echo c > /proc/sysrq-trigger\"", msg='trigger crash')

        utils_lib.init_connection(self, timeout=self.ssh_timeout)
        self.log.info("After system crash")
        utils_lib.run_cmd(self,
                    r'find /var/crash',
                    expect_ret=0,
                    msg='list /var/crash after crash')
        cmd = r'sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50'
        utils_lib.run_cmd(self, cmd, expect_ret=0, expect_kw='write_sysrq_trigger')
Exemplo n.º 2
0
 def test_check_microcode_load(self):
     '''
     bz: 1607899
     des: Don't attempt to perform early microcode update on virtualized guests
     This case checks it from dmesg output.
     '''
     cpu_info = utils_lib.run_cmd(self,
                                  'lscpu',
                                  expect_ret=0,
                                  cancel_not_kw="aarch64",
                                  msg="Only run in x86 platform")
     utils_lib.run_cmd(self,
                       "rpm -qa|grep microcode",
                       msg='get microcode pkg version')
     utils_lib.run_cmd(self,
                       "rpm -qa|grep linux-firmware",
                       msg='get linux-firmware pkg version')
     cmd = 'dmesg|grep microcode'
     if utils_lib.is_metal(self):
         utils_lib.run_cmd(self,
                           cmd,
                           expect_kw="microcode updated early",
                           msg='microcode should load in bare metal')
     else:
         utils_lib.run_cmd(self,
                           cmd,
                           expect_not_kw='microcode updated early',
                           msg='microcode should not load in VMs')
Exemplo n.º 3
0
    def setUp(self):
        utils_lib.init_case(self)
        if self.params['remote_node'] is None:
            self.skipTest("Only support to run in server-client mode!")
        if utils_lib.is_metal(self) or utils_lib.is_ahv(self):
            self.ssh_timeout = 1200
            self.SSH.interval = 60
        else:
            self.ssh_timeout = 180
        self.log.info('set ssh connection timeout to {}'.format(self.ssh_timeout))

        if 'kdump' in self.id():
            timeout = 120
            interval = 5
            time_start = int(time.time())
            while True:
               cmd = 'sudo systemctl is-active kdump'
               ret = utils_lib.run_cmd(self, cmd,ret_status=True, msg='check kdump is active')
               if ret == 0: break
               time_end = int(time.time())
               if time_end - time_start > timeout:
                  self.log.info('timeout ended: {}'.format(timeout))
                  break
               self.log.info('retry after {}s'.format(interval))
               time.sleep(interval)
Exemplo n.º 4
0
    def test_kdump_no_specify_cpu(self):
        '''
        bz: 1654962
        polarion_id: RHEL7-58669
        '''
        cmd = 'systemctl is-active kdump'
        utils_lib.run_cmd(self, cmd, expect_ret=0, msg='check kdump service')
        output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        self.is_metal = utils_lib.is_metal(self)
        if utils_lib.is_arch(self, 'aarch64') and not utils_lib.is_metal(self):
            self.cancel("Cancel as bug 1654962 in arm guest which \
no plan to fix it in the near future!")

        utils_lib.run_cmd(self,
                          r'sudo rm -rf /var/crash/*',
                          expect_ret=0,
                          msg='clean /var/crash firstly')
        utils_lib.run_cmd(self, r'sudo sync', expect_ret=0)
        self.log.info("Before system crash")
        utils_lib.run_cmd(self,
                          r'find /var/crash',
                          expect_ret=0,
                          msg='list /var/crash')
        utils_lib.run_cmd(self,
                          'sudo echo c > /proc/sysrq-trigger',
                          msg='trigger crash')

        if self.is_metal:
            self.log.info("Wait 180s")
            time.sleep(180)
        else:
            self.log.info("Wait 30s")
            time.sleep(30)
        utils_lib.init_connection(self)
        self.log.info("After system crash")
        utils_lib.run_cmd(self,
                          r'find /var/crash',
                          expect_ret=0,
                          msg='list /var/crash after crash')
        cmd = r'sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50'
        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          expect_kw='write_sysrq_trigger')
Exemplo n.º 5
0
 def test_check_virtwhat(self):
     '''
     bz: 1782435
     polarion_id: RHEL7-103857
     test virt-what, not use systemd-detect-virt
     '''
     utils_lib.is_cmd_exist(self, cmd='virt-what')
     utils_lib.run_cmd(self,
                       "rpm -q virt-what",
                       expect_ret=0,
                       msg='get virt-what version')
     virt_what_output = utils_lib.run_cmd(self,
                                          r"sudo virt-what",
                                          expect_ret=0)
     lscpu_output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
     if 'Xen' in lscpu_output:
         self.log.info("Found it is a xen system!")
         if 'full' in lscpu_output:
             self.assertIn('xen-hvm', virt_what_output)
         else:
             self.assertIn('xen-domU', virt_what_output)
     elif 'KVM' in lscpu_output and not utils_lib.is_metal(self):
         self.log.info("Found it is a kvm system!")
         self.assertIn('kvm', virt_what_output)
     elif 'VMware' in lscpu_output:
         self.log.info("Found it is a vmware system!")
         self.assertIn('vmware', virt_what_output)
     elif 'Microsoft' in lscpu_output:
         self.log.info("Found it is a Hyper-V system!")
         self.assertIn('hyperv', virt_what_output)
     elif utils_lib.is_metal(self) and utils_lib.is_aws(self):
         self.log.info("Found it is a bare metal system!")
         self.assertEqual('aws', virt_what_output.strip('\n'))
     elif utils_lib.is_metal(self):
         self.log.info("Found it is a bare metal system!")
     elif utils_lib.is_aws(self) and utils_lib.is_arch(self,
                                                       arch='aarch64'):
         self.assertEqual('aws', virt_what_output.strip('\n'))
     else:
         self.skipTest("Unknow hypervisor")
Exemplo n.º 6
0
 def setUp(self):
     utils_lib.init_case(self)
     if not self.vm:
         self.skipTest("no vm found!")
     if self.params['remote_node'] is None:
         self.skipTest("Only support to run in server-client mode!")
     if utils_lib.is_metal(self):
         self.ssh_timeout = 1200
         self.SSH.interval = 60
     else:
         self.ssh_timeout = 180
     self.log.info('set ssh connection timeout to {}'.format(
         self.ssh_timeout))
Exemplo n.º 7
0
    def test_check_tuned_adm_active(self):
        '''
        case_name:
            test_check_tuned_adm_active

        case_priority:
            1

        component:
            kernel

        bugzilla_id:
            1893063

        polarion_id:
            n/a

        maintainer:
            [email protected]

        description:
            Check tuned-adm loads default "virtual-guest" in vm and does not load virtual-guest in metal instance

        key_steps:
            1. # tuned-adm active

        expected_result:
            Should not load virtual-guest in bare metal.
            Should load virtual-guest in vm by default.

        '''
        utils_lib.is_cmd_exist(self, cmd='tuned-adm', cancel_case=True)
        if 'inactive' in utils_lib.run_cmd(self,
                                           'sudo systemctl is-active tuned'):
            utils_lib.run_cmd(self,
                              'sudo systemctl enable --now tuned',
                              msg='enable tuned service')
        if utils_lib.is_metal(self):
            utils_lib.run_cmd(
                self,
                'tuned-adm active',
                expect_not_kw='virtual-guest',
                msg='Should not load virtual-guest in bare metal')
        else:
            utils_lib.run_cmd(self,
                              'tuned-adm active',
                              expect_kw='virtual-guest',
                              msg='Should load virtual-guest in vm by default')
Exemplo n.º 8
0
    def test_ltp_cpuhotplug(self):
        '''
        bz: 1464095,1908550
        polarion_id: RHEL7-98752
        '''
        # ltp will considering fail if more than 1 cpus cannot be offline
        # in bare metal instance
        # but in large metal instances, it is expected. So do not do it in
        # bare metal instances
        utils_lib.run_cmd(self,
                    'lscpu',
                    expect_ret=0,
                    cancel_not_kw="Xen",
                    msg="Not run in xen instance as bug 1641510 which is very low priority")
        if utils_lib.is_aws(self) and utils_lib.is_metal(self):
            self.skipTest('Cancel test as aws bare metal needs 1+ cpus working \
at least which ltp not handle')
        else:
            self._ltp_run(case_name="cpuhotplug")
Exemplo n.º 9
0
    def test_check_cpu_vulnerabilities(self):
        '''
        check if cpu has unexpected Vulnerable
        '''

        utils_lib.run_cmd(self,
                          "rpm -qa|grep microcode",
                          msg='Get microcode version')
        utils_lib.run_cmd(self,
                          "rpm -qa|grep linux-firmware",
                          msg='get linux-firmware pkg version')
        check_cmd = r"sudo grep . /sys/devices/system/cpu/vulnerabilities/* | \
sed 's/:/^/' | column -t -s^"

        utils_lib.run_cmd(self, check_cmd, expect_ret=0)

        output = utils_lib.run_cmd(self, 'uname -r', expect_ret=0)
        if utils_lib.is_metal(self):
            self.log.info(
                "Bare metal instance should not have any vulnerable (microload loaded)."
            )
            cmd = r"sudo grep . /sys/devices/system/cpu/vulnerabilities/* | \
sed 's/:/^/' | column -t -s^"

        elif 'el7' in output:
            self.log.info(
                "Skip spec_store_bypass,Retpoline and mds in RHEL7 vms")
            check_cmd = r"sudo grep . /sys/devices/system/cpu/vulnerabilities/* | \
grep -v spec_store_bypass|grep -v 'tsx_async_abort'|grep -v 'Vulnerable: Retpoline'|\
grep -v mds| sed 's/:/^/' | column -t -s^"

        else:
            self.log.info(
                "Skip spec_store_bypass and mds,itlb_multihit in vms")
            check_cmd = r"sudo grep . /sys/devices/system/cpu/vulnerabilities/*|\
grep -v spec_store_bypass|grep -v 'tsx_async_abort'|grep -v mds|grep -v \
itlb_multihit|sed 's/:/^/' | column -t -s^"

        utils_lib.run_cmd(self,
                          check_cmd,
                          expect_ret=0,
                          expect_not_kw='Vulnerable')
Exemplo n.º 10
0
    def test_ltp_cpuhotplug(self):
        """
        case_tag:
            kernel
        case_name:
            test_ltp_cpuhotplug
        component:
            xen
        bugzilla_id:
            1464095,1908550
        is_customer_case:
            False
        maintainer:
            [email protected]
        description:
            check if cpu can restore online after offline it
        key_steps:
            1.check machine is not xen or aws bare metal machine
            2.run cpuhotplug ltp test
        expect_result:
            test should be PASS and no crash seen
        debug_want:
            dmesg
        """
        '''
        bz: 1464095,1908550
        polarion_id: RHEL7-98752
        '''
        # ltp will considering fail if more than 1 cpus cannot be offline
        # in bare metal instance
        # but in large metal instances, it is expected. So do not do it in
        # bare metal instances
        utils_lib.run_cmd(self,
                    'lscpu',
                    expect_ret=0,
                    cancel_not_kw="Xen",
                    msg="Not run in xen instance as bug 1641510 which is very low priority")
        if utils_lib.is_aws(self) and utils_lib.is_metal(self):
            self.skipTest('Cancel test as aws bare metal needs 1+ cpus working \
at least which ltp not handle')
        else:
            self._ltp_run(case_name="cpuhotplug")
Exemplo n.º 11
0
    def test_virsh_pci_reattach(self):
        '''
        case_name:
            test_virsh_pci_reattach
        case_priority:
            1
        component:
            kernel
        bugzilla_id:
            1700254
        polarion_id:
            n/a
        maintainer:
            [email protected]
        description:
            Test no exception when system does pci detach and attach operation in virsh.
            virsh can detach host pci device and attach it to guest.
        key_steps:
            1. #virsh  nodedev-detach $pci
            2. #virsh  nodedev-reattach $pci
        expected_result:
            No panic/crash happen.
            eg. # virsh nodedev-detach pci_0000_2b_00_0
                Device pci_0000_2b_00_0 detached
                # virsh nodedev-reattach pci_0000_2b_00_0
                Device pci_0000_2b_00_0 re-attached
        '''
        utils_lib.is_metal(self, action="cancel")
        cmd = "sudo yum install -y libvirt"
        utils_lib.run_cmd(self, cmd, msg="install libvirt pkg")
        cmd = "sudo systemctl restart libvirtd"
        utils_lib.run_cmd(self, cmd, cancel_ret='0', msg="restart libvirtd")
        utils_lib.is_cmd_exist(self, cmd='virsh')
        if utils_lib.is_arch(self, arch='x86_64'):
            utils_lib.run_cmd(self,
                              'cat /proc/cmdline',
                              cancel_kw='intel_iommu=on',
                              msg='Check boot line')

        utils_lib.run_cmd(self, 'sudo lspci', msg="get pci list")
        tmp_pci = None
        cmd = "lspci|grep 'Non-Volatile memory'|wc -l"
        out = utils_lib.run_cmd(self, cmd)
        if int(out) > 0:
            cmd = 'sudo find /sys/devices -name *nvme*n1p1*'
            tmp_root = utils_lib.run_cmd(self, cmd, msg="get boot nvme pci")
            boot_pci = tmp_root.split('/')[-2]
            cmd = 'sudo find /sys/devices -name *nvme*|grep -v %s|\
grep -i pci|grep n1' % boot_pci
            ret = utils_lib.run_cmd(self,
                                    cmd,
                                    msg="get test pci",
                                    ret_status=True)
            if int(ret) == 0:
                tmp_pci = utils_lib.run_cmd(self, cmd, msg="get test pci")
                if len(tmp_pci) > 0:
                    tmp_pci = tmp_pci.split('/')[-4]
                else:
                    tmp_pci = None
            else:
                tmp_pci = None
        if tmp_pci is None:
            cmd = 'sudo find /sys/devices -name *ttyS0*|grep [0-9]:[0-9]'
            tmp_root = utils_lib.run_cmd(self,
                                         cmd,
                                         msg="try to get ttyS0 pci device")
            if len(tmp_root) == 0:
                tmp_pci = None
            else:
                serial_pci = tmp_root.split('/')[-3]
                tmp_pci = serial_pci
        if tmp_pci is None:
            cmd = 'sudo find /sys/devices -name *vga*|grep [0-9]:[0-9]'
            tmp_root = utils_lib.run_cmd(self,
                                         cmd,
                                         msg="try to get vga pci device")
            if len(tmp_root) == 0:
                tmp_pci = None
            else:
                vga_pci = tmp_root.split('/')[-2]
                tmp_pci = vga_pci
        if tmp_pci is not None:
            self.log.info("Get pci device: {}".format(tmp_pci))
        else:
            self.skipTest("No pci device found to detach")

        tmp_pci = tmp_pci.replace('.', '_')
        tmp_pci = tmp_pci.replace(':', '_')
        pci_dev_1 = utils_lib.run_cmd(
            self,
            'sudo virsh nodedev-list|grep %s |tail -1' % tmp_pci,
            msg='pick up device to detach')
        if pci_dev_1.endswith('1'):
            pci_dev_0 = pci_dev_1.rstrip('1') + '0'
            utils_lib.run_cmd(self,
                              'sudo virsh nodedev-detach %s' % pci_dev_0,
                              msg='detach pci device',
                              expect_ret=0)
        utils_lib.run_cmd(self,
                          'sudo virsh nodedev-detach %s' % pci_dev_1,
                          msg='detach pci device',
                          expect_ret=0)
        utils_lib.run_cmd(self,
                          'sudo virsh nodedev-reattach %s' % pci_dev_1,
                          msg='reattach pci device',
                          expect_ret=0)
        if pci_dev_1.endswith('1'):
            utils_lib.run_cmd(self,
                              'sudo virsh nodedev-reattach %s' % pci_dev_0,
                              msg='reattach pci device',
                              expect_ret=0)
        utils_lib.check_log(self,
                            "error,warn,fail,trace,Trace",
                            log_cmd='dmesg -T',
                            cursor=self.dmesg_cursor)
Exemplo n.º 12
0
    def test_kdump_each_cpu(self):
        """
        case_tag:
            kdump
        case_name:
            test_kdump_each_cpu
        case_file:
            os_tests.tests.test_lifecycle.test_kdump_each_cpu
        component:
            kdump
        bugzilla_id:
            1396554
        is_customer_case:
            False
        customer_case_id:
            N/A
        testplan:
            N/A
        maintainer:
            [email protected]
        description:
            Test kdump on each cpu core
        key_steps: |
            1. Triger crash on each cpu core
            2. Check if kdump is working and dump file will be generated
        expect_result:
            kdump is working and dump file will be generated
        debug_want:
            N/A
        debug_want:
            N/A
        """
        utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        product_id = utils_lib.get_product_id(self)
        if utils_lib.is_arch(self, 'aarch64') and not utils_lib.is_metal(self) and float(product_id) < 8.6:
            self.skipTest("Cancel as bug 1654962 in arm guest earlier than 8.6 2082405" )
        
        cmd = "grep processor /proc/cpuinfo | wc -l"
        cpu_counts = int(utils_lib.run_cmd(self, cmd, expect_ret=0,
                                           msg = "Get cpu counts"))
        for core_num in range(cpu_counts):
            self.log.info("Trigger kdump on core %d" % core_num)
            cmd = "systemctl is-active kdump || sudo systemctl start kdump"
            utils_lib.run_cmd(self, cmd, expect_ret=0, msg="check kdump service status")
            
            utils_lib.run_cmd(self,
                        "sudo rm -rf /var/crash/*",
                        expect_ret=0,
                        msg="clean /var/crash")
            utils_lib.run_cmd(self, "sudo sync", expect_ret=0)
            self.log.info("Before system crash")
            res_before = utils_lib.run_cmd(self,
                                           "find /var/crash",
                                           expect_ret=0,
                                           msg="list /var/crash before crash")
            cmd = "sudo bash -c 'taskset -c %d echo c > /proc/sysrq-trigger'" % core_num
            utils_lib.run_cmd(self, cmd, msg='trigger crash')
            time.sleep(30)

            self.params['remote_node'] = self.vm.floating_ip
            utils_lib.init_connection(self, timeout=self.ssh_timeout)
            self.log.info("After system crash")
            res_after = utils_lib.run_cmd(self,
                                          "find /var/crash",
                                          expect_ret=0,
                                          msg="list /var/crash after crash")
            self.assertNotEqual(res_after, res_before,
                                "Test failed as no crash dump file found")

            cmd = "sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50"
            utils_lib.run_cmd(self, cmd, expect_ret=0,
                              expect_kw="write_sysrq_trigger",
                              msg="Check if crash happened")