-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract text from screenshot at test failure and errors from VM logs
Signed-off-by: Qi Zhang <[email protected]> Signed-off-by: Qi Zhang <[email protected]>
- Loading branch information
1 parent
22bbf78
commit b6e0bc3
Showing
27 changed files
with
625 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Collect VM serial port log file | ||
# Parameters: | ||
# vm_dir_name: VM directory name, which is defined in vm_get_vm_info.yml | ||
# vm_serial_file_name: VM serial port file name, which is defined in vm_add_serial_port.yml | ||
# vm_serial_file_local_name: the local file name of downloaded serial port log file | ||
# Return: | ||
# vm_serial_file_local_path: the local path to downloaded serial port log file | ||
# | ||
- name: "Initialize facts of downloaded serial port log file name and path" | ||
ansible.builtin.set_fact: | ||
vm_serial_file_local_path: "" | ||
|
||
- name: "Collect VM serial port log" | ||
when: | ||
- vm_dir_name is defined | ||
- vm_dir_name | ||
- vm_serial_file_name is defined | ||
- vm_serial_file_name | ||
block: | ||
- name: "Download VM serial port log file from datastore" | ||
include_tasks: ../../common/esxi_download_datastore_file.yml | ||
vars: | ||
src_datastore: "{{ datastore }}" | ||
src_file_path: "{{ vm_dir_name }}/{{ vm_serial_file_name }}" | ||
dest_file_path: "{{ current_test_log_folder }}/{{ vm_serial_file_name }}" | ||
download_file_fail_ignore: true | ||
|
||
- name: "Get the local path to downloaded serial port log" | ||
when: | ||
- file_in_datastore_result is defined | ||
- file_in_datastore_result == 'Success' | ||
- datastore_file_download_result.changed is defined | ||
- datastore_file_download_result.changed | ||
block: | ||
- name: "Check downloaded VM serial log at local" | ||
ansible.builtin.stat: | ||
path: "{{ current_test_log_folder }}/{{ vm_serial_file_name }}" | ||
register: local_file_stat_result | ||
ignore_errors: True | ||
|
||
- name: "Set fact of downloaded serial log path at local" | ||
ansible.builtin.set_fact: | ||
vm_serial_file_local_path: "{{ current_test_log_folder }}/{{ vm_serial_file_name }}" | ||
when: | ||
- local_file_stat_result.stat.exists is defined | ||
- local_file_stat_result.stat.exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Extract call trace or other error messages in a log file downloaded from guest | ||
# Parameters: | ||
# local_log_path: The local log file path to extract call trace and errors | ||
# Return: | ||
# errors_in_log: The call trace or error messages extracted from the log file | ||
# | ||
- name: "Check the local log path is an absolute path" | ||
ansible.builtin.assert: | ||
that: | ||
- local_log_path is defined | ||
- local_log_path | ||
- local_log_path is ansible.builtin.abs | ||
fail_msg: "Parameter 'local_log_path' must be set with a local absolute path" | ||
|
||
- name: "Initialize the facts of extracted errors from log" | ||
ansible.builtin.set_fact: | ||
errors_in_log: [] | ||
|
||
- name: "Extract error messages from log file" | ||
ansible.builtin.script: "../tools/extractor.py -t error -f {{ local_log_path }}" | ||
ignore_errors: True | ||
register: extract_error_result | ||
|
||
- name: "Set fact of extracted errors from log file" | ||
ansible.builtin.set_fact: | ||
errors_in_log: "{{ extract_error_result.stdout_lines | select }}" | ||
when: | ||
- extract_error_result.stdout_lines is defined | ||
- extract_error_result.stdout_lines | length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Extract text from a local screenshot file | ||
# Parameters: | ||
# local_screenshot_path: The local screenshot file path | ||
# Return: | ||
# text_in_screenshot: The text extracted from the screenshot file | ||
# | ||
- name: "Check local screenshot file path is an absolute path" | ||
ansible.builtin.assert: | ||
that: | ||
- local_screenshot_path is defined | ||
- local_screenshot_path | ||
- local_screenshot_path is ansible.builtin.abs | ||
fail_msg: "Parameter 'local_screenshot_path' must be set with a local absolute path" | ||
|
||
- name: "Initialize the fact of extracted screenshot text" | ||
ansible.builtin.set_fact: | ||
text_in_screenshot: [] | ||
|
||
- name: "Extract text from local screenshot file" | ||
ansible.builtin.script: "../tools/extractor.py -t text -f {{ local_screenshot_path }}" | ||
ignore_errors: True | ||
register: extract_text_result | ||
|
||
- name: "Set fact of extracted screenshot text" | ||
ansible.builtin.set_fact: | ||
text_in_screenshot: "{{ extract_text_result.stdout_lines | select }}" | ||
when: | ||
- extract_text_result.stdout_lines is defined | ||
- extract_text_result.stdout_lines | length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.