reportportal / agent-python-pytest

Framework integration with PyTest
Apache License 2.0
95 stars 102 forks source link

Attaching large session logs to Pytest run results in pytest hanging #276

Closed allan-silverstein closed 2 years ago

allan-silverstein commented 3 years ago

name: Bug report about: Create a report to help us improve title: '' labels: bug assignees: ''


Describe the bug Pytest run hangs when trying to attach/upload large file to report portal.

Steps to Reproduce Steps to reproduce the behavior: Run a pytest test which creates a large log file. Then try uploading that to report portal with the following code. This works fine 99.9% of the time. Only hangs with large files. In my case the file is approximately 135 Mbytes

def attach_session_logs(testinfo,rp_logger):
    for dev in testinfo['log_files']: # loop through session log file names
        dirpath = os.getcwd()

        # get log file in current working directory
        log_dir = Path(dirpath,testinfo['log_files'][dev]) 

        # open log file and send contents as an attachment to reportportal
        with open(log_dir) as file: 
            contents = file.read()
            rp_logger.info("Session Log Attachment - " + testinfo['log_files'][dev],
                                     attachment={"name": testinfo['log_files'][dev],
                                    "data": contents, "mime": "text/plain"})

Expected behavior Pytest test should complete

Actual behavior Pytest run hangs at the bash shell command line indefinitely

Package versions Include version info of the following packages: reportportal-client, pytest-reportportal

pytest-reportportal==5.0.3 reportportal-client==5.0.3

Additional context Add any other context about the problem here.

HardNorth commented 2 years ago

@allan-silverstein Please use the latest pytest agent: 5.0.10, as for now.