Support haproxy development snapshot version parsing

Fix haproxy version parser in amphora-agent for beta versions (i.e
2.2-dev0)

Change-Id: I5baf7d18105494259361be1f0f411412071f1d36
This commit is contained in:
Gregory Thiemonge 2020-01-09 14:41:32 +01:00
parent 47e0ef31bc
commit 7dc54eb9c9
2 changed files with 10 additions and 1 deletions

View File

@ -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))

View File

@ -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 <test@example.com>\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):