Merge lp:~allenap/rabbitfixture/rabbitmq-3.3-and-later into lp:rabbitfixture

Proposed by Gavin Panella on 2014-05-29
Status: Merged
Approved by: Gavin Panella on 2014-05-29
Approved revision: 34
Merged at revision: 32
Proposed branch: lp:~allenap/rabbitfixture/rabbitmq-3.3-and-later
Merge into: lp:rabbitfixture
Diff against target: 84 lines (+15/-2)
2 files modified
rabbitfixture/server.py (+12/-1)
rabbitfixture/tests/test_server.py (+3/-1)
To merge this branch: bzr merge lp:~allenap/rabbitfixture/rabbitmq-3.3-and-later
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) 2014-05-29 Approve on 2014-05-29
Review via email: mp+221368@code.launchpad.net

Commit message

Allocate a port for RABBITMQ_DIST_PORT, which is related to clustering in RabbitMQ >= 3.3.

Previously RabbitMQ was automatically setting to RABBITMQ_NODE_PORT + 20000, which causes problems when that port is in use, or greater than 2^16.

To post a comment you must log in.
Jeroen T. Vermeulen (jtv) wrote :

Thanks for solving this mystery! Impressive diagnostic work. EnvironmentVariableFixture is starting to look a bit tedious — if only it'd take a dict, or **kwargs...

One suggestion for the branch: if the test verified that the port numbers were in range, might that not have revealed this problem earlier on?

review: Approve
Gavin Panella (allenap) wrote :

> Thanks for solving this mystery! Impressive diagnostic work.
> EnvironmentVariableFixture is starting to look a bit tedious — if only it'd
> take a dict, or **kwargs...

That's Daniel Widerin's work; I take no credit.

>
> One suggestion for the branch: if the test verified that the port numbers were
> in range, might that not have revealed this problem earlier on?

No. This is a new setting, one which rabbitfixture was unaware of. RabbitMQ itself defaults the dist port to node port + 20000. I assume there's an internal overflow there.

Thanks for the review.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rabbitfixture/server.py'
2--- rabbitfixture/server.py 2013-09-16 15:21:39 +0000
3+++ rabbitfixture/server.py 2014-05-29 12:36:00 +0000
4@@ -91,18 +91,24 @@
5 :ivar hostname: The host the RabbitMQ is on (always localhost for
6 `RabbitServerResources`).
7 :ivar port: A port that was free at the time setUp() was called.
8+ :ivar dist_port: A port that was free at the time setUp() was
9+ called. Used for the `RABBITMQ_DIST_PORT` environment variable,
10+ which is related to clustering in RabbitMQ >= 3.3.
11 :ivar homedir: A directory to put the RabbitMQ logs in.
12 :ivar mnesiadir: A directory for the RabbitMQ db.
13 :ivar logfile: The logfile allocated for the server.
14 :ivar nodename: The name of the node.
15+
16 """
17
18 def __init__(self, hostname=None, port=None, homedir=None,
19- mnesiadir=None, logfile=None, nodename=None):
20+ mnesiadir=None, logfile=None, nodename=None,
21+ dist_port=None):
22 super(RabbitServerResources, self).__init__()
23 self._defaults = dict(
24 hostname=hostname,
25 port=port,
26+ dist_port=dist_port,
27 homedir=homedir,
28 mnesiadir=mnesiadir,
29 logfile=logfile,
30@@ -116,6 +122,8 @@
31 self.hostname = 'localhost'
32 if self.port is None:
33 [self.port] = allocate_ports(self.hostname)
34+ if self.dist_port is None:
35+ [self.dist_port] = allocate_ports(self.hostname)
36 if self.homedir is None:
37 self.homedir = self.useFixture(TempDir()).path
38 if self.mnesiadir is None:
39@@ -141,6 +149,7 @@
40 - ``RABBITMQ_LOG_BASE``
41 - ``RABBITMQ_NODE_IP_ADDRESS``
42 - ``RABBITMQ_NODE_PORT``
43+ - ``RABBITMQ_DIST_PORT``
44 - ``RABBITMQ_NODENAME``
45 - ``RABBITMQ_PLUGINS_DIR``
46
47@@ -167,6 +176,8 @@
48 self.useFixture(EnvironmentVariableFixture(
49 "RABBITMQ_NODE_PORT", str(self.config.port)))
50 self.useFixture(EnvironmentVariableFixture(
51+ "RABBITMQ_DIST_PORT", str(self.config.dist_port)))
52+ self.useFixture(EnvironmentVariableFixture(
53 "RABBITMQ_NODENAME", self.config.fq_nodename))
54 self.useFixture(EnvironmentVariableFixture(
55 "RABBITMQ_PLUGINS_DIR", self.config.pluginsdir))
56
57=== modified file 'rabbitfixture/tests/test_server.py'
58--- rabbitfixture/tests/test_server.py 2013-09-16 15:21:39 +0000
59+++ rabbitfixture/tests/test_server.py 2014-05-29 12:36:00 +0000
60@@ -70,6 +70,7 @@
61 with RabbitServerResources() as resources:
62 self.assertEqual("localhost", resources.hostname)
63 self.assertIsInstance(resources.port, int)
64+ self.assertIsInstance(resources.dist_port, int)
65 self.assertIsInstance(resources.homedir, (str, unicode))
66 self.assertIsInstance(resources.mnesiadir, (str, unicode))
67 self.assertIsInstance(resources.logfile, (str, unicode))
68@@ -77,7 +78,7 @@
69
70 def test_passed_to_init(self):
71 args = dict(
72- hostname="hostname", port=1234,
73+ hostname="hostname", port=1234, dist_port=2345,
74 homedir="homedir", mnesiadir="mnesiadir",
75 logfile="logfile", nodename="nodename")
76 resources = RabbitServerResources(**args)
77@@ -114,6 +115,7 @@
78 "RABBITMQ_LOG_BASE": config.homedir,
79 "RABBITMQ_NODE_IP_ADDRESS": socket.gethostbyname(config.hostname),
80 "RABBITMQ_NODE_PORT": str(config.port),
81+ "RABBITMQ_DIST_PORT": str(config.dist_port),
82 "RABBITMQ_NODENAME": config.fq_nodename,
83 "RABBITMQ_PLUGINS_DIR": config.pluginsdir,
84 }

Subscribers

People subscribed via source and target branches

to all changes: