openvidu-deployment-tester: Improve docker cache of drivers. Document how to develop the deployment tester image

pull/797/head
cruizba 2023-03-27 11:40:49 +02:00
parent 92048dcf7a
commit 09d89b2cdb
5 changed files with 63 additions and 23 deletions

View File

@ -0,0 +1,3 @@
python_modules/
src/geckodriver.*
*/__pycache__/

View File

@ -1,7 +1,9 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND noninteractive \
DISPLAY :99.0
DISPLAY :99.0 \
GECKO_DRIVER_LOCATION /usr/local/bin/geckodriver \
CHROME_DRIVER_LOCATION /usr/local/bin/chromedriver
# Install Software
RUN apt-get update && \

View File

@ -79,4 +79,42 @@ docker run openvidu/openvidu-deployment-tester basic-test \
### 2. Recording tests
Working on...
Working on...
## Development and Build instructions
### Requirements
- Python >= 3
- pip
- virtualenv
### Instructions
1. In the directory of this README file, create a virtual environment and activate it:
```bash
virtualenv -p python3 python_modules
source python_modules/bin/activate
```
2. Install the python dependencies:
```bash
pip install -r requirements.txt
```
3. Run the script:
```bash
cd src
python main.py -h
```
4. To build the docker image:
```bash
./create_imagh.sh latest
```

View File

@ -1,11 +1,11 @@
#!/bin/bash
set -eu -o pipefail
# Iniciar XVFB
# DISPLAY variable is used by Selenium to know which X server to use
export DISPLAY_NUM=99
export DISPLAY=":${DISPLAY_NUM}"
# Esperar hasta que XVFB esté listo
# Wait for Xvfb to be ready. If not ready after 2 seconds, try next display
while ! xdpyinfo -display "${DISPLAY}" >/dev/null 2>&1; do
DISPLAY_NUM=$((DISPLAY_NUM+1))
DISPLAY=":${DISPLAY_NUM}"

View File

@ -22,7 +22,7 @@ def install_drivers(chrome_version, gecko_version):
with open("chrome_version", "w") as f:
f.write(chrome_driver_manager.driver.get_version())
with open("firefox_version", "w") as f:
with open("gecko_version", "w") as f:
f.write(firefox_driver_manager.driver.get_version())
def authenticated_url(openvidu_url, openvidu_secret):
@ -42,16 +42,15 @@ def runBrowser(browser, turn=False):
return driver
def runChrome():
# Get Chrome driver version from environment variable
chrome_version = os.environ.get("CHROME_VERSION")
driver_location = os.environ.get("CHROME_DRIVER_LOCATION")
# Load version from file
chrome_version = None
with open("chrome_version", "r") as f:
chrome_version = f.read()
# Get Chrome driver version from file if not found in environment variable
# Read it only if file exist (it may not exist if running in a container)
if chrome_version is None and os.path.isfile("chrome_version"):
with open("chrome_version", "r") as f:
chrome_version = f.read()
print("Chrome version: ", chrome_version)
print("Running chrome...")
print("Chrome version: ", chrome_version)
options = webdriver.ChromeOptions()
options.add_argument("--use-fake-ui-for-media-stream")
options.add_argument("--disable-infobars")
@ -61,21 +60,19 @@ def runChrome():
options.add_argument("--no-sandbox")
return webdriver.Chrome(
service=ChromeService(ChromeDriverManager(version=chrome_version).install()),
service=ChromeService(ChromeDriverManager(path=driver_location, version=chrome_version).install()),
options = options)
def runFirefox(turn=False):
# Get Gecko driver version from environment variable
gecko_version = os.environ.get("GECKO_VERSION")
driver_location = os.environ.get("GECKO_DRIVER_LOCATION")
# Get Gecko driver version from file if not found in environment variable
# Read it only if file exist (it may not exist if running in a container)
if gecko_version is None and os.path.isfile("firefox_version"):
with open("firefox_version", "r") as f:
gecko_version = f.read()
# Load version from file
gecko_version = None
with open("gecko_version", "r") as f:
gecko_version = f.read()
print("Gecko version: ", gecko_version)
print("Running firefox with Turn: ", turn)
print("Gecko version: ", gecko_version)
options = webdriver.FirefoxOptions()
options.set_preference('media.navigator.permission.disabled', True)
options.set_preference('media.navigator.streams.fake', True)
@ -89,7 +86,7 @@ def runFirefox(turn=False):
options.set_preference('media.peerconnection.turn.disable', not turn)
return webdriver.Firefox(
service=FirefoxService(GeckoDriverManager(version=gecko_version).install()),
service=FirefoxService(GeckoDriverManager(path=driver_location, version=gecko_version).install()),
options = options)
def print_candidates(driver):