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

system test: better error reporting with special chars #17509

Closed
Luap99 opened this issue Feb 15, 2023 · 3 comments · Fixed by #17538
Closed

system test: better error reporting with special chars #17509

Luap99 opened this issue Feb 15, 2023 · 3 comments · Fixed by #17538
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@Luap99
Copy link
Member

Luap99 commented Feb 15, 2023

I made a small mistake in #17502 which added extra newlines in podman logs.
This correctly caused test failures however the assertion expected vs actual did not show anything wrong, it hides the newline so it was harder to spot the mistake.

Here the examples output:

[+0214s] not ok 110 podman logs - --until --follow journald
         # (from function `assert' in file test/system/[helpers.bash, line 643](https://github.com/containers/podman/blob/9ec0f263a0a89a7ae4b05ae92b4725199fb4e6c4/test/system/helpers.bash#L643),
         #  from function `_log_test_follow_until' in file test/system/[035-logs.bats, line 370](https://github.com/containers/podman/blob/9ec0f263a0a89a7ae4b05ae92b4725199fb4e6c4/test/system/035-logs.bats#L370),
         #  in test file test/system/[035-logs.bats, line 384](https://github.com/containers/podman/blob/9ec0f263a0a89a7ae4b05ae92b4725199fb4e6c4/test/system/035-logs.bats#L384))
         #   `_log_test_follow_until journald' failed
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ rm -t 0 --all --force --ignore
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ ps --all --external --format {{.ID}} {{.Names}}
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ images --all --format {{.Repository}}:{{.Tag}} {{.ID}}
         # quay.io/libpod/testimage:20221018 f5a99120db64
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ run --log-driver=journald --name yUFBphl6ug -d quay.io/libpod/testimage:20221018 sh -c while :; do echo 7bPIZdpyfG && sleep 2; done
         # 992fd024d1e622d8af7e8a670e79e7d7cdc19dec844a0e53f1ec99dfb5677530
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ logs --until 3s -f yUFBphl6ug
         # 7bPIZdpyfG
         #
         # 7bPIZdpyfG
         # #/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
         # #|     FAIL: logs --until -f on running container works
         # #| expected: '7bPIZdpyfG
         # 7bPIZdpyfG'
         # #|   actual: '7bPIZdpyfG'
         # #|         > '7bPIZdpyfG'
         # #\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         # # [teardown]
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ pod rm -t 0 --all --force --ignore
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ rm -t 0 --all --force --ignore
         # 992fd024d1e622d8af7e8a670e79e7d7cdc19dec844a0e53f1ec99dfb5677530
         # # podman-remote --url unix:/tmp/podman_tmp_RuWQ network prune -

If you look at the logs output before the assertion we see that there is an extra newline between both log lines. However the actual part in the assertion hides that.

Full log: https://api.cirrus-ci.com/v1/artifact/task/5780561285873664/html/int-podman-fedora-36-rootless-host.log.html#t--podman-pod-logs-with-different-colors--1

Also the same can be seen in the APIv2 test which also does not show the final newline:

         not ok 273 [20-containers] POST containers/foo/attach?logs=true&stream=false [-d {}] : output
         #  expected: hi-there-ztH0wDFTj5755EE
         #    actual: hi-there-ztH0wDFTj5755EE

from https://api.cirrus-ci.com/v1/artifact/task/6457860448583680/html/apiv2-podman-fedora-37-root-host.log.html

IMO the assertion should highlight all special chars to make debugging easier.
@edsantiago PTAL

@edsantiago
Copy link
Member

This is a longstanding problem, and one that is very hard to fix. I'm sorry that it cost you time. I will look into it again and see if I have fresh ideas on how to resolve it.

@Luap99
Copy link
Member Author

Luap99 commented Feb 15, 2023

It didn't really cost me time but I was surprised, the newline was visible in the real output but I am more worried about chars that will not be visible at all, i.e. \r
I was thinking in the direction of using printf %q

$ a=$'abc\r1234'
$ printf %s $a
1234
$ printf %q $a
$'abc\r1234'

@edsantiago
Copy link
Member

That works for short strings. On wall-of-text strings, it might not. But please keep the suggestions coming, I may be able to figure something out with %q, or cat -vET, or other ideas.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants