def test_check_yum_repoinfo(test_instance): """Check the yum repoinfo for RHUI repos. case_name: [Aliyun]GeneralTest.test_check_yum_repoinfo description: Check the yum repoinfo for RHUI repos. bugzilla_id: n/a polarion_id: https://polarion.engineering.redhat.com/polarion/#/project/\ RedHatEnterpriseLinux7/workitems?query=title:\ "[Aliyun]GeneralTest.test_check_yum_repoinfo" maintainer: [email protected] case_priority: 0 case_component: checkup key_steps: 1. yum repoinfo, Repo-pkgs is not zero. pass_criteria: All commands succeed. """ run_cmd(test_instance, 'sudo yum repoinfo', expect_ret=0, expect_not_kw='Repo-pkgs : 0', timeout=1200, msg='try to get repo info')
def test_check_vulnerabilities(self): """ Check vulnerabilities for RHEL on Aliyun. case_name: [Aliyun]GeneralTest.test_check_vulnerabilities description: Check vulnerabilities for RHEL on Aliyun. bugzilla_id: n/a polarion_id: https://polarion.engineering.redhat.com/polarion/#/project/\ RedHatEnterpriseLinux7/workitems?query=title:\ "[Aliyun]GeneralTest.test_check_vulnerabilities" maintainer: [email protected] case_priority: 0 case_component: checkup key_steps: 1. Launch an instance on Aliyun. 2. Get microcode version via command "rpm -qa | grep microcode". 3. Check the current vulnerabilities via command "grep ^ /sys/devices/system/cpu/vulnerabilities/*". pass_criteria: There is no unexpected vulnerabilities in system. Whitelisted all the vulnerabilities from RHEL7.9 and RHEL8.3 before July 2021. """ # Print microcode version utils_alibaba.run_cmd(self, 'rpm -qa|grep microcode', msg='Get microcode version') # Print vulnerabilities check_cmd = 'grep ^ /sys/devices/system/cpu/vulnerabilities/* | sed "s#^.*vulnerabilities/##"' utils_alibaba.run_cmd(self, check_cmd, expect_ret=0) # Apply whitelist and perform checking data_file = 'vulnerabilities.el{}.lst'.format(self.rhel_ver) if not utils_alibaba.is_data_file_exist(self.cloud.cloud_provider, data_file): data_file = 'vulnerabilities.el{}.lst'.format( self.rhel_ver.split('.')[0]) if not utils_alibaba.is_data_file_exist(self.cloud.cloud_provider, data_file): self.error('Data file can not be found.') self.session.copy_data_to_guest(self.cloud.cloud_provider, data_file) check_cmd += ' | grep -v "Not affected" | grep -vxFf {}'.format( os.path.join(self.dest_dir, data_file)) utils_alibaba.run_cmd(self, check_cmd, expect_output='')
def test_yum_package_install(test_instance): """Check the yum package installation. case_name: [Aliyun]GeneralTest.test_yum_package_install description: Check the yum package installation. bugzilla_id: n/a polarion_id: https://polarion.engineering.redhat.com/polarion/#/project/\ RedHatEnterpriseLinux7/workitems?query=title:\ "[Aliyun]GeneralTest.test_yum_package_install" maintainer: [email protected] case_priority: 0 case_component: checkup key_steps: 1. yum clean all 2. yum repolist 3. yum check-update 4. yum search zsh 5. yum -y install zsh 6. sudo rpm -e zsh pass_criteria: All commands succeed. """ run_cmd(test_instance, "sudo yum clean all", expect_ret=0, timeout=180) run_cmd(test_instance, "sudo yum repolist", expect_ret=0, timeout=1200) run_cmd(test_instance, "sudo yum check-update", timeout=1200) run_cmd(test_instance, "sudo yum search zsh", expect_ret=0, timeout=180) run_cmd(test_instance, "sudo yum -y install zsh", expect_ret=0, timeout=180) run_cmd(test_instance, r"sudo rpm -q --queryformat '%{NAME}' zsh", expect_ret=0) run_cmd(test_instance, "sudo rpm -e zsh", expect_ret=0)