Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate Check the disk-change events for cdrom and disk when #5932

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chunfuwen
Copy link
Contributor

@chunfuwen chunfuwen commented Oct 6, 2024

startuppolicy is set to optional

xx-38693 - [disk-change]Check the disk-change events when startuppolicy is optional
xx-112414 - start a guest with block type cdrom --bz1471225
xx-32763 - [audit log] Audit log related to guest CDROM

@chunfuwen
Copy link
Contributor Author

chunfuwen commented Oct 6, 2024

DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stdout.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stderr.expected) => NOT FOUND (data sources: variant, test, file)
PASS 1-type_specific.io-github-autotest-libvirt.virtual_disks.cdrom_device.coldplug.dropped_changed_events_startuppolicy_backend.positive_test

DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stdout.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stderr.expected) => NOT FOUND (data sources: variant, test, file)
PASS 1-type_specific.io-github-autotest-libvirt.virtual_disks.cdrom_device.coldplug.block_cdrom_tainted.positive_test

DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stdout.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stderr.expected) => NOT FOUND (data sources: variant, test, file)
PASS 1-type_specific.io-github-autotest-libvirt.virtual_disks.cdrom_device.coldplug.disconnect_audit_cdrom_backend.positive_test

@chunfuwen chunfuwen force-pushed the automate_dropped_changed_event_case branch 2 times, most recently from f0efc32 to aa017a2 Compare October 8, 2024 05:58
startuppolicy is set to optional, and no cdrom:pass-through log when
using block type cdrom

xx-38693 - [disk-change]Check the disk-change events when
startuppolicy is optional

xx-112414 - start a guest with block type cdrom --bz1471225

xx-32763 - [audit log] Audit log related to guest CDROM

Signed-off-by: chunfuwen <[email protected]>
@chunfuwen chunfuwen force-pushed the automate_dropped_changed_event_case branch from aa017a2 to b1729c4 Compare October 8, 2024 06:09
@@ -129,6 +129,29 @@
target_dev = "sdd"
backend_device = "empty_source_cdrom_backend"
only hotplug..positive_test
- dropped_changed_events_startuppolicy_backend:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think this pattern is a little unclear. Maybe events_check_with_optional_startuppolicy is better?

test.fail("Can not find matched event:%s from event output: %s" % (change_event_matched, ret_output))
dropped_event_matched = r"event 'disk-change' for domain '%s' disk .*dropped" % vm.name
if not re.search(dropped_event_matched, ret_output):
test.fail("Can not find matched event:%s from event output: %s" % (dropped_event_matched, ret_output))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above codes are little repetitive, I suggest we can merge them together. For example, use for statement to check events:

events_to_check = ["changed", "dropped"]
for event in events_to_check:
    event_matched = r"event 'disk-change' for domain '%s' disk .*%s" % (vm.name, event)
    if not re.search(event_matched, ret_output):
        test.fail("Can not find matched event:%s from event output: %s" % (event_matched, ret_output))

@@ -638,6 +767,12 @@ def run(test, params, env):
check_scsi_cdrom_hot_eject(vm, params, test)
elif backend_device == "empty_source_cdrom_backend":
check_empty_source_cdrom(vm, params, test)
elif backend_device == "dropped_changed_events_startuppolicy_backend":
check_dropped_changed_events_startuppolicy_backend(vm, params, virsh_session, test)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also important to check the dumpxml after starting guest. But I didn't find this step. Did I miss this part of the code or is it not added in the script?

startupPolicy="optional"
backend_device = "dropped_changed_events_startuppolicy_backend"
only coldplug..positive_test
- block_cdrom_tainted:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a positive case which we don't want to find the tainted log. But this pattern seems a negative case. I suggest we can directly to use block_cdrom_bankend to help us better understand the case when we debug.

def create_block_cdrom_disk(params):
"""
Create one block cdrom device
:param params: dict wrapped with parameter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have a blank line above.

return block_cdrom_disk


def check_block_cdrom_tainted(vm, params, test):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_block_cdrom_log maybe more better to understand.

def check_disconnect_audit_cdrom(params, test):
"""
check audit log when cdrom is disconnected
:param params: dict wrapped with parameter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have a blank line above.

def create_disconnect_audit_cdrom(params):
"""
Create one file cdrom device
:param params: dict wrapped with parameter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have a blank line above.

:param test: test assert object
"""
qemu_log = "/var/log/libvirt/qemu/%s.log" % vm.name
process.run("truncate -s 0 {}".format(qemu_log), shell=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step makes the checkpoint meaningless because the log has been cleared.

service_name = 'auditd'
service_mgr = service.ServiceManager()
status = service_mgr.status(service_name)
LOG.debug('Service status is %s', status)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this function Factory.create_service("auditd"). You can check if we can use this common function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants