-
Notifications
You must be signed in to change notification settings - Fork 170
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
base: master
Are you sure you want to change the base?
Automate Check the disk-change events for cdrom and disk when #5932
Conversation
DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file) DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file) DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file) |
f0efc32
to
aa017a2
Compare
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]>
aa017a2
to
b1729c4
Compare
@@ -129,6 +129,29 @@ | |||
target_dev = "sdd" | |||
backend_device = "empty_source_cdrom_backend" | |||
only hotplug..positive_test | |||
- dropped_changed_events_startuppolicy_backend: |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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