Merge lp:~javier.collado/utah/bug1169846-test-case into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 871
Merged at revision: 872
Proposed branch: lp:~javier.collado/utah/bug1169846-test-case
Merge into: lp:utah
Diff against target: 70 lines (+37/-1)
2 files modified
tests/test_rsyslog.py (+36/-0)
utah/provisioning/rsyslog.py (+1/-1)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1169846-test-case
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+159853@code.launchpad.net

Description of the change

This branch adds the test case for the timeout functionality that was missing
in the original merge request:
https://code.launchpad.net/~javier.collado/utah/bug1169846/+merge/159821

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

pretty good. you think we can try and grep the exception for the missing steps?

870. By Javier Collado

Do not use repr to display the message name

871. By Javier Collado

Match exception message to ensure current message and remaining messages are there

Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks for your feedback. A pattern has been added to verify the step in the
exception message are correct.

review: Needs Resubmitting
Revision history for this message
Andy Doan (doanac) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_rsyslog.py'
2--- tests/test_rsyslog.py 2013-04-10 15:26:26 +0000
3+++ tests/test_rsyslog.py 2013-04-22 11:16:26 +0000
4@@ -16,6 +16,7 @@
5 """Test syslog processing functionality."""
6
7
8+import itertools
9 import logging
10 import socket
11 import time
12@@ -25,6 +26,7 @@
13
14 from utah.exceptions import UTAHException
15 from utah.provisioning.rsyslog import RSyslog
16+from utah.timeout import UTAHTimeout
17
18
19 class TestRsyslog(unittest.TestCase):
20@@ -246,3 +248,37 @@
21 def test_usefile_truncation(self):
22 """Test tailing a file with truncation."""
23 self.usefile(True)
24+
25+ def test_timeout(self):
26+ """UTAHTimeout is raised on timeout"""
27+ steps = [
28+ {
29+ "message": "message_1",
30+ "pattern": "finished",
31+ "timeout": 1,
32+ },
33+ {
34+ "message": "message_2",
35+ "pattern": "pattern",
36+ },
37+ {
38+ "message": "message_3",
39+ "pattern": "pattern",
40+ },
41+ ]
42+
43+ messages = itertools.repeat('log example')
44+ pattern = (r'Timeout \({}\) occurred for {} message.\n'
45+ r'Remaining messages: {}'
46+ .format(steps[0]['timeout'],
47+ steps[0]['message'],
48+ ', '.join([step['message']
49+ for step in steps[1:]])))
50+
51+ r = RSyslog('utah-test', '/tmp')
52+ thread = threading.Thread(target=self.producer,
53+ args=(r.port, messages))
54+ thread.daemon = True
55+ thread.start()
56+ self.assertRaisesRegexp(UTAHTimeout, pattern,
57+ r.wait_for_install, steps)
58
59=== modified file 'utah/provisioning/rsyslog.py'
60--- utah/provisioning/rsyslog.py 2013-04-19 11:19:55 +0000
61+++ utah/provisioning/rsyslog.py 2013-04-22 11:16:26 +0000
62@@ -157,7 +157,7 @@
63 remaining_messages = [step['message']
64 for step in steps[x + 1:]]
65 log_message = (
66- 'Timeout ({}) occurred for {!r} message.\n'
67+ 'Timeout ({}) occurred for {} message.\n'
68 'Remaining messages: {}'
69 .format(timeout, message,
70 ', '.join(remaining_messages)))

Subscribers

People subscribed via source and target branches