reportportal / agent-python-pytest

Framework integration with PyTest
Apache License 2.0
94 stars 103 forks source link

Connection error with timeout during adding attachment files with size KB-MB (txt, pcap, mp4) #350

Closed pavloshchepan closed 10 months ago

pavloshchepan commented 10 months ago

Describe the bug Connection error with timeout during adding attachment files with size KB-MB (txt, pcap, mp4)

Steps to Reproduce Steps to reproduce the behavior:

  1. Collect diff attachment logs in some dir (ex artifacts)
  2. use rp logger for uploading files and func for example and use it on teardown:
def attach_files_to_rp(path_2_dir, rp, scope=''):
    for f in path_2_dir.glob('*'):
        if '.' in f.name:
            with open(f, "rb") as image_file:
                file_data = image_file.read()
            mime = "text/plain" if '.log' in f.name else magic.from_file(f, mime=True)
            log.debug(f'Mime of file {f.name} - {mime}')
            if '.pcap' in f.name:
                log.warning(f'skipped {f.name}')
                continue
            rp.debug(f'{scope}{f}', attachment={
                "name": f.name,
                "data": file_data,
                "mime": mime
            })
            sleep(5)

Expected behavior No timeout error

Actual behavior Timeout error (default value is 10sec, 10sec) according to this code:

// from venv/lib/python3.9/site-packages/reportportal_client/core/rp_requests.py
def make(self):
        """Make HTTP request to the Report Portal API."""
        try:
            return RPResponse(self.session_method(
                self.url, data=self.data, json=self.json,
                files=self.files, verify=self.verify_ssl,
                timeout=self.http_timeout)

Package versions pytest-reportportal==5.2.1 reportportal-client==5.4.0

Additional context Maybe there is some configurable timeout for rp requests?

HardNorth commented 10 months ago

@pavloshchepan Hmm, it seems we missed some configuration options. OK, I'll add them in the next release.

pavloshchepan commented 10 months ago

@HardNorth could you please tell me when the next release is planned? About config options do you mean option for specifying read/write timeout option?

HardNorth commented 10 months ago

@pavloshchepan Next week, yes, timeout options.

HardNorth commented 10 months ago

Fixed in: https://github.com/reportportal/agent-python-pytest/releases/tag/5.3.0

pavloshchepan commented 10 months ago

thanks) I'll check)

pavloshchepan commented 10 months ago

@HardNorth now I see the next behavior:

I pass a new config params in pytest.ini file: rp_connect_timeout = 60 rp_read_timeout = 60

And run tests with rp option. I see that on init session my increased timeouts works - 60 sec. But in the request it is still (10, 10):

                print(f'RP response - {self.http_timeout}')
            return RPResponse(self.session_method(self.url, data=self.data, json=self.json, files=self.files,
                                                  verify=self.verify_ssl, timeout=self.http_timeout))
>>>
RP response - (10, 10)

Could you please check? Maybe I just missed smth?

HardNorth commented 10 months ago

@pavloshchepan Missed that in our client library, should be fixed in the latest version. If you uninstall and install the agent again it should get the latest version of this library.