diff --git a/octavia/amphorae/backends/agent/api_server/haproxy_compatibility.py b/octavia/amphorae/backends/agent/api_server/haproxy_compatibility.py index c8915379ce..4a918864be 100644 --- a/octavia/amphorae/backends/agent/api_server/haproxy_compatibility.py +++ b/octavia/amphorae/backends/agent/api_server/haproxy_compatibility.py @@ -30,7 +30,7 @@ def get_haproxy_versions(): version = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) - version_re = re.search(r'.*version (.+?)\.(.+?)\..*', + version_re = re.search(r'.*version (.+?)\.(.+?)(\.|-dev).*', version.decode('utf-8')) major_version = int(version_re.group(1)) diff --git a/octavia/tests/unit/amphorae/backends/agent/api_server/test_haproxy_compatibility.py b/octavia/tests/unit/amphorae/backends/agent/api_server/test_haproxy_compatibility.py index 9d3f7b6877..5c1b0d2614 100644 --- a/octavia/tests/unit/amphorae/backends/agent/api_server/test_haproxy_compatibility.py +++ b/octavia/tests/unit/amphorae/backends/agent/api_server/test_haproxy_compatibility.py @@ -99,6 +99,15 @@ class HAProxyCompatTestCase(base.TestCase): self.assertEqual(1, major) self.assertEqual(6, minor) + @mock.patch('subprocess.check_output') + def test_get_haproxy_versions_devel(self, mock_process): + mock_process.return_value = ( + b"HA-Proxy version 2.3-dev0 2019/11/25 - https://haproxy.org/\n" + b"Some other data here \n") + major, minor = haproxy_compatibility.get_haproxy_versions() + self.assertEqual(2, major) + self.assertEqual(3, minor) + @mock.patch('octavia.amphorae.backends.agent.api_server.' 'haproxy_compatibility.get_haproxy_versions') def test_process_cfg_for_version_compat(self, mock_get_version):