mirror of https://github.com/OpenVidu/openvidu.git
deployment: openvidu_health_check can test OpenVidu CE/PRO/ENTERPRISE. Cache web drivers in Docker image
parent
e8c39c9242
commit
2c4596a73f
|
@ -23,13 +23,16 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
|
|||
|
||||
RUN pip3 install selenium webdriver_manager prettytable
|
||||
|
||||
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" ]
|
||||
COPY ./run.sh ./entrypoint.sh /usr/local/bin/
|
||||
COPY ./openvidu_health_check.py ./download_webdrivers.py ./
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/run.sh
|
||||
|
||||
CMD [ "openvidu_helth_check" ]
|
||||
# Cache web driver
|
||||
RUN python3 download_webdrivers.py
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
|
||||
|
||||
CMD [ "openvidu_health_check.py" ]
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from openvidu_health_check import InfraSmokeTests
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
init_obj = InfraSmokeTests()
|
||||
init_obj.runChrome()
|
||||
except:
|
||||
print("Chrome web driver downloaded")
|
||||
try:
|
||||
init_obj.runFirefox()
|
||||
except:
|
||||
print("Firefox web driver downloaded")
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
asyncRun() {
|
||||
"$@" &
|
||||
pid="$!"
|
||||
trap "echo 'Stopping PID $pid'; kill -SIGTERM $pid" SIGINT SIGTERM
|
||||
|
||||
# A signal emitted while waiting will make the wait command return code > 128
|
||||
# Let's wrap it in a loop that doesn't end before the process is indeed stopped
|
||||
while kill -0 $pid > /dev/null 2>&1; do
|
||||
wait
|
||||
done
|
||||
}
|
||||
|
||||
asyncRun /usr/local/bin/run.sh "$@"
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
import unittest
|
||||
import requests
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver import firefox
|
||||
from selenium.webdriver.firefox import service
|
||||
|
@ -17,20 +18,28 @@ import os
|
|||
class InfraSmokeTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
print('Executing test... Please wait...')
|
||||
self.openvidu_url = os.getenv('OV_URL')
|
||||
self.openvidu_password = os.getenv('OV_SECRET')
|
||||
self.is_openvidu_ce = self.check_is_openvidu_ce()
|
||||
if self.is_openvidu_ce:
|
||||
self.inject_basic_auth_in_url()
|
||||
self.driver = None
|
||||
|
||||
def test_inspector(self):
|
||||
def test_chrome_no_relay(self):
|
||||
self.inspector_check(browser="chrome")
|
||||
|
||||
def test_firefox_no_relay(self):
|
||||
self.inspector_check(browser="firefox")
|
||||
|
||||
def test_firefox_force_relay(self):
|
||||
self.inspector_check(browser="firefox", turn=True)
|
||||
|
||||
def inspector_check(self, browser="chrome", turn=False):
|
||||
print('\n\n======================================================================')
|
||||
print('|')
|
||||
print('|')
|
||||
print('| Testing OpenVidu with ' + browser + ' and force relay: ' + str(turn))
|
||||
print('| Testing OpenVidu ' + ('CE ' if self.is_openvidu_ce else 'PRO/ENTERPRISE ') + 'with ' + browser + ' and force relay: ' + str(turn))
|
||||
print('|')
|
||||
print('|')
|
||||
print('======================================================================')
|
||||
|
@ -41,6 +50,20 @@ class InfraSmokeTests(unittest.TestCase):
|
|||
else:
|
||||
self.runFirefox(turn)
|
||||
|
||||
if self.is_openvidu_ce:
|
||||
url_test = self.openvidu_url + '/dashboard'
|
||||
self.driver.get(url_test)
|
||||
|
||||
elem = self.driver.find_element(By.ID,'test-btn')
|
||||
elem.send_keys(Keys.RETURN)
|
||||
|
||||
elem = self.driver.find_element(By.NAME, 'secret')
|
||||
elem.send_keys(self.openvidu_password)
|
||||
|
||||
elem = self.driver.find_element(By.ID, 'join-btn')
|
||||
elem.send_keys(Keys.RETURN)
|
||||
|
||||
else:
|
||||
url_test = self.openvidu_url + '/inspector'
|
||||
self.driver.get(url_test)
|
||||
|
||||
|
@ -112,6 +135,20 @@ class InfraSmokeTests(unittest.TestCase):
|
|||
self.driver.implicitly_wait(5)
|
||||
self.driver.maximize_window()
|
||||
|
||||
def check_is_openvidu_ce(self):
|
||||
response = requests.get(self.openvidu_url + "/dashboard")
|
||||
if response.status_code == 401:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def inject_basic_auth_in_url(self):
|
||||
separator = "://"
|
||||
basic_auth_url_str = "OPENVIDUAPP:" + self.openvidu_password + "@"
|
||||
split_url = self.openvidu_url.split(separator)
|
||||
self.openvidu_url = split_url[0] + separator + basic_auth_url_str + split_url[1]
|
||||
|
||||
|
||||
def print_candidates(self):
|
||||
try:
|
||||
# New tab
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash -x
|
||||
#!/bin/bash
|
||||
set -eu -o pipefail
|
||||
|
||||
# Launch XVFB
|
||||
|
@ -11,4 +11,6 @@ do
|
|||
echo "Waiting xvfb..."
|
||||
done
|
||||
|
||||
exec "$*"
|
||||
echo "Running tests... Please wait..."
|
||||
|
||||
exec python3 "$@"
|
||||
|
|
Loading…
Reference in New Issue