Skip to content

Commit

Permalink
Merge pull request #248 from linl-rh/master
Browse files Browse the repository at this point in the history
Add two test cases about fastboot to Alibaba.
  • Loading branch information
yoguo authored Nov 21, 2022
2 parents 2e7beb9 + 176587e commit aa9beab
Show file tree
Hide file tree
Showing 2 changed files with 204 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/alibaba_testcases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ cases:
test_functional_checkup.py:GeneralTest.test_check_virt_what
test_functional_checkup.py:GeneralTest.test_check_pv_drivers
test_functional_checkup.py:GeneralTest.test_kdump_function
test_functional_checkup.py:GeneralTest.test_kexec_fastboot_systemctl
test_functional_checkup.py:GeneralTest.test_kexec_fastboot_kexec_e
test_functional_checkup.py:GeneralTest.test_check_image_id
test_functional_checkup.py:GeneralTest.test_check_vulnerabilities
test_functional_checkup.py:GeneralTest.test_check_rhui_crt
Expand Down
202 changes: 202 additions & 0 deletions tests/alibaba/test_functional_checkup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,208 @@ def test_kdump_function(self):
cmd = 'cat /var/crash/1*/vmcore-dmesg.txt|tail -50'
utils_alibaba.run_cmd(self, cmd, expect_ret=0, expect_kw='write_sysrq_trigger')

def test_kexec_fastboot_systemctl(self):
"""
case_name:
[Aliyun]GeneralTest.test_kexec_fastboot_systemctl
case_tags:
kdump
case_status:
Approved
title:
[Aliyun]GeneralTest.test_kexec_fastboot_systemctl
polarion_id:
https://polarion.engineering.redhat.com/polarion/#/project/RHELVIRT/workitems?query=title:"[Aliyun]GeneralTest.test_kexec_fastboot_systemctl"
importance:
Critical
subsystem_team:
sst_virtualization_cloud
automation_drop_down:
Automated
linked_work_items:
polarion-VIRT-99338
automation_field:
https://github.com/virt-s1/avocado-cloud/tree/master/tests/alibaba/test_functional_checkup.py
setup_teardown:
n/a
environment:
n/a
component:
kernel
bug_id:
1758323, 1841578
is_customer_case:
False
testplan:
https://polarion.engineering.redhat.com/polarion/#/project/RHELVIRT/wiki/Alibaba/Aliyun%20RHEL%20guest%20Test%20Plan
test_type:
Functional
test_level:
Component
maintainer:
[email protected]
description:
Test fastboot kernel via systemctl kexec.
key_steps:
1. Start an instance (e.g., c6.xlarge) with RHEL image on Aliyun.
2. Check the kdump service is enabled and active.
3. Load each kernel with command "sudo kexec -l /boot/vmlinuz-$version --initrd=/boot/initramfs-$version.img --reuse-cmdline"
4. Fastboot via command "systemctl kexec".
expected_result:
Kernel is loaded successfully without panic or crash.
debug_want:
n/a
"""

self.log.info("Checking kdump status")

if self.rhel_ver.split('.')[0] == '6':
check_cmd = 'sudo service kdump status'
else:
check_cmd = 'systemctl status kdump.service'

kdump_running = False

for i in range(10):
output = self.session.cmd_output(check_cmd)
self.log.debug("%s" % output)
if 'Active: active' in output:
self.log.info('kdump service is running.')
kdump_running = True
break
else:
if 'Active: inactive' in output:
self.log.error('kdump service is inactive!')
break
if 'Kdump is unsupported' in output:
self.log.error('kdump service is unsupported!')
break
self.log.info('Wait for another 20s (max = 200s)')
time.sleep(20)

if not kdump_running:
self.cancel('Cancel test as kdump is not running.')

self.log.info("Test fastboot via systemctl kexec")
self.session.connect()
utils_alibaba.run_cmd(self,'uname -r', cancel_not_kw='el7,el6', msg='Not full support earlier than el8, skip!')
cmd = 'sudo rpm -qa|grep -e "kernel-[0-9]"'
output = utils_alibaba.run_cmd(self, cmd, msg='Get kernel version')
kernels_list = output.split('\n')
for kernel in kernels_list:
kernel_vmlinuz = "/boot/" + kernel.replace('kernel','vmlinuz')
kernel_initramfs = "/boot/" + kernel.replace('kernel','initramfs') + ".img"
cmd = "sudo kexec -l %s --initrd=%s --reuse-cmdline" % (kernel_vmlinuz, kernel_initramfs)
utils_alibaba.run_cmd(self, cmd, msg='Switch kernel', expect_ret=0)
cmd = "sudo systemctl kexec"
self.log.info("CMD: %s", cmd)
self.session.session.sendline("%s" % cmd)
time.sleep(10)
self.session.connect()
utils_alibaba.run_cmd(self, 'uname -r', msg='check kernel', expect_ret=0, expect_kw=kernel[7:])

def test_kexec_fastboot_kexec_e(self):
"""Test case for avocado framework.
case_name:
[Aliyun]GeneralTest.test_kexec_fastboot_kexec_e
case_tags:
kdump
case_status:
Approved
title:
[Aliyun]GeneralTest.test_kexec_fastboot_systemctl
polarion_id:
https://polarion.engineering.redhat.com/polarion/#/project/RHELVIRT/workitems?query=title:"[Aliyun]GeneralTest.test_kexec_fastboot_kexec_e"
importance:
Critical
subsystem_team:
sst_virtualization_cloud
automation_drop_down:
Automated
linked_work_items:
polarion-VIRT-99338
automation_field:
https://github.com/virt-s1/avocado-cloud/tree/master/tests/alibaba/test_functional_checkup.py
setup_teardown:
n/a
environment:
n/a
component:
kernel
bug_id:
1758323, 1841578
is_customer_case:
False
testplan:
https://polarion.engineering.redhat.com/polarion/#/project/RHELVIRT/wiki/Alibaba/Aliyun%20RHEL%20guest%20Test%20Plan
test_type:
Functional
test_level:
Component
maintainer:
[email protected]
description:
Test fastboot kernel via systemctl kexec.
key_steps:
1. Start an instance (e.g., c6.xlarge) with RHEL image on Aliyun.
2. Check the kdump service is enabled and active.
3. Load each kernel with command "sudo kexec -l /boot/vmlinuz-$version --initrd=/boot/initramfs-$version.img --reuse-cmdline"
4. Fastboot via command "kexec -e".
expected_result:
Kernel can be loaded via kexec, and system will reboot into the loaded kernel via kexec -e without calling shutdown(8).
debug_want:
n/a
"""

self.log.info("Checking kdump status")

if self.rhel_ver.split('.')[0] == '6':
check_cmd = 'sudo service kdump status'
else:
check_cmd = 'systemctl status kdump.service'

kdump_running = False

for i in range(10):
output = self.session.cmd_output(check_cmd)
self.log.debug("%s" % output)
if 'Active: active' in output:
self.log.info('kdump service is running.')
kdump_running = True
break
else:
if 'Active: inactive' in output:
self.log.error('kdump service is inactive!')
break
if 'Kdump is unsupported' in output:
self.log.error('kdump service is unsupported!')
break
self.log.info('Wait for another 20s (max = 200s)')
time.sleep(20)

if not kdump_running:
self.cancel('Cancel test as kdump is not running.')

self.log.info("Test fastboot via systemctl kexec")
self.session.connect()
utils_alibaba.run_cmd(self,'uname -r', cancel_not_kw='el7,el6', msg='Not full support earlier than el8, skip!')
cmd = 'sudo rpm -qa|grep -e "kernel-[0-9]"'
output = utils_alibaba.run_cmd(self, cmd, msg='Get kernel version')
kernels_list = output.split('\n')
for kernel in kernels_list:
kernel_vmlinuz = "/boot/" + kernel.replace('kernel','vmlinuz')
kernel_initramfs = "/boot/" + kernel.replace('kernel','initramfs') + ".img"
cmd = "sudo kexec -l %s --initrd=%s --reuse-cmdline" % (kernel_vmlinuz, kernel_initramfs)
utils_alibaba.run_cmd(self, cmd, msg='Switch kernel', expect_ret=0)
cmd = "sudo kexec -e"
self.log.info("CMD: %s", cmd)
self.session.session.sendline("%s" % cmd)
time.sleep(10)
self.session.connect()
utils_alibaba.run_cmd(self, 'uname -r', msg='check kernel', expect_ret=0, expect_kw=kernel[7:])

def test_check_image_id(self):
"""Check the image label in Alibaba private image.
Expand Down

0 comments on commit aa9beab

Please sign in to comment.