I want to create selenium hub and a pytest containers by calling a .yml file. The pytest container would call the selenium hub container to run some tests. For this I have: (a) pytest project (b) Dockerfile to create an image of the project and install python (c) Bash script that executes pytest command (d) e2e.yml file to create the pytest and selenium hub containers
How it should work: (1st step) I launch e2e.yml file (d) with the command:
docker-compose -f e2e.yml up
As a result: three containers get created: two chrome nodes and the selelium hub. After that the container with the pytest project gets created via the Dockerfile (a and b)
FROM python:3.8
COPY requirements.txt .
RUN pip3 install --no-cache-dir --user -r requirements.txt
COPY . .
(2nd step) e2e.yml file than calls the bash script (c)
#!/usr/bin/env bash
set -e
export SELENIUM_URL="http://172.24.0.2:4444"
python -m pytest
The bash script essentially calls a pytest command that starts tests, which is the desired result.
What I get: The fist step passes as desired, but when I try to execute the pytest command, python outputs an error "No such file or directory: '/dev/fd/13"
Error message:
==================================== ERRORS ====================================
e2e_1 | ________________________ ERROR collecting test session _________________________
e2e_1 | root/.local/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
e2e_1 | result: Optional[TResult] = func()
e2e_1 | root/.local/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
e2e_1 | call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
e2e_1 | root/.local/lib/python3.8/site-packages/_pytest/main.py:711: in collect
e2e_1 | for direntry in visit(str(argpath), self._recurse):
e2e_1 | root/.local/lib/python3.8/site-packages/_pytest/pathlib.py:667: in visit
e2e_1 | yield from visit(entry.path, recurse)
e2e_1 | root/.local/lib/python3.8/site-packages/_pytest/pathlib.py:667: in visit
e2e_1 | yield from visit(entry.path, recurse)
e2e_1 | root/.local/lib/python3.8/site-packages/_pytest/pathlib.py:667: in visit
e2e_1 | yield from visit(entry.path, recurse)
e2e_1 | root/.local/lib/python3.8/site-packages/_pytest/pathlib.py:652: in visit
e2e_1 | for entry in os.scandir(path):
e2e_1 | E FileNotFoundError: [Errno 2] No such file or directory: '/dev/fd/13'
e2e_1 | =========================== short test summary info ============================
e2e_1 | ERROR - FileNotFoundError: [Errno 2] No such file or directory: '/dev/fd/13'
The e2e.yml file (d):
version: '3.7'
services:
e2e:
build:
dockerfile: Dockerfile
context: .
command: bash run_test_page.sh
depends_on:
- 'selenium-hub'
- 'selenium-1'
- 'selenium-2'
environment:
SELENIUM_URL: 'http://172.24.0.2:4444'
volumes:
- type: bind
source: ./screenshots
target: /screenshots
- type: bind
source: ./junit
target: /junit
selenium-1:
image: selenium/node-chrome:latest
shm_size: '2gb'
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-2:
image: selenium/node-chrome:latest
shm_size: '2gb'
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-hub:
image: selenium/hub:latest
expose:
- 4444
I don't know the meaning of thir error, but my best guess is that python is improperly installed.