mirror of https://github.com/OpenVidu/openvidu.git
deployment: Experimental openvidu-health-checker self-contained docker image to check openvidu deployments
parent
abce613468
commit
5f7a88c68f
|
@ -0,0 +1,35 @@
|
||||||
|
FROM ubuntu:20.04
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
ENV DISPLAY :99.0
|
||||||
|
|
||||||
|
# Install Software
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -qqy --no-install-recommends \
|
||||||
|
gnupg2 \
|
||||||
|
xvfb \
|
||||||
|
x11-utils \
|
||||||
|
wget \
|
||||||
|
python3 \
|
||||||
|
python3-pip
|
||||||
|
|
||||||
|
# Install Chrome and firefox
|
||||||
|
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||||
|
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
|
||||||
|
&& apt-get update -qqy \
|
||||||
|
&& apt-get -qqy install \
|
||||||
|
google-chrome-stable firefox \
|
||||||
|
&& rm /etc/apt/sources.list.d/google-chrome.list
|
||||||
|
|
||||||
|
RUN pip3 install selenium webdriver_manager
|
||||||
|
|
||||||
|
COPY ./run.sh /usr/local/bin/run.sh
|
||||||
|
COPY ./openvidu_helth_check.py /usr/local/bin/openvidu_helth_check
|
||||||
|
RUN chmod +x /usr/local/bin/run.sh /usr/local/bin/openvidu_helth_check
|
||||||
|
|
||||||
|
WORKDIR /workdir
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/usr/local/bin/run.sh" ]
|
||||||
|
|
||||||
|
CMD [ "openvidu_helth_check" ]
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Openvidu health checker
|
||||||
|
|
||||||
|
The main purpose of this image is to have an self-contained and indpendent docker image to test and check possible errors in OpenVidu deployments.
|
||||||
|
|
||||||
|
This image is also usefull to automation tests of infrastructure.
|
||||||
|
|
||||||
|
# Currest health checks
|
||||||
|
|
||||||
|
## 1. Video working and Turn correctly setup
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run --shm-size 2g \
|
||||||
|
-e OV_URL=<OV_URL> \
|
||||||
|
-e OV_SECRET=<OV_SECRET> \
|
||||||
|
openvidu-health-checker
|
||||||
|
```
|
||||||
|
|
||||||
|
Just put your OpenVidu url at `OV_URL` and your `OV_SECRET` and the stack will be tested.
|
||||||
|
|
||||||
|
This health check includes:
|
||||||
|
|
||||||
|
- 1. Inspector Test Video in **Chrome**
|
||||||
|
- 2. Inspector Test Video in **Firefox**
|
||||||
|
- 3. Inspector Test Video in **Firefox** with **TURN forced**.
|
||||||
|
|
||||||
|
If allways works:
|
||||||
|
|
||||||
|
- STUN/TURN is correctly configured
|
||||||
|
- Video Publishing/Subscribing works
|
||||||
|
|
||||||
|
If works sometimes:
|
||||||
|
|
||||||
|
- Bad ports opened.
|
||||||
|
- Bad internet connection.
|
||||||
|
- No possible connection via STUN/TURN
|
||||||
|
|
||||||
|
If don't work:
|
||||||
|
|
||||||
|
- Bad port configuration.
|
||||||
|
- No possible connection via STUN/TURN
|
||||||
|
- Simply a deployment which is not deployed correctly
|
|
@ -0,0 +1,6 @@
|
||||||
|
VERSION=$1
|
||||||
|
if [[ ! -z $VERSION ]]; then
|
||||||
|
docker build --pull --no-cache --rm=true -t openvidu/openvidu-health-checker:$VERSION .
|
||||||
|
else
|
||||||
|
echo "Error: You need to specify a version as first argument"
|
||||||
|
fi
|
|
@ -0,0 +1,95 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
import unittest
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.firefox import service
|
||||||
|
from webdriver_manager.chrome import ChromeDriverManager
|
||||||
|
from webdriver_manager.firefox import GeckoDriverManager
|
||||||
|
from selenium.webdriver.chrome import options
|
||||||
|
from selenium.webdriver.chrome.service import Service as ChromeService
|
||||||
|
from selenium.webdriver.firefox.service import Service as FirefoxService
|
||||||
|
from selenium.webdriver.common.keys import Keys
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
|
class InfraSmokeTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.openvidu_url = os.getenv('OV_URL')
|
||||||
|
self.openvidu_password = os.getenv('OV_SECRET')
|
||||||
|
self.driver = None
|
||||||
|
|
||||||
|
def test_inspector(self):
|
||||||
|
self.inspector_check(browser="chrome")
|
||||||
|
self.inspector_check(browser="firefox")
|
||||||
|
self.inspector_check(browser="firefox", turn=True)
|
||||||
|
|
||||||
|
def inspector_check(self, browser="chrome", turn=False):
|
||||||
|
if browser == "chrome":
|
||||||
|
self.runChrome()
|
||||||
|
else:
|
||||||
|
self.runFirefox(turn)
|
||||||
|
print ('Testing OpenVidu Inspector test')
|
||||||
|
|
||||||
|
url_test = self.openvidu_url + '/inspector'
|
||||||
|
self.driver.get(url_test)
|
||||||
|
|
||||||
|
elem = self.driver.find_element(By.ID, 'secret-input')
|
||||||
|
elem.send_keys(self.openvidu_password)
|
||||||
|
|
||||||
|
elem = self.driver.find_element(By.ID, 'login-btn')
|
||||||
|
elem.send_keys(Keys.RETURN)
|
||||||
|
|
||||||
|
time.sleep(10)
|
||||||
|
print('data:image/png;base64,' + self.driver.get_screenshot_as_base64())
|
||||||
|
elem = self.driver.find_element(By.ID,'menu-test-btn')
|
||||||
|
elem.send_keys(Keys.RETURN)
|
||||||
|
|
||||||
|
elem = self.driver.find_element(By.ID,'test-btn')
|
||||||
|
elem.send_keys(Keys.RETURN)
|
||||||
|
|
||||||
|
self.driver.find_elements(By.XPATH, "//*[contains(text(), 'Stream playing')]")
|
||||||
|
print('data:image/png;base64,' + self.driver.get_screenshot_as_base64())
|
||||||
|
|
||||||
|
print('Video detected.')
|
||||||
|
elem = self.driver.find_element(By.ID,'test-btn')
|
||||||
|
elem.send_keys(Keys.RETURN)
|
||||||
|
|
||||||
|
print('Test success')
|
||||||
|
self.closeBrowser()
|
||||||
|
|
||||||
|
def runChrome(self):
|
||||||
|
self.options = webdriver.ChromeOptions()
|
||||||
|
self.options.add_argument("--use-fake-ui-for-media-stream")
|
||||||
|
self.options.add_argument("--disable-infobars")
|
||||||
|
self.options.add_argument("--ignore-certificate-errors")
|
||||||
|
self.options.add_argument("--start-maximized")
|
||||||
|
self.options.add_argument("--use-fake-device-for-media-stream")
|
||||||
|
self.options.add_argument("--no-sandbox")
|
||||||
|
|
||||||
|
self.driver = webdriver.Chrome(
|
||||||
|
service=ChromeService(ChromeDriverManager().install()),
|
||||||
|
options = self.options)
|
||||||
|
self.driver.implicitly_wait(15)
|
||||||
|
|
||||||
|
def runFirefox(self, turn=False):
|
||||||
|
print("Running firefox with Turn: ", turn)
|
||||||
|
self.options = webdriver.FirefoxOptions()
|
||||||
|
self.options.set_preference('media.navigator.permission.disabled', True)
|
||||||
|
self.options.set_preference('media.navigator.streams.fake', True)
|
||||||
|
if turn:
|
||||||
|
self.options.set_preference('media.peerconnection.ice.relay_only', True)
|
||||||
|
|
||||||
|
self.driver = webdriver.Firefox(
|
||||||
|
service=FirefoxService(GeckoDriverManager().install()),
|
||||||
|
options = self.options)
|
||||||
|
self.driver.implicitly_wait(15)
|
||||||
|
self.driver.maximize_window()
|
||||||
|
|
||||||
|
def closeBrowser(self):
|
||||||
|
# close the browser window
|
||||||
|
self.driver.close()
|
||||||
|
self.driver.quit()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash -x
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
# Launch XVFB
|
||||||
|
/usr/bin/Xvfb :99 -screen 0 1280x720x16 &
|
||||||
|
|
||||||
|
# Wait for XVFB
|
||||||
|
while ! xdpyinfo >/dev/null 2>&1
|
||||||
|
do
|
||||||
|
sleep 0.50s
|
||||||
|
echo "Waiting xvfb..."
|
||||||
|
done
|
||||||
|
|
||||||
|
exec "$*"
|
Loading…
Reference in New Issue