7
7
import osgtest .library .core as core
8
8
import osgtest .library .osgunittest as osgunittest
9
9
10
- class TestFetchCrl (osgunittest .OSGTestCase ):
11
-
10
+ def output_is_acceptable (fetch_crl_output ):
11
+ """All lines output from fetch-crl are considered an error. We whitelist
12
+ a few transient ones.
13
+ """
12
14
error_message_whitelist = [
13
15
'CRL has lastUpdate time in the future' ,
14
16
'CRL has nextUpdate time in the past' ,
@@ -28,18 +30,23 @@ class TestFetchCrl(osgunittest.OSGTestCase):
28
30
'LWP::Protocol::http::Socket' ,
29
31
]
30
32
31
- def output_is_acceptable (self , fetch_crl_output ):
32
- all_lines_ok = True
33
- for line in fetch_crl_output .rstrip ('\n ' ).split ('\n ' ):
34
- line_ok = False
35
- for error_string in TestFetchCrl .error_message_whitelist :
36
- if re .search (error_string , line ):
37
- line_ok = True
38
- break
39
- if not line_ok :
40
- all_lines_ok = False
33
+ all_lines_ok = True
34
+ for line in fetch_crl_output .rstrip ('\n ' ).split ('\n ' ):
35
+ if not line : # skip blank lines
36
+ continue
37
+ line_ok = False
38
+ for error_string in error_message_whitelist :
39
+ if re .search (error_string , line ):
40
+ line_ok = True
41
41
break
42
- return all_lines_ok
42
+ if not line_ok :
43
+ all_lines_ok = False
44
+ core .log_message ("Found uncaught error message: '%s'" % line .strip ())
45
+ break
46
+ return all_lines_ok
47
+
48
+
49
+ class TestFetchCrl (osgunittest .OSGTestCase ):
43
50
44
51
def test_01_fetch_crl (self ):
45
52
core .skip_ok_unless_installed ('fetch-crl' )
@@ -51,7 +58,7 @@ def test_01_fetch_crl(self):
51
58
status , stdout , stderr = core .system (command )
52
59
fail = core .diagnose ('Run %s in /etc' % 'fetch-crl' , command , status , stdout , stderr )
53
60
if status == 1 :
54
- self .assert_ (self . output_is_acceptable (stdout ), fail )
61
+ self .assert_ (output_is_acceptable (stdout ), fail )
55
62
else :
56
63
self .assertEquals (status , 0 , fail )
57
64
count = len (glob .glob (os .path .join ('/etc/grid-security/certificates' , '*.r[0-9]' )))
@@ -68,7 +75,7 @@ def test_02_fetch_crl_dir(self):
68
75
status , stdout , stderr = core .system (command )
69
76
fail = core .diagnose ('Run fetch-crl in temp dir' , command , status , stdout , stderr )
70
77
if status == 1 :
71
- self .assert_ (self . output_is_acceptable (stdout ), fail )
78
+ self .assert_ (output_is_acceptable (stdout ), fail )
72
79
else :
73
80
self .assertEquals (status , 0 , fail )
74
81
count = len (glob .glob (os .path .join (temp_crl_dir , '*.r[0-9]' )))
0 commit comments