Switch constraints files over to the new opendev infrastructure

Currently constraint redirectiones that point to EOL releases don't work
as expected due to gitea needed to differentiate between tags and
branches.  Rather than fix, and rely on multiple redirects lets just
craft 301's that point to the correct gitea url.

This means we now need to know when a target is a branch or tag but
that's pretty simple to intuit given our deliverable structure.

Change-Id: Ife030f8ee7b5d204b054f99e920a675f7d92da69
This commit is contained in:
Tony Breeds 2019-05-22 13:39:46 +10:00
parent b50b346d63
commit 5801fbdc77
4 changed files with 28 additions and 15 deletions

View File

@ -1,6 +1,6 @@
redirect 301 /teams/shade.html /teams/openstacksdk.html
redirect 301 /constraints/upper/master http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=master
redirect 301 /constraints/upper/master https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt
{%- for redirection in redirections %}
redirect {{ redirection.code }} /constraints/upper/{{ redirection.src }} http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h={{ redirection.dst }}
redirect {{ redirection.code }} /constraints/upper/{{ redirection.src }} https://opendev.org/openstack/requirements/raw/{{ redirection.ref_type }}/{{ redirection.dst }}/upper-constraints.txt
{%- endfor %}

View File

@ -1,5 +1,5 @@
/teams/shade.html 301 /teams/openstacksdk.html
/constraints/upper/master 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=master
/constraints/upper/master 301 https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt
{%- for redirection in redirections %}
/constraints/upper/{{ redirection.src }} {{ redirection.code }} http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h={{ redirection.dst }}
/constraints/upper/{{ redirection.src }} {{ redirection.code }} https://opendev.org/openstack/requirements/raw/{{ redirection.ref_type }}/{{ redirection.dst }}/upper-constraints.txt
{%- endfor %}

View File

@ -24,6 +24,7 @@ def generate_constraints_redirections(_deliverables, future_releases=[]):
for deliv in _deliverables.get_deliverable_history('requirements'):
# Any open deliverables should point to master
target = 'master'
ref_type = 'branch'
# Unless there is a specific stable branch
for branch in deliv.branches:
@ -35,13 +36,16 @@ def generate_constraints_redirections(_deliverables, future_releases=[]):
for release in deliv.releases:
if release.is_eol:
target = str(release.version)
ref_type = 'tag'
break
# Insert into the begining of the list so that redirections are
# master -> juno
redirections.insert(0, dict(code=301, src=deliv.series, dst=target))
redirections.insert(0, dict(code=301, src=deliv.series,
ref_type=ref_type, dst=target))
for series in future_releases:
redirections.insert(0, dict(code=302, src=series, dst='master'))
redirections.insert(0, dict(code=302, src=series,
ref_type='branch', dst='master'))
return redirections

View File

@ -122,42 +122,48 @@ class TestRedirections(base.BaseTestCase):
deliverables = FakeDeliverables([
self.OPEN_DEVELOPMENT,
])
self.assertEqual([dict(code=301, src='stein', dst='master')],
self.assertEqual([dict(code=301, src='stein', ref_type='branch',
dst='master')],
generate_constraints_redirections(deliverables))
def test_development_release(self):
deliverables = FakeDeliverables([
self.DEVELOPMENT_RELEASE,
])
self.assertEqual([dict(code=301, src='stein', dst='master')],
self.assertEqual([dict(code=301, src='stein', ref_type='branch',
dst='master')],
generate_constraints_redirections(deliverables))
def test_open_stable(self):
deliverables = FakeDeliverables([
self.OPEN_STABLE,
])
self.assertEqual([dict(code=301, src='rocky', dst='stable/rocky')],
self.assertEqual([dict(code=301, src='rocky', ref_type='branch',
dst='stable/rocky')],
generate_constraints_redirections(deliverables))
def test_open_unstable(self):
deliverables = FakeDeliverables([
self.OPEN_UNSTABLE,
])
self.assertEqual([dict(code=301, src='rocky', dst='stable/rocky')],
self.assertEqual([dict(code=301, src='rocky', ref_type='branch',
dst='stable/rocky')],
generate_constraints_redirections(deliverables))
def test_stable_release(self):
deliverables = FakeDeliverables([
self.STABLE_RELEASE,
])
self.assertEqual([dict(code=301, src='rocky', dst='stable/rocky')],
self.assertEqual([dict(code=301, src='rocky', ref_type='branch',
dst='stable/rocky')],
generate_constraints_redirections(deliverables))
def test_stable_eol(self):
deliverables = FakeDeliverables([
self.STABLE_EOL,
])
self.assertEqual([dict(code=301, src='mitaka', dst='mitaka-eol')],
self.assertEqual([dict(code=301, src='mitaka', ref_type='tag',
dst='mitaka-eol')],
generate_constraints_redirections(deliverables))
def test_all(self):
@ -166,9 +172,12 @@ class TestRedirections(base.BaseTestCase):
self.STABLE_RELEASE,
self.DEVELOPMENT_RELEASE,
])
self.assertEqual([dict(code=301, src='stein', dst='master'),
dict(code=301, src='rocky', dst='stable/rocky'),
dict(code=301, src='mitaka', dst='mitaka-eol')],
self.assertEqual([dict(code=301, src='stein', ref_type='branch',
dst='master'),
dict(code=301, src='rocky', ref_type='branch',
dst='stable/rocky'),
dict(code=301, src='mitaka', ref_type='tag',
dst='mitaka-eol')],
generate_constraints_redirections(deliverables))
def test_empty(self):