Skip to content
Snippets Groups Projects
Commit 0d37f1f2 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Changed timeout in nginx vhost test (refs #22843).

parent e5883735
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,11 @@ import re ...@@ -10,6 +10,11 @@ import re
import requests import requests
import socket import socket
import sys import sys
try:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
except ImportError:
requests.packages.urllib3.disable_warnings()
''' '''
This script checks for all enabled vhosts in Nginx conf that: This script checks for all enabled vhosts in Nginx conf that:
...@@ -70,7 +75,7 @@ for name in os.listdir(nginx_dir): ...@@ -70,7 +75,7 @@ for name in os.listdir(nginx_dir):
url = '%s://%s' % ('https' if https else 'http', domain) url = '%s://%s' % ('https' if https else 'http', domain)
sys.stdout.write('Testing url "%s":\n' % url) sys.stdout.write('Testing url "%s":\n' % url)
if name.startswith('mediaserver') and url not in celerity_conf: if name.startswith('mediaserver') and url not in celerity_conf:
sys.stdout.write('Url "%s" not found in celerity conf; it should also be set in the MediaWorker.\n' % url) sys.stdout.write('\033[93mWarning:\033[0m Url "%s" not found in celerity conf; it should also be set in the MediaWorker.\n' % url)
warnings += 1 warnings += 1
# test domain IP # test domain IP
ip_error = None ip_error = None
...@@ -94,37 +99,47 @@ for name in os.listdir(nginx_dir): ...@@ -94,37 +99,47 @@ for name in os.listdir(nginx_dir):
sys.stdout.write('\033[94mIgnored (%s)\033[0m' % ip_warning) sys.stdout.write('\033[94mIgnored (%s)\033[0m' % ip_warning)
ip_warning = None ip_warning = None
else: else:
sys.stdout.write('\033[91mWarning (%s)\033[0m' % ip_warning) sys.stdout.write('\033[93mWarning (%s)\033[0m' % ip_warning)
else: else:
sys.stdout.write('\033[92mOK (127.0.0.1)\033[0m') sys.stdout.write('\033[92mOK (127.0.0.1)\033[0m')
# test url # test url
sys.stdout.write(', status: ') sys.stdout.write(', status: ')
req_error = False req_error = False
try: try:
req = requests.get(url, verify=False, proxies={'http': '', 'https': ''}, timeout=10) req = requests.get(url, verify=False, proxies={'http': '', 'https': ''}, timeout=30)
req_time = int(1000 * req.elapsed.total_seconds())
except Exception as e: except Exception as e:
code = str(e) code = str(e)
req_time = 0
else: else:
code = req.status_code code = req.status_code
if code not in (200, 403): if code not in (200, 403):
sys.stdout.write('\033[91mKO (%s)\033[0m' % code) sys.stdout.write('\033[91mKO (%s, %sms)\033[0m' % (code, req_time))
req_error = True req_error = True
else: else:
sys.stdout.write('\033[92mOK (%s)\033[0m' % code) if req_time > 10000:
sys.stdout.write('\033[93mOK (%s, %sms)\033[0m' % (code, req_time))
warnings += 1
else:
sys.stdout.write('\033[92mOK (%s, %sms)\033[0m' % (code, req_time))
if 'mediaserver' in name and wowza_dir: if 'mediaserver' in name and wowza_dir:
# test /streaming url # test /streaming url
sys.stdout.write(', streaming: ') sys.stdout.write(', streaming: ')
try: try:
req = requests.get(url + '/streaming/', verify=False, proxies={'http': '', 'https': ''}, timeout=10) req = requests.get(url + '/streaming/', verify=False, proxies={'http': '', 'https': ''}, timeout=30)
req_time = int(1000 * req.elapsed.total_seconds())
except Exception as e: except Exception as e:
code = str(e) code = str(e)
req_time = 0
else: else:
code = req.status_code code = req.status_code
if code != 200: if code != 200:
sys.stdout.write('\033[91mKO (%s)\033[0m' % code) sys.stdout.write('\033[91mKO (%s, %sms)\033[0m' % (code, req_time))
req_error = True req_error = True
elif req_time > 10000:
sys.stdout.write('\033[93mOK (%s, %sms)\033[0m' % (code, req_time))
else: else:
sys.stdout.write('\033[92mOK (%s)\033[0m' % code) sys.stdout.write('\033[92mOK (%s, %sms)\033[0m' % (code, req_time))
sys.stdout.write('.\n') sys.stdout.write('.\n')
if ip_warning: if ip_warning:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment