Skip to content

Commit

Permalink
Allow version-specific repomd url override
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Uiterwijk <[email protected]>
  • Loading branch information
puiterwijk authored and bowlofeggs committed Mar 7, 2018
1 parent e3013ff commit a81c44c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
20 changes: 13 additions & 7 deletions bodhi/server/consumers/masher.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,24 +995,30 @@ def _get_master_repomd_url(self, arch):
basestring: A URL on the master mirror where the repomd.xml file should be synchronized.
"""
release = self.compose.release.id_prefix.lower().replace('-', '_')
version = self.compose.release.version
request = self.compose.request.value

# First check to see if there's an override for the current version, if not, fall back.
# This will first try fedora_28_stable_(suffix), and then fedora_stable_(suffix).
key_prefixes = ['%s_%s_%s' % (release, version, request),
'%s_%s' % (release, request)]
# If the release has primary_arches defined in the config, we need to consider whether to
# use the release's *alt_master_repomd setting.
primary_arches = config.get(
'{release}_{version}_primary_arches'.format(
release=release, version=self.compose.release.version))
if primary_arches and arch not in primary_arches.split():
key = '%s_%s_alt_master_repomd'
suffix = '_alt_master_repomd'
else:
key = '%s_%s_master_repomd'
key = key % (release, request)
suffix = '_master_repomd'

master_repomd = config.get(key)
if not master_repomd:
raise ValueError("Could not find %s in the config file" % key)
keys = [key_prefix + suffix for key_prefix in key_prefixes]

return master_repomd % (self.compose.release.version, arch)
for key in keys:
val = config.get(key)
if val:
return val % (version, arch)
raise ValueError("Could not find any of %s in the config file" % ','.join(keys))

def _punge(self):
"""
Expand Down
36 changes: 34 additions & 2 deletions bodhi/tests/server/consumers/test_masher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,8 @@ def test_master_repomd_undefined(self):
t._get_master_repomd_url('aarch64')

self.assertEqual(six.text_type(exc.exception),
'Could not find fedora_testing_alt_master_repomd in the config file')
'Could not find any of fedora_17_testing_alt_master_repomd,'
'fedora_testing_alt_master_repomd in the config file')

@mock.patch.dict(
'bodhi.server.consumers.masher.config',
Expand All @@ -1815,6 +1816,36 @@ def test_primary_arch(self):
'http://example.com/pub/fedora/linux/updates/testing/17/x86_64/repodata.repomd.xml'
)

@mock.patch.dict(
'bodhi.server.consumers.masher.config',
{'fedora_17_primary_arches': 'armhfp x86_64',
'fedora_testing_master_repomd':
'http://example.com/pub/fedora/linux/updates/testing/%s/%s/repodata.repomd.xml',
'fedora_testing_alt_master_repomd':
'http://example.com/pub/fedora-secondary/updates/testing/%s/%s/repodata.repomd.xml',
'fedora_17_testing_master_repomd':
'http://example.com/pub/fedora/linux/updates/testing/%s/Everything/'
'%s/repodata.repomd.xml'})
def test_primary_arch_version_override(self):
"""
Assert that if a release_version_request setting exists, that overrides release_request.
"""
msg = self._make_msg()

t = PungiComposerThread(self.semmock, msg['body']['msg']['composes'][0],
'bowlofeggs', log, self.Session, self.tempdir)
t.compose = Compose.from_dict(self.db, msg['body']['msg']['composes'][0])

url = t._get_master_repomd_url('x86_64')

self.assertEqual(
url,
'http://example.com/pub/fedora/linux/updates/testing/17/Everything/'
'x86_64/repodata.repomd.xml'
)

self.assert_sems(0)

@mock.patch.dict(
'bodhi.server.consumers.masher.config',
{'fedora_testing_master_repomd':
Expand Down Expand Up @@ -2204,7 +2235,8 @@ def test_missing_config_key(self, publish):
t._wait_for_sync()

self.assertEqual(six.text_type(exc.exception),
'Could not find fedora_testing_master_repomd in the config file')
'Could not find any of fedora_17_testing_master_repomd,'
'fedora_testing_master_repomd in the config file')
publish.assert_called_once_with(topic='mashtask.sync.wait',
msg={'repo': t.id, 'agent': 'bowlofeggs'}, force=True)

Expand Down
8 changes: 6 additions & 2 deletions production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,34 @@ use = egg:bodhi-server
# file_url: Used in the repo metadata to set RPM URLs.
# file_url = https://download.fedoraproject.org/pub/fedora/linux/updates

# {release}_{request}_master_repomd: This is used by the masher to determine when a
# {release}_({version}_){request}_master_repomd: This is used by the masher to determine when a
# primary architecture push has been synchronized to the master mirror for a given release and
# request. The masher will verify that the checksum of repomd.xml at the master URL matches the
# expected value, and will poll the URL until this test passes. Substitute release and request
# for each release id (replacing -'s with _'s) and request (stable, testing). Used for the
# arches listed in {release}_{version}_primary_arches when it is defined, else used for all
# arches. You must put two %s's in this setting - the first will be replaced with the release
# version and the second will be replaced with the architecture.
# If a version of the option exists with a matching version, it has priority over one without.
# examples (these settings do not have defaults):
# fedora_stable_master_repomd = http://download01.phx2.fedoraproject.org/pub/fedora/linux/updates/%s/%s/repodata/repomd.xml
# fedora_28_stable_master_repomd = http://download01.phx2.fedoraproject.org/pub/fedora/linux/updates/%s/Everything/%s/repodata/repomd.xml
# fedora_testing_master_repomd = http://download01.phx2.fedoraproject.org/pub/fedora/linux/updates/testing/%s/%s/repodata/repomd.xml
# fedora_epel_stable_master_repomd = http://download01.phx2.fedoraproject.org/pub/epel/%s/%s/repodata/repomd.xml
# fedora_epel_testing_master_repomd = http://download01.phx2.fedoraproject.org/pub/epel/testing/%s/%s/repodata/repomd.xml

# {release}_{request}_alt_master_repomd: This is used by the masher to determine when a
# {release}_({version}_){request}_alt_master_repomd: This is used by the masher to determine when a
# secondary architecture push has been synchronized to the master mirror for a given release and
# request. The masher will verify that the checksum of repomd.xml at the master URL matches the
# expected value, and will poll the URL until this test passes. Substitute release and request
# for each release id (replacing -'s with _'s) and request (stable, testing). Used for the
# arches not listed in {release}_{version}_primary_arches if it is defined. You must put two
# %s's in this setting - the first will be replaced with the release version and the second will
# be replaced with the architecture.
# If a version of the option exists with a matching version, it has priority over one without.
# examples (these settings do not have defaults):
# fedora_stable_alt_master_repomd = http://download01.phx2.fedoraproject.org/pub/fedora-secondary/updates/%s/%s/repodata/repomd.xml
# fedora_28_stable_alt_master_repomd = http://download01.phx2.fedoraproject.org/pub/fedora-secondary/updates/%s/Everything/%s/repodata/repomd.xml
# fedora_testing_alt_master_repomd = http://download01.phx2.fedoraproject.org/pub/fedora-secondary/updates/testing/%s/%s/repodata/repomd.xml


Expand Down

0 comments on commit a81c44c

Please sign in to comment.