From 82359003581c3a9d3457461be8bd080a2892a661 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu>
Date: Thu, 23 Mar 2017 16:58:40 +0100
Subject: [PATCH] Fixed celerity config check.

---
 tests/test_nginx_vhosts.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/test_nginx_vhosts.py b/tests/test_nginx_vhosts.py
index cc9aef56..c635ca1c 100755
--- a/tests/test_nginx_vhosts.py
+++ b/tests/test_nginx_vhosts.py
@@ -39,18 +39,18 @@ if os.path.isfile('../utils.py'):
     es_utils = imp.load_source('es_utils', '../utils.py')
     conf = es_utils.load_conf()
 
+# get celerity conf
+celerity_conf = ''
+if os.path.exists('/etc/celerity/config.py'):
+    with open('/etc/celerity/config.py', 'r') as fo:
+        celerity_conf = fo.read()
+
 # get enabled vhosts
 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:
@@ -69,10 +69,10 @@ 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)
+        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)
+            warnings = True
         # test domain IP
         ip_error = None
         try:
-- 
GitLab