提交 2ccdfbf2 编写于 作者: D Dave Cramer 提交者: GitHub

Fixversion (#1730)

* Align the version number with the current 5.0.
Currently gppkg fails due to the server being version 5.0
and getversion not understanding it.

* MAIN_VERSION uses 3 numbers now, add test for 5.0

* fix formatting

* attempt to deal with versions prior to 5 which expected 4 version numbers,
versions after 4 expect 3 version numbers

if the major version is below 5 then append 99,99 to versions shorter than 4 digits
if the major version is greater than 4 then append 99 to versions shorter than 3 digits
上级 8ef84de1
......@@ -164,8 +164,10 @@ class GpVersion:
raise StandardError("Version too short")
if len(v) > 4:
raise StandardError("Version too long")
if len(v) < 4:
if v[0] < 5 and len(v) < 4: # versions before 5 used 4 digits
v.extend([99,99])
if v[0] > 4 and len(v) < 3:
v.extend([99])
v = map(int, v) # Convert to integers
self.version = v[:4] # If we extended beyond 4 cut it back down
......
......@@ -97,7 +97,17 @@ class GpVersionTestCase(unittest.TestCase):
self.assertEqual(v.getVersionRelease(), "5.0")
self.assertEqual(v_1.getVersionRelease(), "4.3")
self.assertEqual(v_2.getVersionRelease(), "4.2")
def test_case_7(self):
vLong = GpVersion("PostgreSQL 8.3.23 (Greenplum Database 5.0.0 build dev) on x86_64-pc-linux-gnu, compiled by GCC gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17) compiled on Feb 9 2017 23:06:31")
self.assertTrue(vLong.isVersionCurrentRelease() == True )
self.assertTrue(vLong.getVersionBuild() == 'dev')
self.assertTrue(vLong.getVersionRelease() == "5.0")
self.assertTrue(vLong.isVersionRelease("5.0"))
self.assertTrue(vLong.isVersionRelease("3.2") == False)
self.assertTrue(vLong > "4.0.0")
self.assertTrue(vLong > "4.0")
def test_lshift_negative(self):
v = GpVersion('3.2')
with self.assertRaisesRegexp(StandardError, 'invalid version shift'):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册