Merge lp:~cjwatson/rabbitfixture/rabbitmq-server-3.8.10 into lp:rabbitfixture

Proposed by Colin Watson
Status: Merged
Merged at revision: 53
Proposed branch: lp:~cjwatson/rabbitfixture/rabbitmq-server-3.8.10
Merge into: lp:rabbitfixture
Diff against target: 68 lines (+35/-1)
3 files modified
NEWS.rst (+1/-0)
rabbitfixture/server.py (+18/-1)
rabbitfixture/tests/test_server.py (+16/-0)
To merge this branch: bzr merge lp:~cjwatson/rabbitfixture/rabbitmq-server-3.8.10
Reviewer Review Type Date Requested Status
Ioana Lasc Approve
Review via email: mp+397244@code.launchpad.net

Commit message

Handle new format of rabbitmqctl status output in RabbitMQ 3.7.0.

To post a comment you must log in.
53. By Colin Watson

Correct affected RabbitMQ version: I think it's actually 3.7.0.

The rabbitmq-server git repository is confusingly laid out, but I definitely
see the new format with the packaged version of 3.8.2 in focal, and release
notes suggest that the big change was in 3.7.0.

54. By Colin Watson

Test new rabbitmqctl status format.

Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.rst'
2--- NEWS.rst 2021-02-01 11:14:25 +0000
3+++ NEWS.rst 2021-02-01 12:16:39 +0000
4@@ -12,6 +12,7 @@
5 child process.
6 - Fix ``ResourceWarning`` on Python 3 if
7 ``RabbitServerEnvironment.rabbitctl`` times out.
8+- Handle new format of ``rabbitmqctl status`` output in RabbitMQ 3.7.0.
9
10 0.4.2 (2019-08-23)
11 ==================
12
13=== modified file 'rabbitfixture/server.py'
14--- rabbitfixture/server.py 2021-02-01 11:14:25 +0000
15+++ rabbitfixture/server.py 2021-02-01 12:16:39 +0000
16@@ -89,10 +89,27 @@
17 \{rabbit,"RabbitMQ"
18 """, re.VERBOSE | re.DOTALL)
19
20+# RabbitMQ 3.7.0 has a new format for its status output.
21+new_status_regex = re.compile(r"""
22+ Status\ of\ node\ '?
23+ (?P<nodename> # begin capture group
24+ [^@]+@[^@']+? # a node is name@hostname
25+ )'?(?:\ \.\.\.)?\n # end capture group
26+ .*
27+ ^OS\ PID:\ \d+\n
28+ .*
29+ ^RabbitMQ\ version:
30+ """, re.VERBOSE | re.MULTILINE | re.DOTALL)
31+
32
33 def get_nodename_from_status(status_text):
34 match = status_regex.search(status_text)
35- return None if match is None else match.group("nodename")
36+ if match is not None:
37+ return match.group("nodename")
38+ match = new_status_regex.search(status_text)
39+ if match is not None:
40+ return match.group("nodename")
41+ return None
42
43
44 class RabbitServerResources(Fixture):
45
46=== modified file 'rabbitfixture/tests/test_server.py'
47--- rabbitfixture/tests/test_server.py 2021-02-01 10:28:42 +0000
48+++ rabbitfixture/tests/test_server.py 2021-02-01 12:16:39 +0000
49@@ -227,3 +227,19 @@
50 self.assertEqual(
51 "tmpTAIyVi@obidos",
52 get_nodename_from_status(example_status))
53+
54+ def test_get_nodename_from_status_3_7_0(self):
55+ # rabbitmq-server 3.7.0 (I think) introduced a new format.
56+ example_status = dedent("""\
57+ Status of node tmpTAIyVi@obidos ...
58+ Runtime
59+
60+ OS PID: 12345
61+ OS: Linux
62+ Uptime (seconds): 5
63+ RabbitMQ version: 3.8.2
64+ Node name: tmpTAIyVi@obidos
65+ """)
66+ self.assertEqual(
67+ "tmpTAIyVi@obidos",
68+ get_nodename_from_status(example_status))

Subscribers

People subscribed via source and target branches

to all changes: