Skip to content

Commit 3ed8c98

Browse files
Merge pull request #136 from brianhlin/fix-fetch-crl-errors
Fix fetch crl errors
2 parents 23be965 + d02a895 commit 3ed8c98

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

osgtest/tests/test_06_fetch_crl.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import osgtest.library.core as core
88
import osgtest.library.osgunittest as osgunittest
99

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+
"""
1214
error_message_whitelist = [
1315
'CRL has lastUpdate time in the future',
1416
'CRL has nextUpdate time in the past',
@@ -28,18 +30,23 @@ class TestFetchCrl(osgunittest.OSGTestCase):
2830
'LWP::Protocol::http::Socket',
2931
]
3032

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
4141
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):
4350

4451
def test_01_fetch_crl(self):
4552
core.skip_ok_unless_installed('fetch-crl')
@@ -51,7 +58,7 @@ def test_01_fetch_crl(self):
5158
status, stdout, stderr = core.system(command)
5259
fail = core.diagnose('Run %s in /etc' % 'fetch-crl', command, status, stdout, stderr)
5360
if status == 1:
54-
self.assert_(self.output_is_acceptable(stdout), fail)
61+
self.assert_(output_is_acceptable(stdout), fail)
5562
else:
5663
self.assertEquals(status, 0, fail)
5764
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):
6875
status, stdout, stderr = core.system(command)
6976
fail = core.diagnose('Run fetch-crl in temp dir', command, status, stdout, stderr)
7077
if status == 1:
71-
self.assert_(self.output_is_acceptable(stdout), fail)
78+
self.assert_(output_is_acceptable(stdout), fail)
7279
else:
7380
self.assertEquals(status, 0, fail)
7481
count = len(glob.glob(os.path.join(temp_crl_dir, '*.r[0-9]')))

0 commit comments

Comments
 (0)