Merge lp:~cjwatson/rabbitfixture/ctl-dist-port into lp:rabbitfixture

Proposed by Colin Watson
Status: Merged
Merged at revision: 61
Proposed branch: lp:~cjwatson/rabbitfixture/ctl-dist-port
Merge into: lp:rabbitfixture
Diff against target: 112 lines (+26/-5)
3 files modified
NEWS.rst (+3/-1)
rabbitfixture/server.py (+19/-3)
rabbitfixture/tests/test_server.py (+4/-1)
To merge this branch: bzr merge lp:~cjwatson/rabbitfixture/ctl-dist-port
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
William Grant code Approve
Review via email: mp+429534@code.launchpad.net

Commit message

Set RABBITMQ_CTL_DIST_PORT_{MIN,MAX} environment variables.

Description of the change

Otherwise `rabbitmqctl` starts this port range at `RABBITMQ_DIST_PORT` + 10000, which may exceed 65535.

Needed as of rabbitmq-server 3.7.4.

I gave this a full test run on a hacked focal buildbot worker, and it's behaving much better - no more `RabbitMQLayer` setup failures in the test runs I did there.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Oh my, good find.

review: Approve (code)
Revision history for this message
Jürgen Gmach (jugmac00) :
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 2022-09-01 15:47:58 +0000
3+++ NEWS.rst 2022-09-06 23:52:37 +0000
4@@ -5,7 +5,9 @@
5 0.5.3
6 =====
7
8-- Nothing yet.
9+- Set ``RABBITMQ_CTL_DIST_PORT_MIN`` and ``RABBITMQ_CTL_DIST_PORT_MAX``
10+ environment variables, as otherwise ``rabbitmqctl`` starts this port range
11+ at ``RABBITMQ_DIST_PORT`` + 10000, which may exceed 65535.
12
13 0.5.2 (2022-08-01)
14 ==================
15
16=== modified file 'rabbitfixture/server.py'
17--- rabbitfixture/server.py 2022-09-01 11:48:33 +0000
18+++ rabbitfixture/server.py 2022-09-06 23:52:37 +0000
19@@ -122,6 +122,9 @@
20 :ivar dist_port: A port that was free at the time setUp() was
21 called. Used for the `RABBITMQ_DIST_PORT` environment variable,
22 which is related to clustering in RabbitMQ >= 3.3.
23+ :ivar ctl_dist_port: A port that was free at the time setUp() was
24+ called. Used for the `RABBITMQ_CTL_DIST_PORT_MIN` environment
25+ variable.
26 :ivar homedir: A directory to put the RabbitMQ logs in.
27 :ivar mnesiadir: A directory for the RabbitMQ db.
28 :ivar logfile: The logfile allocated for the server.
29@@ -131,12 +134,13 @@
30
31 def __init__(self, hostname=None, port=None, homedir=None,
32 mnesiadir=None, logfile=None, nodename=None,
33- dist_port=None):
34+ dist_port=None, ctl_dist_port=None):
35 super(RabbitServerResources, self).__init__()
36 self._defaults = dict(
37 hostname=hostname,
38 port=port,
39 dist_port=dist_port,
40+ ctl_dist_port=ctl_dist_port,
41 homedir=homedir,
42 mnesiadir=mnesiadir,
43 logfile=logfile,
44@@ -148,10 +152,16 @@
45 self.__dict__.update(self._defaults)
46 if self.hostname is None:
47 self.hostname = 'localhost'
48+ port_vars = []
49 if self.port is None:
50- [self.port] = allocate_ports(self.hostname)
51+ port_vars.append("port")
52 if self.dist_port is None:
53- [self.dist_port] = allocate_ports(self.hostname)
54+ port_vars.append("dist_port")
55+ if self.ctl_dist_port is None:
56+ port_vars.append("ctl_dist_port")
57+ ports = allocate_ports(*([self.hostname] * len(port_vars)))
58+ for port_var, port in zip(port_vars, ports):
59+ setattr(self, port_var, port)
60 if self.homedir is None:
61 self.homedir = self.useFixture(TempDir()).path
62 if self.mnesiadir is None:
63@@ -181,6 +191,8 @@
64 - ``RABBITMQ_NODE_IP_ADDRESS``
65 - ``RABBITMQ_NODE_PORT``
66 - ``RABBITMQ_DIST_PORT``
67+ - ``RABBITMQ_CTL_DIST_PORT_MIN``
68+ - ``RABBITMQ_CTL_DIST_PORT_MAX``
69 - ``RABBITMQ_NODENAME``
70 - ``RABBITMQ_PLUGINS_DIR``
71 - ``RABBITMQ_ENABLED_PLUGINS_FILE``
72@@ -212,6 +224,10 @@
73 self.useFixture(EnvironmentVariableFixture(
74 "RABBITMQ_DIST_PORT", str(self.config.dist_port)))
75 self.useFixture(EnvironmentVariableFixture(
76+ "RABBITMQ_CTL_DIST_PORT_MIN", str(self.config.ctl_dist_port)))
77+ self.useFixture(EnvironmentVariableFixture(
78+ "RABBITMQ_CTL_DIST_PORT_MAX", str(self.config.ctl_dist_port + 10)))
79+ self.useFixture(EnvironmentVariableFixture(
80 "RABBITMQ_NODENAME", self.config.fq_nodename))
81 self.useFixture(EnvironmentVariableFixture(
82 "RABBITMQ_ENABLED_PLUGINS_FILE", self.config.pluginsfile))
83
84=== modified file 'rabbitfixture/tests/test_server.py'
85--- rabbitfixture/tests/test_server.py 2021-02-01 12:16:29 +0000
86+++ rabbitfixture/tests/test_server.py 2022-09-06 23:52:37 +0000
87@@ -125,6 +125,7 @@
88 self.assertEqual("localhost", resources.hostname)
89 self.assertIsInstance(resources.port, int)
90 self.assertIsInstance(resources.dist_port, int)
91+ self.assertIsInstance(resources.ctl_dist_port, int)
92 self.assertIsInstance(resources.homedir, six.string_types)
93 self.assertIsInstance(resources.mnesiadir, six.string_types)
94 self.assertIsInstance(resources.logfile, six.string_types)
95@@ -134,7 +135,7 @@
96
97 def test_passed_to_init(self):
98 args = dict(
99- hostname="hostname", port=1234, dist_port=2345,
100+ hostname="hostname", port=1234, dist_port=2345, ctl_dist_port=3456,
101 homedir="homedir", mnesiadir="mnesiadir",
102 logfile="logfile", nodename="nodename")
103 resources = RabbitServerResources(**args)
104@@ -172,6 +173,8 @@
105 "RABBITMQ_NODE_IP_ADDRESS": socket.gethostbyname(config.hostname),
106 "RABBITMQ_NODE_PORT": str(config.port),
107 "RABBITMQ_DIST_PORT": str(config.dist_port),
108+ "RABBITMQ_CTL_DIST_PORT_MIN": str(config.ctl_dist_port),
109+ "RABBITMQ_CTL_DIST_PORT_MAX": str(config.ctl_dist_port + 10),
110 "RABBITMQ_NODENAME": config.fq_nodename,
111 "RABBITMQ_ENABLED_PLUGINS_FILE": config.pluginsfile,
112 }

Subscribers

People subscribed via source and target branches

to all changes: