Support specifying upload options for image builds

The upload options are expected to be provided as a JSON file. The same
options will be used for all image type and architecture combinations,
similarly as it is done for ostree options.

Extend unit tests to cover the newly added functionality.
This commit is contained in:
Tomas Hozza 2022-07-29 17:28:43 +02:00 committed by Ondřej Budai
parent 4e32ae5439
commit c76e97ddc9
4 changed files with 151 additions and 0 deletions

View file

@ -1199,6 +1199,9 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
for ir in ireqs:
arch = ir["architecture"]
# Piggyback on this test case to test that no upload_options
# are set, if they were not provided in the args.
self.assertIsNone(ir.get("upload_options"))
repos = ir["repositories"]
assert len(repos) == 3
@ -1209,6 +1212,44 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods
ps = r.get("package_sets")
assert ps and ps == ["a", "b", "c", "d"]
@httpretty.activate
def test_compose_upload_options_global(self):
# Check we properly handle compose requests with global upload options
session = self.mock_session()
handler = self.make_handler(session=session)
arches = ["x86_64", "aarch64"]
upload_options = {
"region": "us-east-1",
"share_with_accounts": ["123456789"]
}
args = ["name", "version", "distro",
"image_type",
"fedora-candidate",
arches,
{"upload_options": upload_options}]
url = self.plugin.DEFAULT_COMPOSER_URL
composer = MockComposer(url, architectures=arches)
composer.httpretty_register()
res = handler.handler(*args)
assert res, "invalid compose result"
compose_id = res["composer"]["id"]
compose = composer.composes.get(compose_id)
self.assertIsNotNone(compose)
ireqs = compose["request"]["image_requests"]
# Check we got all the requested architectures
ireq_arches = [i["architecture"] for i in ireqs]
diff = set(arches) ^ set(ireq_arches)
self.assertEqual(diff, set())
for ir in ireqs:
uo = ir["upload_options"]
self.assertEqual(uo, upload_options)
@httpretty.activate
def test_compose_status_retry(self):
compose_id = "43e57e63-ab32-4a8d-854d-3bbc117fdce3"