mirror: for mirror-testing, disable the security suite

Mirror testing should focus on testing the primary mirror, not the
security archive - therefore we disable the -security suite.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2023-09-07 11:15:31 +02:00
parent 5cc6f5df4a
commit 79f2c4c432
2 changed files with 58 additions and 1 deletions

View File

@ -323,7 +323,15 @@ class MirrorModel(object):
def get_apt_config_staged(self) -> Dict[str, Any]: def get_apt_config_staged(self) -> Dict[str, Any]:
assert self.primary_staged is not None assert self.primary_staged is not None
return self._get_apt_config_using_candidate(self.primary_staged) config = self._get_apt_config_using_candidate(self.primary_staged)
# For mirror testing, we disable the -security suite - so that we only
# test the primary mirror, not the security archive.
if "disable_suites" not in config:
config["disable_suites"]: List[str] = []
if "security" not in config["disable_suites"]:
config["disable_suites"].append("security")
return config
def get_apt_config_elected(self) -> Dict[str, Any]: def get_apt_config_elected(self) -> Dict[str, Any]:
assert self.primary_elected is not None assert self.primary_elected is not None

View File

@ -290,3 +290,52 @@ class TestMirrorModel(unittest.TestCase):
) )
with country_mirror_candidates: with country_mirror_candidates:
self.assertTrue(self.model.wants_geoip()) self.assertTrue(self.model.wants_geoip())
def test_get_apt_config_staged_default_config(self):
self.model.legacy_primary = False
self.model.primary_candidates = [
PrimaryEntry(
uri="http://mirror.local/ubuntu", arches=None, parent=self.model
),
]
self.model.primary_candidates[0].stage()
config = self.model.get_apt_config_staged()
self.assertEqual(
config["primary"],
[
{
"uri": "http://mirror.local/ubuntu",
"arches": ["default"],
}
],
)
self.assertEqual(
set(config["disable_components"]), set(self.model.disabled_components)
)
self.assertEqual(set(config["disable_suites"]), {"security"})
def test_get_apt_config_staged_with_config(self):
self.model.legacy_primary = False
self.model.primary_candidates = [
PrimaryEntry(
uri="http://mirror.local/ubuntu", arches=None, parent=self.model
),
]
self.model.primary_candidates[0].stage()
self.model.config = {
"disable_suites": ["updates"],
}
config = self.model.get_apt_config_staged()
self.assertEqual(
config["primary"],
[
{
"uri": "http://mirror.local/ubuntu",
"arches": ["default"],
}
],
)
self.assertEqual(
set(config["disable_components"]), set(self.model.disabled_components)
)
self.assertEqual(set(config["disable_suites"]), {"security", "updates"})