Support cloning one freeze to multiple

The idea behind the version-map code is to work around a lack of a node
that has multiple python3 versions by taking a freeze from one version
(say python-3.5) and cloning that to another (say python-3,4).  This was
written to facilitate the transition from trusty (3.4) to xenial (3.5).

With the transition from xenial (3.5) to bionic (3.6) we need to do
something similar.  To aid the transition it'd be nice to be able to
duplicate a 3.5 freeze to both 3.4 *and* 3.6.  The current version_map
doesn't allow for that.

Enhance the version_map code to accommodate this situation.  The idea
would be to backport this as far as Ocata[1]

[1] We need to look again at separating the requirements code from the
data

Change-Id: I8784509bc162eb6f2e80261bc2d81dbe63ce7989
This commit is contained in:
Tony Breeds 2018-07-05 11:22:40 +10:00
parent 961a537e0d
commit 587460bac1
2 changed files with 30 additions and 10 deletions

View File

@ -139,12 +139,12 @@ def _clone_versions(freezes, options):
for freeze_data in freezes: for freeze_data in freezes:
versions = [v for v, d in freezes] versions = [v for v, d in freezes]
version, freeze = freeze_data version, freeze = freeze_data
if (version in options.version_map and if version in options.version_map:
options.version_map[version] not in versions): for dst_version in sorted(options.version_map[version]):
print("Duplicating %s freeze to %s" % if dst_version not in versions:
(version, options.version_map[version]), print("Duplicating %s freeze to %s" %
file=sys.stderr) (version, dst_version), file=sys.stderr)
freezes.append((options.version_map[version], copy.copy(freeze))) freezes.append((dst_version, copy.copy(freeze)))
# -- untested UI glue from here down. # -- untested UI glue from here down.
@ -177,7 +177,8 @@ def _validate_options(options):
"Invalid version-map entry %(map_entry)s" "Invalid version-map entry %(map_entry)s"
% dict(map_entry=map_entry)) % dict(map_entry=map_entry))
src, dst = map_entry.split(':') src, dst = map_entry.split(':')
version_map[src] = dst version_map.setdefault(src, set())
version_map[src].add(dst)
options.version_map = version_map options.version_map = version_map

View File

@ -110,7 +110,8 @@ class TestClone(testtools.TestCase):
def test_py34_clone_py35(self): def test_py34_clone_py35(self):
# Simulate an environment where we have python 3.4 data and need to # Simulate an environment where we have python 3.4 data and need to
# clone that to python 3.5 # clone that to python 3.5
options = Namespace(version_map={'3.4': '3.5', '3.5': '3.4'}) options = Namespace(version_map={'3.4': set(['3.5']),
'3.5': set(['3.4'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')]) freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')]) freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('dnspython3', '1.12.0')]) freeze_35 = ('3.5', [('dnspython3', '1.12.0')])
@ -125,7 +126,8 @@ class TestClone(testtools.TestCase):
def test_py34_noclone_py35(self): def test_py34_noclone_py35(self):
# Simulate an environment where we have python 3.4 and python 3.5 data # Simulate an environment where we have python 3.4 and python 3.5 data
# so there is no need to clone. # so there is no need to clone.
options = Namespace(version_map={'3.4': '3.5', '3.5': '3.4'}) options = Namespace(version_map={'3.4': set(['3.5']),
'3.5': set(['3.4'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')]) freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')]) freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('other-pkg', '1.0.0')]) freeze_35 = ('3.5', [('other-pkg', '1.0.0')])
@ -140,7 +142,8 @@ class TestClone(testtools.TestCase):
def test_py35_clone_py34(self): def test_py35_clone_py34(self):
# Simulate an environment where we have python 3.5 data and need to # Simulate an environment where we have python 3.5 data and need to
# clone that to python 3.4 # clone that to python 3.4
options = Namespace(version_map={'3.4': '3.5', '3.5': '3.4'}) options = Namespace(version_map={'3.4': set(['3.5']),
'3.5': set(['3.4'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')]) freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')]) freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('dnspython3', '1.12.0')]) freeze_35 = ('3.5', [('dnspython3', '1.12.0')])
@ -151,3 +154,19 @@ class TestClone(testtools.TestCase):
generate._clone_versions(freezes, options) generate._clone_versions(freezes, options)
self.assertEqual(expected_freezes, freezes) self.assertEqual(expected_freezes, freezes)
def test_py35_clone_py34_py36(self):
# Simulate an environment where we have python 3.5 data and need to
# clone that to python 3.4
options = Namespace(version_map={'3.5': set(['3.4', '3.6'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('dnspython3', '1.12.0')])
freeze_36 = ('3.6', [('dnspython3', '1.12.0')])
freezes = [freeze_27, freeze_35]
expected_freezes = [freeze_27, freeze_35, freeze_34, freeze_36]
generate._clone_versions(freezes, options)
self.assertEqual(expected_freezes, freezes)