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

Use python logging infrastructure inside tests #562

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

mwperina
Copy link
Member

Use python logging infrastructure inside tests instead of print() to
have timestamps to be able to correlate tests logs with system logs.

Signed-off-by: Martin Perina mperina@redhat.com

@mwperina mwperina force-pushed the use-logging-in-tests branch 2 times, most recently from d100661 to a097d36 Compare September 13, 2023 09:03
Use python logging infrastructure inside tests instead of print() to
have timestamps to be able to correlate tests logs with system logs.

Signed-off-by: Martin Perina <mperina@redhat.com>
@mwperina
Copy link
Member Author

mwperina commented Sep 13, 2023

Before this change following output we had in the tmt log for starting a service:

13:10:49                 out: Starting unit simple.service on node node-foo                                                                                            

After the change log contains:

10:23:11                 out: 2023-09-13 10:23:11+0000,279 DEBUG   [bluechi_test.container] Starting unit 'simple.service' on node 'node-foo' (container:174)          
10:23:11                 out: 2023-09-13 10:23:11+0000,283 DEBUG   [urllib3.connectionpool] http://%2frun%2fuser%2f1001%2fpodman%2fpodman.sock:80 "POST /v4.6.0/libpod/containers/bluechi-controller/exec HTTP/1.1" 201 74 (connectionpool:473)                                                                                               
10:23:11                 out: 2023-09-13 10:23:11+0000,290 DEBUG   [urllib3.connectionpool] http://%2frun%2fuser%2f1001%2fpodman%2fpodman.sock:80 "POST /v4.6.0/libpod/exec/24f4a2eaf18472424579e267530019be7c24281224bfe202bf0ec3b9042f8b22/start HTTP/1.1" 200 None (connectionpool:473)                                                    
10:23:11                 out: 2023-09-13 10:23:11+0000,348 DEBUG   [urllib3.connectionpool] Resetting dropped connection: %2frun%2fuser%2f1001%2fpodman%2fpodman.sock (connectionpool:290)                                                                                                                                                    
10:23:11                 out: 2023-09-13 10:23:11+0000,350 DEBUG   [urllib3.connectionpool] http://%2frun%2fuser%2f1001%2fpodman%2fpodman.sock:80 "GET /v4.6.0/libpod/exec/24f4a2eaf18472424579e267530019be7c24281224bfe202bf0ec3b9042f8b22/json HTTP/1.1" 200 417 (connectionpool:473)                                                       10:23:11                 out: 2023-09-13 10:23:11+0000,350 DEBUG   [bluechi_test.container] Start unit 'simple.service' on node 'node-foo' finished with result '0'             and output:                                                                                                                                                   
10:23:11                 out: Unit simple.service start operation result: done (container:177)                                                                         

The appearance of libpod logs is a side effect caused by setting the log level to DEBUG

@mwperina mwperina marked this pull request as ready for review September 13, 2023 10:41
Copy link
Member

@engelmi engelmi left a comment

Choose a reason for hiding this comment

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

LGTM

@mwperina mwperina merged commit 78502d3 into eclipse-bluechi:main Sep 13, 2023
10 checks passed
@mwperina mwperina deleted the use-logging-in-tests branch September 13, 2023 12:03
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