From b19944eeecb5e133962f9e1f58768e3c7b9b929d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu>
Date: Thu, 23 Feb 2017 17:07:04 +0100
Subject: [PATCH] add initial worker test, refs #20596

---
 tests/test_mediaworker.py | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100755 tests/test_mediaworker.py

diff --git a/tests/test_mediaworker.py b/tests/test_mediaworker.py
new file mode 100755
index 00000000..fbee1bf9
--- /dev/null
+++ b/tests/test_mediaworker.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+'''
+Criticality: High
+Checks that MediaWorker can be reached using SSH
+'''
+import os
+import imp
+import sys
+import subprocess
+
+GREEN = '\033[92m'
+RED = '\033[91m'
+DEF = '\033[0m'
+
+os.chdir(os.path.dirname(__file__))
+if not os.path.isfile('../utils.py'):
+    print('conf.sh not found')
+    sys.exit(1)
+
+es_utils = imp.load_source('es_utils', '../utils.py')
+conf = es_utils.load_conf()
+
+def check_ssh(ip):
+    status, output = subprocess.getstatusoutput('timeout 2 ssh -o StrictHostKeyChecking=no %s ls /tmp' % ip)
+    if status != 0:
+        print('%sFailed to login using SSH%s' % (RED, DEF))
+        return False
+    return True
+
+all_ok = True
+
+worker_ip = conf.get('CELERITY_WORKER_IP')
+if worker_ip != '127.0.1.1':
+    if not check_ssh(worker_ip):
+        all_ok = False
-- 
GitLab