Merge "Support haproxy development snapshot version parsing"

This commit is contained in:
Zuul 2020-02-01 11:38:17 +00:00 committed by Gerrit Code Review
commit 9f89da5f22
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):