manykarim / rf-lambda-executor

Run Robot Framework Tests via AWS Lambda
Apache License 2.0
5 stars 0 forks source link

AWS linux in Docker is not working with Browser library #1

Open Krata4 opened 1 year ago

Krata4 commented 1 year ago

Hi, I met in on Robocon and firstly I would like thank you for your presentation. I tried to implement somethink litl bit similar as you, but I have issue with run of Test insite conteiner. I am getting error: " Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket"

I attached playwright log: playwright-log (2).txt

I am using your dockerfile config: ########################################### FROM public.ecr.aws/lambda/python

Install the function's dependencies using file requirements.txt

from your project folder.

RUN curl -sL https://rpm.nodesource.com/setup_16.x | bash - RUN yum install -y nodejs dbus-glib alsa-lib mesa-libgbm xrandr gtkspell3 cups-libs at-spi2-atk git && yum clean all COPY requirements.txt "${LAMBDA_TASK_ROOT}" RUN python3.9 -m pip install -r requirements.txt -t "${LAMBDA_TASK_ROOT}" && python3.9 -m Browser.entry init

Copy function code

COPY app.py "${LAMBDA_TASK_ROOT}"

Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)

CMD [ "app.lambda_handler" ]

################################################

Did you see this issue? Can you help me please?

manykarim commented 1 year ago

Hi, I definitely faced some challenges while executing Browser Tests on AWS Lambda.

I could solve some by adding the Browser Arguments ["--single-process", "--no-sandbox", "--disable-gpu"]

And I also faced some problems when using the "New Context" Keyword. So I use a "New Browser" Keyword as a Test Setup.

Find one example Test Suite attached. It has the adjustments mentioned above. I was able to run it on AWS Lambda with the Dockerimage.

So, you also want to run your tests on Lambda right? Or just inside a Container in general?

Maybe it's also worth investigating creating a Lambda Container Image based on a custom image as described here https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-alt

todo.txt

Krata4 commented 1 year ago

Hi, thanks for reposnse. I tried your solution already but it is still workaround :-). I am tring to run tests insite docker only. Do you think that is it possible to run tests directly in lambda? Did you try it? Propably I will start work on custom docker image. Or shanll I log issue on AWS, because I found error during creating docker image which is rotcouse of problem?

Thanks

manykarim commented 1 year ago

Ah, ok. If it's only about running tests with Browser library in a container you can just use a image with robot framework and browser library. For example https://docs.robotframework.org/docs/using_rf_in_ci_systems/docker#marketsquarerobotframework-browser

Or you can create your own one with a dockerfile like that ​https://docs.robotframework.org/docs/using_rf_in_ci_systems/docker#dockerimage-with-robot-framework-and-browser-library

Krata4 commented 1 year ago

no no :-) Sorry, I am using Lambda as serverless. So this is not possible use native robotframework image.

So possible way is create custome image based on ASW doc, am I right?

manykarim commented 1 year ago

Ok, I was able to run the Browser Library tests on Lambda with my Dockerimage and the workarounds I mentioned above

https://github.com/manykarim/rf-lambda-executor/blob/main/executor/Dockerfile

["--single-process", "--no-sandbox", "--disable-gpu"]

Some limitations are not due the Dockerimage, but due to AWS Lambda itself. If you want to use serverless infrastructure with less restrictions and limitations, maybe it's worth looking into AWS Fargate, a serverless kubernetes cluster.

Krata4 commented 1 year ago

Ok, I thought that problem is in dbus dependencies which is not correctly deployed on Docker image (there is error during building AWS image). So, you are thinking that other image (some custome image) will not help?

Thanks

Krata4 commented 1 year ago

I mean this error: Failed to get D-Bus connection: Operation not permitted

manykarim commented 1 year ago

Is there any other error in the robot framework log, e g. About missing dependencies? Are you running your browser in headless mode?

Krata4 commented 1 year ago

Yes, I am running in headless mode. Error I can see in playwright log only (about dbus)

[pid=508][err] [0210/195020.204942:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory