From 14800e804d1602ea2d41a30c0b104b860c5e980d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu>
Date: Thu, 1 Jun 2017 12:34:54 +0200
Subject: [PATCH] add raid test, refs #21547

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

diff --git a/tests/test_raid.py b/tests/test_raid.py
new file mode 100755
index 00000000..e68e4958
--- /dev/null
+++ b/tests/test_raid.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2017, Florent Thiery
+'''
+Criticality: High
+Checks that the server RAID array is fine.
+'''
+import glob
+import subprocess
+import sys
+import os
+
+GREEN = '\033[92m'
+RED = '\033[91m'
+DEF = '\033[0m'
+
+def print_red(string):
+    print(RED + string + DEF)
+
+def print_green(string):
+    print(GREEN + string + DEF)
+
+def check_raid(dev):
+    cmd = 'mdadm -D /dev/%s' % dev
+    status, output = subprocess.getstatusoutput(cmd)
+    print(output)
+    return status != 0
+
+if os.path.isfile('/proc/mdstat'):
+    all_ok = True
+    for r in glob.glob('/dev/md*'):
+        all_ok = min(check_raid(r), all_ok)
+    sys.exit(not all_ok)
+else:
+    print('No software RAID array found, untestable')
+    sys.exit(2)
-- 
GitLab