robotframework / robotframework

Generic automation framework for acceptance testing and RPA
http://robotframework.org
Apache License 2.0
9.89k stars 2.34k forks source link

Using python multiprocessing lib and logger from robot.api corrupts output.xml' file. #5193

Open kasadik opened 2 months ago

kasadik commented 2 months ago

Robot versions: 7.0.1 Python 3.11 Amazon Linux image used

I have tests where I'm using python multiprocessing library. When I'm running them on AWS linux machine I'm getting an error "output.xml' failed: Incompatible child element 'arg' for 'test'". But when I'm running them locally in my MacOS environment everything is ok. This issue occurs upon using logger from robot framework api lib. When two different process are trying to log some data, output.xml file gets corrupted. When logger is removed from functions that are used multiprocessing library everything is working: Example:

from multiprocessing import Process
from robot.api import logger  # to import robot logger lib

def some_func(arg1):
      logger.info('Some arg {arg1})

processes = []

for i in range(2):
    p = Process(target=some_func, args=(i))
    processes.append(p)

for p in processes:
    p.start()

for p in processes:
    p.join()

Amazon Linux image was used Received error after test execution: 'output.xml' failed: Incompatible child element 'arg' for 'test'.

Screenshot 2024-08-30 at 13 52 43
oboehmer commented 2 months ago

@kasadik , did you check the note in https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#communication-when-using-threads ? I fear this is expected..

kasadik commented 2 months ago

@kasadik , did you check the note in https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#communication-when-using-threads ? I fear this is expected..

But why it doesn't happen on MacOS? I'm using the same framework and on MacOS everything is ok, no corruption and report.html is also generated. But somehow on Amazon Linux instance it gets corrupted. Also thx for providing me this link I will take a look.