From b3095c1c909dcb3124e7fb893d5576bb57a64e19 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu>
Date: Thu, 30 Mar 2017 08:42:16 +0200
Subject: [PATCH] Changed worker test (refs #21016).

---
 tests/test_mediaworker.py | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/tests/test_mediaworker.py b/tests/test_mediaworker.py
index 4c97102e..f9557a4c 100755
--- a/tests/test_mediaworker.py
+++ b/tests/test_mediaworker.py
@@ -4,10 +4,11 @@
 Criticality: High
 Checks that MediaWorker can be reached using SSH and that it can reach the tasks server
 '''
-import os
 import imp
-import sys
+import os
+import re
 import subprocess
+import sys
 
 GREEN = '\033[92m'
 RED = '\033[91m'
@@ -46,7 +47,7 @@ def check_ssh(ip):
 
 def run_tests(ip):
     print('Updating envsetup tests on MediaWorker.')
-    cmd = 'ssh -t %s cd /root/envsetup && git pull' % ip
+    cmd = 'ssh -t %s /root/envsetup/update_envsetup.py' % ip
     os.system(cmd)
     print('Running envsetup tests on MediaWorker.')
     cmd = 'ssh -t %s /root/envsetup/tester.py' % ip
@@ -61,9 +62,22 @@ def run_tests(ip):
 
 
 def check_celerity_connectivity(ip):
-    h = conf.get('MS_SERVER_NAME')
-    cmd = 'ssh %s curl -k https://%s:6200' % (ip, h)
-    print('Checking celerity connectivity: %s' % cmd)
+    print('Getting celerity server url.')
+    cmd = 'ssh -t %s cat /etc/celerity/config.py' % ip
+    print(cmd)
+    try:
+        d = subprocess.check_output(cmd, shell=True, timeout=5, universal_newlines=True)
+    except subprocess.CalledProcessError:
+        m = None
+    else:
+        m = re.search(r'\nSERVER_URL\s*=\s*([:\/\'\"\-\_\.\w]+)', d)
+    if not m:
+        print('%sFailed to get celerity tasks server url from configuration in MediaWorker "%s".%s' % (RED, ip, DEF))
+        return False
+    server_url = m.groups()[0].strip('"\' ')
+    print('Checking celerity connectivity.')
+    cmd = 'ssh -t %s curl -k %s' % (ip, server_url)
+    print(cmd)
     try:
         d = subprocess.check_output(cmd, shell=True, timeout=5, universal_newlines=True)
     except subprocess.CalledProcessError:
-- 
GitLab