From da674847f6ddf7ab96e5465651877f4631c685a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu>
Date: Thu, 16 Mar 2017 18:36:07 +0100
Subject: [PATCH] detect if a ms vhost is not in the celerity conf, refs #20845

---
 tests/test_nginx_vhosts.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/test_nginx_vhosts.py b/tests/test_nginx_vhosts.py
index e6a4f491..57176e9a 100755
--- a/tests/test_nginx_vhosts.py
+++ b/tests/test_nginx_vhosts.py
@@ -44,6 +44,13 @@ resolution_ignored = conf.get('TESTER_VHOST_RESOLUTION_IGNORED', '').split(',')
 requests.packages.urllib3.disable_warnings()
 found = False
 errors = 0
+warnings = False
+
+def check_celerity_conf(url):
+    with open('/etc/celerity/config.py', 'r') as f:
+        d = f.read()
+        return url in d
+
 for name in os.listdir(nginx_dir):
     path = os.path.join(nginx_dir, name)
     with open(path, 'r') as fo:
@@ -62,6 +69,9 @@ for name in os.listdir(nginx_dir):
             continue  # status vhost
         found = True
         url = '%s://%s' % ('https' if https else 'http', domain)
+        if name.startswith('mediaserver') and not check_celerity_conf(url):
+            sys.stdout.write('Url %s not found in celerity conf; is should also be set in the MediaWorker\n' % url)
+            warnings = True
         sys.stdout.write('Testing url "%s":\n' % url)
         # test domain IP
         ip_error = None
@@ -118,8 +128,10 @@ for name in os.listdir(nginx_dir):
             errors += 1
 
 if errors:
-    print('%s vhost(s) did not correctly responded.' % errors)
+    print('%s vhost(s) did not correctly respond.' % errors)
     sys.exit(1)
+elif warnings:
+    sys.exit(3)
 if not found:
     print('No vhost found in Nginx sites-enabled dir.')
     sys.exit(1)
-- 
GitLab