[test] Journalisation d'un test complet avec envois de mail en cas d'erreurs
This commit is contained in:
parent
8171455f4b
commit
7b8cfaea67
2 changed files with 37 additions and 10 deletions
14
test.py
14
test.py
|
@ -18,13 +18,17 @@ import variables
|
|||
sys.path.append("/usr/scripts/")
|
||||
from gestion.affich_tools import anim, OK, cprint, ERREUR
|
||||
|
||||
mail_format = False
|
||||
show_traceback = False
|
||||
if "--traceback" in sys.argv:
|
||||
show_traceback = True
|
||||
fast_test = False
|
||||
if "--fast" in sys.argv:
|
||||
fast_test = True
|
||||
|
||||
if "--mail" in sys.argv:
|
||||
mail_format = True
|
||||
OK = "OK"
|
||||
ERREUR = "ERREUR"
|
||||
def randomMAC():
|
||||
mac = [ 0x00, 0x16, 0x3e,
|
||||
random.randint(0x00, 0x7f),
|
||||
|
@ -72,7 +76,7 @@ def keys_of_list_of_dict(l, type=''):
|
|||
Teste l'écriture des objets si on est en mode rw"""
|
||||
keys = set()
|
||||
if l:
|
||||
anime=anim("Test des objets %r" % type, len(l))
|
||||
anime=anim("Test des objets %r" % type, 0 if mail_format else len(l))
|
||||
anime.reinit()
|
||||
ok=True
|
||||
for item in l:
|
||||
|
@ -88,6 +92,7 @@ def keys_of_list_of_dict(l, type=''):
|
|||
if show_traceback: print traceback.format_exc()
|
||||
else: print "\t%r" % error
|
||||
ok = False
|
||||
if not mail_format:
|
||||
anime.cycle()
|
||||
if l:
|
||||
anime.reinit()
|
||||
|
@ -145,11 +150,13 @@ def tests_machines(parent_dn, realm_list, ipsec=False):
|
|||
else: print "\t%r" % error
|
||||
else: print OK
|
||||
|
||||
if not mail_format:
|
||||
print "Test de la librairie lc_ldap"
|
||||
|
||||
print "Connexion"
|
||||
conn = shortcuts.lc_ldap_test()
|
||||
|
||||
if not mail_format:
|
||||
print u"Tests effectués avec les droits %s " % ', '.join(conn.droits)
|
||||
|
||||
###############################################
|
||||
|
@ -179,14 +186,17 @@ else:
|
|||
print OK
|
||||
|
||||
machines_attrs_keys = keys_of_list_of_dict(machines, 'machines')
|
||||
if not mail_format:
|
||||
print "Test des attributs des machines"
|
||||
test_list_of_dict(machines_attrs_keys, machines)
|
||||
|
||||
adherents_attrs_keys = keys_of_list_of_dict(adherents, 'adherents')
|
||||
if not mail_format:
|
||||
print "Test des attributs des adhérents"
|
||||
test_list_of_dict(adherents_attrs_keys, adherents)
|
||||
|
||||
|
||||
if not mail_format:
|
||||
print "Test de création d'objets"
|
||||
print "Instanciation"
|
||||
|
||||
|
|
17
test.sh
Executable file
17
test.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
MSG=$(/usr/scripts/lc_ldap/test.py --mail | grep -v OK$)
|
||||
TO="roots@crans.org"
|
||||
#TO="samir@crans.org"
|
||||
FROM="respbats@crans.org"
|
||||
SUBJECT="Erreur dans les tests lc_ldap sur la base de test"
|
||||
if [ -n "$MSG" ]; then
|
||||
sendmail "$TO" << EOF
|
||||
From: $FROM
|
||||
To: $TO
|
||||
Subject: $SUBJECT
|
||||
|
||||
$MSG
|
||||
.
|
||||
EOF
|
||||
fi;
|
Loading…
Add table
Add a link
Reference in a new issue