Skip to content

Conversation

@jyurdal
Copy link

@jyurdal jyurdal commented May 11, 2021

passing large response.text to function and calculating len() of it
takes a lot of time (and CPU) when a application/zip is returned.
This results in test timeouts and hence failures

passing large response.text to function and calculating len() of it
takes a lot of time (and CPU) when a application/zip is returned.
This results in test timeouts and hence failures
@lucagiove
Copy link
Member

Interesting the approach of looking at headers for the length.
By the way I don't think your implementation is clean enough to be merged and if the size is higher than limit no message of body truncated will be shown.

@jyurdal
Copy link
Author

jyurdal commented May 11, 2021

I think the fact that the logging of data (that is not necessarily desired) uses one 100% of one CPU core for a time way longer then the test itself is an issue.
My first idea was to add boolean parameter log_body to get_on_session and post_on_session ( with default set to True). User could disable logging of the body for video, audio, application/zip and/or other binary files. Would that be acceptable solution for you @lucagiove ?

@lucagiove
Copy link
Member

No it's not acceptable as well but I'll think about it, maybe logging could be disabled by a global library property definitely not for each keyword.
I'll think about it but maybe looking at the size is feasible only in a different way.

@jyurdal
Copy link
Author

jyurdal commented May 11, 2021

That would be great if that was resolved. I have experienced that any processing on response.text takes a long time, including passing it to a function (In our case it response.text was 7M of size). Maybe that can be somehow optimized?

I still think that per function parameter with a default would work well. In our case vast majority of the POST/GET are application/json and disabling the logging would be required on just few API non json calls. I image when developers write test cases they would have the knowledge on which API calls should be fully logged.

One more option would be logging text body only (predefined values of the 'Content-Type') unless logging level is greater then 10.
Thanks for your time @lucagiove :-)

Copy link
Member

@lucagiove lucagiove left a comment

Choose a reason for hiding this comment

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

I'm thinking about having another barrier to completely disable logging if size is greater than a specified value.
Maybe the value could be configured while loading the library but I expect a good default to do the job already.

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.

High cpu and memory consumption due to logging

2 participants