-
Notifications
You must be signed in to change notification settings - Fork 562
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
tests: update snapd testing tools with spread log filter #13974
base: master
Are you sure you want to change the base?
tests: update snapd testing tools with spread log filter #13974
Conversation
…b77e1..d60381fcd9 d60381fcd9 add run number to filtered filename 5dde2d67b8 consider the tests execution in main 6b9a3aabcc change filtered log name b2756aa579 default file is .filtered.log 500b9dace4 Fix tests workflow 45db26a3d2 fix shellcheck error in log-filter fe45c27b7d create a var to store filter params 5a9b66d7dc filter spread results 51f9b055af New tool used to filter the spread.log output b8d20c1d5b fix snaps.name test with correct siffix spelling f640ac72e3 Add missing test details f0754df304 Filter the error y debug output in log-parser fc10196efd Add suggestions to details 94ac5ffe58 Add details on tests 501578c719 add more checks in os.query to check is-core_xx e8929207ff fix os-query for ubuntu comparing with core 226114641f os.query won't check SPREAD_SYSTEM anymore to compare core systems b89ec98b23 use local variables in os.query tool dacfd81de9 fix is_core functions 1db5214d5f Improve the remote docs (snapcore#36) 2e4a3153a2 1 more comment 3a0fc57e1e add explanation about why we check for ( Do | Doing ) 4cf8e635bf fix os.query test after merge b89b4f8647 fix artifacts name d30cee6da0 Merge remote-tracking branch 'upstream/main' 5ef5dcbe8f Tests use artifacts in spread tests (snapcore#51) 555c43d2ab Support auto-refresh with Do instead of Doing 96c2b0c19c remove tests support for ubuntu 23.04 (EoL) 74082c0c34 Tests improve remote wait (snapcore#49) 5121bfb659 remove support for opensuse leap 15.4 (snapcore#48) 30df700d08 Add new systems support (snapcore#47) 1f08938925 Support check amazon linux version (snapcore#46) 43533bdd97 Change the exit value checking for test formats (snapcore#45) 3c88244c04 Update check-test-format to support a dir and a list of files (snapcore#44) 510d95f429 add extra check for error in auto-refresh detection function 3289d4031b Try open the log with latin-1 encoding when utf-8 is not working 9db785499f improved how the tools are waiting for system reboot 2a5c4414a3 fix shellcheck errors 5e7b63883d Fixes for osquery and tests pkgs (snapcore#43) 4c9145e2ac support reboot waiting for auto-refresh 45768f5188 show changes in unknown status after refresh 8013c30c2a Remove support for ubuntu 22.10 b32b80bf54 Fix remote.rait-for test in bionic 5675c625e9 Enable fedora 38 55f4471957 Support for new oss f2e88b357c New tool used to query spread json reports cacd35ede0 utils/spread-shellcheck: explain disabled warnings (snapcore#42) c82afb2dee Support --no-install-recommends parameter when installing dependencies with tests.pkgs b84eea92e2 spread-shellcheck: fix quotes in environment variables (snapcore#41) ab1e51c29f New comparison in os-query for core systems (snapcore#40) e5ae22a5d4 systemd units can be overwritten 63540b845a Fix error messages in remote pull and push 75e8a426a5 make sure the unit is removed in tests.systemd test 9089ff5c02 Update tests to use the new tests.systemd stop-unit 44ecd5e56a Move tests.systemd stop-units to stop-unit 01a2a83b4b Update tests.systemd to have stop units as systemd.sh 162e93bd35 update tests.systemd CLI options to be the same than retry command 14aa43a405 new feature to re-run failed spread tests (snapcore#39) 604cb782db Fix shellcheck in systemd tool bfc71082c8 Update the tests.systemd to allow parameters waiting for service status 8a2d0a99df Adding quiet tool and removing set +-x from tests.pkgs d90935d2a4 A comment explaining about the default values for wait-for 3232c5dba7 Add support for ubuntu 23.04 a7164fba07 remove fedora 35 support, add fedora 37 support 89b9eb5301 Update systems supported 92bb6a0664 Include snap-sufix in the snaps.name tool git-subtree-dir: tests/lib/external/snapd-testing-tools git-subtree-split: d60381fcd91fc71a393674cb7ec70acb3485ea08
…date-snapd-testing-tools tests/lib/external/snapd-testing-tools/.github/workflows/tests.yaml tests/lib/external/snapd-testing-tools/tests/remote.retry/task.yaml
|
||
(set -o pipefail; spread $RUN_TESTS | tee spread.log) | ||
(set -o pipefail; spread $RUN_TESTS | ./utils/log-filter $FILTER_PARAMS | tee spread.log) |
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.
does spread use stderr for regular logs or just stdout? iow. do we need |&
?
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 output goes to stdout iirc
parser = _make_parser() | ||
args = parser.parse_args() | ||
process_spread_output(args.output_file, args.exclude, args.filter) | ||
|
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.
newline
@@ -0,0 +1,224 @@ | |||
#!/usr/bin/env python3 |
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.
please use black to format the script
@@ -2,7 +2,7 @@ summary: smoke test for the remote.retry tool | |||
|
|||
details: | | |||
This test checks the remote.retry tool properly handles retrying | |||
a command in the remote instance. Also verifies that on failure | |||
a command in the remote instance. Also Verifies that on failure |
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.
why upcase?
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'll revert that
for line in sys.stdin: | ||
print_line(line) | ||
|
||
while is_detail_start(line): |
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 think I'd restructure this a bit. You could have something like:
regexes = {
ERROR: compile_rules(filter_rules, ERROR),
DEBUG: compile_rules(filter_rules, DEBUG),
FAILED: compile_rules(filter_rules, FAILED),
WARNING: compile-rules(filter_rules, WARNING),
}
with open(output_file, "w") as myfile:
for line in sys.stdin:
print_line(line)
kind = is_detail_start(line)
# kind is one of [DEBUG, ERROR, FAILED, WARNING]
if kind in exclude_lines:
line = skip_details(sys.stdin)
continue
line = process_detail(sys.stdin, line, regexes[kind], myfile)
...
|
||
if is_line(line, WARNING): | ||
if WARNING in exclude_lines: | ||
line = skip_detail(sys.stdin) |
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.
hm wasn't the exclusion supposed to filter out the lines from stdout and write them to a file? isn't this operating in reverese?
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.
well, those tools are for different things, this tool is needed to filter the output to send to the observability stack, the other tool is used to filter the output displayed in github page.
So, it will work like this -> spread ... | filter_1 | filter_2
The filter 1 will save to a new file the filtered output and will send to stdout the stdin
The filter 2 will save to files the debug output and will send to stdout the contect without the debug 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.
I did a quick pass with some suggestions.
Please reformat with black as Maciej suggested and lint the code with mypy --strictl. With what we depend on it should not need any loopholes to validate.
@@ -2,7 +2,7 @@ summary: smoke test for the remote.retry tool | |||
|
|||
details: | | |||
This test checks the remote.retry tool properly handles retrying | |||
a command in the remote instance. Also verifies that on failure | |||
a command in the remote instance. Also Verifies that on failure |
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 think this should not be capitalized
return regex_list | ||
|
||
|
||
def process_detail_line(line: str, regex_list: list, to_stream: io.TextIOWrapper): |
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.
How about something like this?
def process_detail_line(line: str, regex_list: list[re.Pattern[str], to_stream: typing.TextIO) -> None:
for regex in regex_list:
for match in regex.findall(line):
write_line(match, to_stream)
break
else:
write_line(line, to_stream)
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've added type hints and fixed a few bugs. I'll push a patch after the planning call.
The code now passes mypy --strict, some functions have weird logic needed to satisfy the type checker that indicate something is still off. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
This change includes a new tool used in snapd-testing-tools used to filter spread logs to be sent to COS.
This new tool reads the input from spread output and filters the data following defined rules. Currently it is filtering data to avoid sending the complete logs to COS.
The new tool sends to the stdout the full imput .