diff --git a/tests/test_mediaworker.py b/tests/test_mediaworker.py index 4c97102ef0c2df1d9267a431db6a1e07775a5434..f9557a4c62c9eac92c71f472b33a3d50b3f922ae 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: