Exemplo n.º 1
0
    def test_cpu_passthrough(self):
        '''
        case_tag:
            CPU
        case_name:
            test_cpu_passthrough
        case_file:
            os_tests.tests.test_nutanix_vm.test_cpu_passthrough
        component:
            CPU
        bugzilla_id:
            N/A
        is_customer_case:
            False
        customer_case_id:
            N/A
        testplan:
            N/A
        maintainer:
            [email protected]
        description:
            Verify CPU passthrough features
        key_steps: |
            1. Enable CPU passthrough, and check CPU info on RHEL guest OS
            2. Disable CPU passthrough, and check CPU info on RHEL guest OS
        expect_result:
            CPU passthrough can be enable or disable and take effect on RHEL guest OS
        debug_want:
            N/A
        '''
        pt_is_disabled = self.vm.get_cpu_passthrough(enabled=False)
        if pt_is_disabled:
            self.vm.set_cpu_passthrough(enabled=True)
            utils_lib.init_connection(self)
            self.assertTrue(self.vm.get_cpu_passthrough(enabled=True),
                            "Test failed as setup CPU passthrough failed")
        else:
            self.fail(
                "Expecte CPU passthrough set as disabled by default, need more investigation here"
            )

        cmd = "grep -i vmx /proc/cpuinfo"
        utils_lib.run_cmd(
            self,
            cmd,
            expect_ret=0,
            expect_kw="vmx",
            msg="Verify if cpu vmx has take effected on RHEL guest OS")

        self.log.info("Recover VM cpu passthrough")
        self.vm.set_cpu_passthrough(enabled=False)
        self.assertTrue(self.vm.get_cpu_passthrough(enabled=False),
                        "Test failed as recover CPU passthrough failed")
        utils_lib.init_connection(self)
        utils_lib.run_cmd(
            self,
            cmd,
            expect_not_ret=0,
            expect_not_kw="vmx",
            msg="Verify if cpu vmx has disabled on RHEL guest OS")
Exemplo n.º 2
0
 def test_check_product_id(self):
     '''
     bz: 1938930
     issue: RHELPLAN-60817
     check if product id matches /etc/redhat-release
     '''
     check_cmd = "sudo cat /etc/redhat-release"
     output = utils_lib.run_cmd(self,
                                check_cmd,
                                expect_ret=0,
                                cancel_not_kw='CentOS,Fedora',
                                msg='check release name')
     product_id = re.findall('\d.\d', output)[0]
     self.log.info("Get product id: {}".format(product_id))
     cmd = 'sudo rpm -qa|grep redhat-release'
     utils_lib.run_cmd(self,
                       cmd,
                       cancel_ret='0',
                       msg='get redhat-release-server version')
     cmd = 'sudo rct cat-cert /etc/pki/product-default/*.pem'
     utils_lib.run_cmd(self,
                       cmd,
                       expect_ret=0,
                       expect_kw="Version: {}".format(product_id),
                       msg='check product certificate')
Exemplo n.º 3
0
    def test_check_sysfs_cpu_list(self):
        '''
        case_name:
            test_check_sysfs_cpu_list

        case_priority:
            1

        component:
            kernel

        bugzilla_id:
            1741462

        polarion_id:
            n/a

        maintainer:
            [email protected]

        description:
            Check no crash when read "cpu_list" in /sys.

        key_steps:
            1. # find -H /sys -name cpu_list  -type f -perm -u=r -print -exec cat '{}' 2>&1 \;

        expected_result:
            No crash/panic happen

        '''
        cmd = "find -H /sys -name cpu_list  -type f -perm -u=r -print -exec cat '{}' 2>&1 \;"
        utils_lib.run_cmd(
            self, cmd, msg='Check no crash seen when read cpu_list if exists')
Exemplo n.º 4
0
 def test_check_dmidecode_dump_segfault(self):
     '''
     case_name:
         test_check_dmidecode_dump_segfault
     case_priority:
         2
     component:
         dmidecode
     bugzilla_id:
         1885823
     customer_case_id:
         02939365
     polarion_id:
         n/a
     maintainer:
         [email protected]
     description:
         check there is no segmentation fault while run 'dmidecode --dump'
     key_steps:
         # dmidecode --dump |grep -i Segmentation 
     expected_result:
         No segmentation fault found.
     '''
     utils_lib.is_cmd_exist(self, cmd='dmidecode')
     cmd = "sudo dmidecode --dump"
     utils_lib.run_cmd(self,
                       cmd,
                       expect_ret=0,
                       expect_not_kw='Segmentation')
Exemplo n.º 5
0
 def test_check_hosts(self):
     '''
     des: localhost ipv6 and ipv4 should be set in /etc/hosts
     '''
     expect_kws = '127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4,::1         localhost localhost.localdomain localhost6 localhost6.localdomain6'
     cmd = "sudo cat /etc/hosts"
     utils_lib.run_cmd(self, cmd, expect_ret=0, expect_kw=expect_kws, msg='check /etc/hosts')
Exemplo n.º 6
0
    def test_check_service(self):
        '''
        case_name:
            test_check_service

        case_priority:
            1

        component:
            systemd

        bugzilla_id:
            1740443

        polarion_id:
            n/a

        maintainer:
            [email protected]

        description:
            Check no failed service in start up.

        key_steps:
            1. # systemctl|grep failed

        expected_result:
            No failed service found.

        '''
        cmd = 'systemctl'
        utils_lib.run_cmd(self, cmd, expect_ret=0)
        utils_lib.run_cmd(self, cmd, expect_ret=0, expect_not_kw='failed')
Exemplo n.º 7
0
    def test_check_available_clocksource(self):
        '''
        polarion_id:
        bz: 1726487
        '''
        output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        if 'Xen' in output:
            expect_clocks = 'xen,tsc,hpet,acpi_pm'
        elif 'aarch64' in output:
            expect_clocks = 'arch_sys_counter'
        elif 'AuthenticAMD' in output and 'KVM' in output:
            expect_clocks = 'kvm-clock,tsc,acpi_pm'
        elif 'GenuineIntel' in output and 'KVM' in output:
            expect_clocks = 'kvm-clock,tsc,acpi_pm'
        else:
            expect_clocks = 'tsc,hpet,acpi_pm'

        cmd = 'sudo cat /sys/devices/system/clocksource/clocksource0/\
available_clocksource'

        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          expect_kw=expect_clocks,
                          msg='Checking available clocksource')
Exemplo n.º 8
0
 def test_check_username(self):
     """
     Check no old username in fresh image
     """
     for user in ['cloud-user']:
         cmd = 'sudo cat /etc/passwd|grep {}'.format(user)
         utils_lib.run_cmd(self, cmd, expect_not_ret='0', msg='check no {} user in fresh image'.format(user))
Exemplo n.º 9
0
 def test_check_sysconfig_kernel(self):
     '''
     des: UPDATEDEFAULT=yes and DEFAULTKERNEL=kernel should be set in /etc/sysconfig/kernel
     '''
     expect_kws = 'UPDATEDEFAULT=yes,DEFAULTKERNEL=kernel-core'
     cmd = "sudo cat /etc/sysconfig/kernel"
     utils_lib.run_cmd(self, cmd, expect_ret=0, expect_kw=expect_kws, msg='check /etc/sysconfig/kernel')
Exemplo n.º 10
0
 def test_check_selinux_status(self):
     """
     case_name:
         test_check_selinux_status
     component:
         rhel-guest-image
     bugzilla_id:
         N/A
     is_customer_case:
         False
     maintainer:
         [email protected]
     description:
         check selinux status is enforcing
     key_steps:
         1. getenforce
         2. cat /etc/selinux/config|grep SELINUX=
     expect_result:
         Enforcing/enforcing
     """
     cmd = "getenforce"
     output = utils_lib.run_cmd(self, cmd, expect_ret=0, msg="getenforce")
     self.assertEqual(output.rstrip('\n'), "Enforcing",
                      "SELinux is not enforcing")
     cmd = "cat /etc/selinux/config|grep SELINUX="
     output = utils_lib.run_cmd(self,
                                cmd,
                                expect_ret=0,
                                msg="get SELINUX in /etc/selinux/config")
     keyword = ""
     for line in output.splitlines():
         if '#' not in line:
             keyword = line.split('=')[1]
     self.assertEqual(keyword, "enforcing", "SELinux is not enforcing")
Exemplo n.º 11
0
 def test_check_bash_history(self):
     '''
     Verify no old .bash_history exists
     '''
     for user in ['cloud-user', 'root']:
         cmd = 'sudo cat ~{}/.bash_history'.format(user)
         utils_lib.run_cmd(self, cmd, expect_not_ret='0', msg='check bash history does not exist in fresh image')
Exemplo n.º 12
0
 def test_dracut_f_v(self):
     '''
     case_name:
         test_dracut_f_v
     case_priority:
         1
     component:
         kernel
     bugzilla_id:
         1849082,1906301
     customer_case_id:
         02925130
     polarion_id:
         n/a
     maintainer:
         [email protected]
     description:
         Test no failed items in generating an initramfs/initrd image.
     key_steps:
         1. # dracut -f -v
     expected_result:
         No failed items found.
     '''
     cmd = "sudo dracut -f -v"
     utils_lib.run_cmd(self,
                       cmd,
                       expect_ret=0,
                       expect_not_kw='Failed,FAILED',
                       timeout=120)
Exemplo n.º 13
0
 def test_fsadm_resize(self):
     """
     case_name:
         test_fsadm_resize
     component:
         lvm2
     bugzilla_id:
         1905705
     is_customer_case:
         True
     maintainer:
         [email protected]
     description:
         test if "fsdadm resize" can run normally
     key_steps:
         1.check cmd fsadm
         2.sudo fsadm resize $(findmnt -n -o source /)
     expect_result:
         fsadm does nothing since the filesystem is already at maximum size
     """
     utils_lib.is_cmd_exist(self, 'fsadm')
     utils_lib.run_cmd(self,
                       'sudo fsadm resize $(findmnt -n -o source /)',
                       expect_ret=0,
                       expect_not_kw="unbound variable",
                       msg="fsadm should not crash")
Exemplo n.º 14
0
 def tearDown(self):
     if 'test_boot_debugkernel' in self.id():
         cmd = "sudo grubby --set-default-index=%s" % self.old_grub_index
         utils_lib.run_cmd(self,
                           cmd,
                           expect_ret=0,
                           msg="restore default boot index to {}".format(
                               self.old_grub_index))
     if 'test_boot_hpet_mmap_enabled' in self.id():
         cmd = 'sudo grubby --update-kernel=ALL  --remove-args="hpet_mmap=1"'
         utils_lib.run_cmd(self, cmd, msg='Remove "hpet_mmap=1"')
     if 'test_boot_mitigations' in self.id():
         cmd = 'sudo grubby --update-kernel=ALL  --remove-args="mitigations=auto,nosmt"'
         utils_lib.run_cmd(self, cmd, msg='Remove "mitigations=auto,nosmt"')
     if 'test_boot_usbcore_quirks' in self.id():
         cmd = 'sudo grubby --update-kernel=ALL  --remove-args="usbcore.quirks=quirks=0781:5580:bk,0a5c:5834:gij"'
         utils_lib.run_cmd(
             self,
             cmd,
             msg='Remove "usbcore.quirks=quirks=0781:5580:bk,0a5c:5834:gij"'
         )
     if 'test_kdump_no_specify_cpu' not in self.id():
         utils_lib.run_cmd(self,
                           'sudo reboot',
                           msg='reboot system under test')
         time.sleep(10)
         utils_lib.init_connection(self, timeout=800)
Exemplo n.º 15
0
    def test_change_clocksource(self):
        '''
        :avocado: tags=test_change_clocksource,fast_check
        polarion_id:
        '''
        output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        cmd = 'sudo cat /sys/devices/system/clocksource/clocksource0/\
current_clocksource'

        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          msg='Check current clock source')
        cmd = 'sudo cat /sys/devices/system/clocksource/clocksource0/\
available_clocksource'

        output = utils_lib.run_cmd(self, cmd, expect_ret=0)
        for clocksource in output.split(' '):
            cmd = 'sudo bash -c \'echo "%s" > /sys/devices/system/clocksource/clocksource0/\
current_clocksource\'' % clocksource
            utils_lib.run_cmd(self,
                              cmd,
                              expect_ret=0,
                              msg='Change clocksource to %s' % clocksource)
            cmd = 'sudo cat /sys/devices/system/clocksource/clocksource0/\
current_clocksource'

            utils_lib.run_cmd(self,
                              cmd,
                              expect_kw=clocksource,
                              msg='Check current clock source')
        utils_lib.run_cmd(self, 'dmesg|tail -30', expect_ret=0)
Exemplo n.º 16
0
    def test_boot_usbcore_quirks(self):
        '''
        bz: 1809429
        polarion_id:
        '''
        utils_lib.run_cmd(self,
                          r'sudo rm -rf /var/crash/*',
                          expect_ret=0,
                          msg='clean /var/crash firstly')
        option = 'usbcore.quirks=quirks=0781:5580:bk,0a5c:5834:gij'
        cmd = 'sudo grubby --update-kernel=ALL --args="{}"'.format(option)
        utils_lib.run_cmd(self,
                          cmd,
                          msg='Append {} to command line!'.format(option),
                          timeout=600)
        utils_lib.run_cmd(self, 'sudo reboot', msg='reboot system under test')
        time.sleep(10)
        utils_lib.init_connection(self, timeout=800)

        utils_lib.run_cmd(self, 'cat /proc/cmdline', expect_kw=option)
        cmd = r'sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50'
        utils_lib.run_cmd(self,
                          cmd,
                          expect_kw='No such file or directory',
                          msg='make sure there is no core generated')
        utils_lib.check_log(self,
                            "error,warn,fail,trace,Trace",
                            skip_words='ftrace',
                            rmt_redirect_stdout=True)
Exemplo n.º 17
0
 def test_check_root_is_locked(self):
     """
     Root account should be locked
     """
     self.log.info('RHEL AMI found')
     cmd = 'sudo passwd -S root | grep -q LK'
     utils_lib.run_cmd(self, cmd, expect_ret=0, msg='check root is locked')
Exemplo n.º 18
0
    def test_check_proc_self_status(self):
        '''
        case_name:
            test_check_proc_self_status

        case_priority:
            1

        component:
            kernel

        bugzilla_id:
            1773868

        polarion_id:
            n/a

        maintainer:
            [email protected]

        description:
            Check no 'unknown' in /proc/self/status.

        key_steps:
            1. # cat /proc/self/status

        expected_result:
            No 'unknown' in this file

        '''
        utils_lib.run_cmd(self,
                          'cat /proc/self/status',
                          expect_not_kw='unknown',
                          msg='Check no unknown in "/proc/self/status"')
Exemplo n.º 19
0
 def test_check_journal_log(self):
     '''
     Verify no traceback|ordering in journalctl -xl
     '''
     ignore_list = []
     utils_lib.run_cmd(self, 'sudo journalctl -xl > /tmp/journal.log')
     self._check_log('/tmp/journal.log', ignore_list, 'traceback|ordering')
Exemplo n.º 20
0
 def test_check_selinux(self):
     '''
     SELinux should be in enforcing/targeted mode
     '''
     out = utils_lib.run_cmd(self, 'uname -r', msg='get kernel version')
     utils_lib.run_cmd(self, 'sudo getenforce',expect_kw='Enforcing', msg='check selinux current mode is Enforcing')
     utils_lib.run_cmd(self, 'sudo cat /etc/sysconfig/selinux',expect_kw='SELINUX=enforcing,SELINUXTYPE=targeted', msg='check selinux current setting')
Exemplo n.º 21
0
 def test_check_authselect(self):
     '''
     Check authselect current
     '''
     if self.rhel_x_version < 8:
         self.skipTest("Only support in RHEL-8+")
     cmd = 'authselect current'
     utils_lib.run_cmd(self, cmd, expect_output="No existing configuration detected.", msg="Check authselect current")
Exemplo n.º 22
0
 def _update_kernel_args(self, boot_param_required):
     cmd = 'sudo grubby --update-kernel=ALL --args="{}"'.format(boot_param_required)
     utils_lib.run_cmd(self, cmd, msg="append {} to boot params".format(boot_param_required))
     utils_lib.run_cmd(self, 'sudo reboot', msg='reboot system under test')
     time.sleep(10)
     utils_lib.init_connection(self, timeout=self.ssh_timeout)
     cat_proc_cmdline = utils_lib.run_cmd(self, 'cat /proc/cmdline')
     return cat_proc_cmdline
Exemplo n.º 23
0
 def test_check_chrony_conf(self):
     '''
     Verify file /etc/chrony.conf is not changed
     '''
     # filename = '/etc/chrony.conf'
     # self._check_file_content(filename.split('/')[-1], filename, project=self.rhel_x_version)
     # self._check_file_not_changed("chrony")
     utils_lib.run_cmd(self, "sudo cat /etc/chrony.conf", expect_ret=0, expect_kw='server metadata.google.internal iburst', msg='check chrony points to Google Time Sync service')
Exemplo n.º 24
0
 def test_check_ttyS0_conf(self):
     """
     bz: 1103344
     check no "/etc/init/ttyS0.conf" exists.
     check no "/dev/ttyS0: tcgetattr: Input/output error" in "/var/log/secure"
     """
     utils_lib.run_cmd(self, 'sudo cat /etc/init/ttyS0.conf', expect_not_ret=0, msg='make sure no /etc/init/ttyS0.conf found')
     utils_lib.run_cmd(self, 'sudo cat /etc/init/ttyS0.bak', msg='ttyS0.bak may also not in RHEL nowadays')
Exemplo n.º 25
0
 def test_check_auditd(self):
     """
     Check auditd:
     - service should be on
     - config files shoud have specified checksums
     """
     utils_lib.run_cmd(self, 'sudo systemctl is-active auditd', expect_ret=0, msg="Ensure auditd service is active")
     utils_lib.run_cmd(self, 'sudo rpm -V audit', expect_ret=0, msg='Ensure /etc/auditd.conf is not changed')
Exemplo n.º 26
0
 def test_check_cpu_flags(self):
     '''
     rhbz: 1061348
     check various cpu flags
     '''
     utils_lib.is_arch(self, arch='x86_64', action='cancel')
     cmd = "sudo cat /proc/cpuinfo"
     utils_lib.run_cmd(self, cmd, expect_ret=0, expect_kw='avx,xsave,pcid', msg='check avx,xsave,pcid flags')
Exemplo n.º 27
0
 def test_check_rhel_version(self):
     '''
     check if rhel provider matches /etc/redhat-release
     '''
     release_file = 'redhat-release'
     product_id = utils_lib.get_product_id(self)
     cmd = "echo $(sudo rpm -q --qf '%{VERSION}' --whatprovides " + release_file + ')'
     utils_lib.run_cmd(self,cmd, expect_kw=product_id, msg='check redhat-release version match')
Exemplo n.º 28
0
 def test_check_hostkey_permission(self):
     '''
     bz: 2013644
     Verify /etc/ssh/ssh_host_xxx_key permission are 600, group is root.
     '''
     expected = "-rw-------.rootroot"
     cmd = "ls -l /etc/ssh/{ssh_host_ecdsa_key,ssh_host_ed25519_key,ssh_host_rsa_key}|awk '{print $1$3$4}'|uniq"
     utils_lib.run_cmd(self, cmd, expect_output=expected, msg="Verify /etc/ssh/ssh_host_xxx_key permission is 600, group is ssh_keys")
Exemplo n.º 29
0
    def test_check_metadata(self):
        '''
        polarion_id:
        https://cloudinit.readthedocs.io/en/latest/topics/datasources/ec2.html
        '''
        cmd = r"curl http://169.254.169.254/latest/meta-data/instance-type"

        utils_lib.run_cmd(self, cmd, expect_ret=0, expect_not_kw="Not Found")
Exemplo n.º 30
0
    def test_iostat_x(self):
        '''
        case_name:
            test_iostat_x
        case_priority:
            1
        component:
            kernel
        bugzilla_id:
            1661977
        polarion_id:
            n/a
        maintainer:
            [email protected]
        description:
            Check "iostat -x" report and make sure there is no high utils when there is no obviously read/write operations.
        key_steps:
            1. # iostat -x
        expected_result:
            No high utils reported when no obviously read/write operations.
            eg. # iostat -x
                Linux 4.18.0-236.el8.aarch64 (ip-xx-xxx-x-xxx.us-west-2.compute.internal) 	09/28/2020 	_aarch64_	(2 CPU)

                avg-cpu:  %user   %nice %system %iowait  %steal   %idle
                           7.77    0.00    1.48    0.69    0.00   90.06

                Device            r/s     w/s     rkB/s     wkB/s   rrqm/s   wrqm/s  %rrqm  %wrqm r_await w_await aqu-sz rareq-sz wareq-sz  svctm  %util
                nvme0n1         46.06    2.82   1587.81    274.62     0.00     0.23   0.00   7.52    0.50    1.32   0.00    34.47    97.31   0.86   4.19
                nvme1n1          0.15    0.00     10.43      0.00     0.00     0.00   0.00   0.00    1.00    0.00   0.00    70.40     0.00   1.50   0.02
        '''
        expect_utils = self.params.get('disk_utils')
        self.log.info("Check no disk utils lager than %s" % expect_utils)
        utils_lib.is_cmd_exist(self, cmd='iostat')
        cmd = 'sudo  iostat -x -o JSON'
        output = utils_lib.run_cmd(self, cmd)
        try:
            res_dict = json.loads(output)
            for x in res_dict["sysstat"]["hosts"][0]["statistics"][0]["disk"]:
                self.assertLessEqual(
                    x["util"],
                    expect_utils,
                    msg="Utils more than %s without any large io! act: %s" %
                    (expect_utils, x["util"]))
        except ValueError as err:
            self.log.info("cmd has no json support")
            cmd = "sudo iostat -x"
            utils_lib.run_cmd(self, cmd, expect_ret=0)
            cmd = "sudo iostat -x|awk -F' ' '{print $NF}'"
            output = utils_lib.run_cmd(self, cmd, expect_ret=0)
            compare = False
            for util in output.split('\n'):
                if 'util' in util:
                    compare = True
                    continue
                if compare and not util == '':
                    if float(util) > expect_utils:
                        self.fail("Some disk's utils %s is larger than %s" %
                                  (util, expect_utils))