mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-02 10:20:31 +08:00
Integration tests: add v3-packager coverage
This commit is contained in:
@@ -139,3 +139,15 @@ testdata:
|
||||
rest_submit_module_build:
|
||||
module: testmodule
|
||||
branch: test-submit-module
|
||||
v3_normal_build:
|
||||
module: testmodule
|
||||
branch: test-v3-normal-build
|
||||
v3_multiple_contexts:
|
||||
module: testmodule
|
||||
branch: test-v3-multiple-contexts
|
||||
v3_no_components:
|
||||
module: testmodule
|
||||
branch: test-v3-no-components
|
||||
v3_buildrequire:
|
||||
module: testmodule
|
||||
branch: test-v3-buildrequire
|
||||
|
||||
44
tests/integration/test_v3_buildrequire.py
Normal file
44
tests/integration/test_v3_buildrequire.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
def test_v3_buildrequire(mbs, clone_and_start_build):
|
||||
"""Test buildrequire fields in the v3-packager mmd.
|
||||
|
||||
Preconditions:
|
||||
* 2 contexts defined in mmd, one of which 'build-requires' another module
|
||||
(as well as a koji-resolver enabled platform).
|
||||
* Build-required module is tagged in koji with koji_tag_with_modules from said platform.
|
||||
|
||||
Steps:
|
||||
* Submit a build.
|
||||
* Wait until the build(s) are in build state.
|
||||
* Cancel the build(s).
|
||||
|
||||
Checks:
|
||||
* That that number of builds produced is equal to the number of configurations.
|
||||
* That each build has expected buildrequires items.
|
||||
"""
|
||||
|
||||
repo, builds = clone_and_start_build()
|
||||
contexts = {
|
||||
cfg["context"]: cfg for cfg in repo.modulemd["data"]["configurations"]
|
||||
}
|
||||
|
||||
assert len(builds) == len(contexts)
|
||||
|
||||
for build in builds:
|
||||
mbs.wait_for_module_build(build, lambda bld: bld.get("state") >= 2)
|
||||
ctx = build.module_build_data["context"]
|
||||
|
||||
assert ctx in contexts
|
||||
for buildrequire, data in build.module_build_data["buildrequires"].items():
|
||||
if buildrequire == "platform":
|
||||
mmd_platform = contexts[ctx]["platform"]
|
||||
assert data["stream"] == mmd_platform \
|
||||
if mmd_platform.endswith(".z") else f"{mmd_platform}.z"
|
||||
continue
|
||||
assert buildrequire in contexts[ctx]["buildrequires"]
|
||||
assert data["stream"] == contexts[ctx]["buildrequires"][buildrequire][0]
|
||||
|
||||
|
||||
8
tests/integration/test_v3_multiple_contexts.py
Normal file
8
tests/integration/test_v3_multiple_contexts.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
def test_v3_multiple_contexts(clone_and_start_build):
|
||||
"""Test that multiple configurations in v3-packager modulemd produce multiple module builds"""
|
||||
repo, builds = clone_and_start_build("--optional", "rebuild_strategy=all")
|
||||
assert len(builds) == len(repo.modulemd["data"]["configurations"])
|
||||
12
tests/integration/test_v3_no_components.py
Normal file
12
tests/integration/test_v3_no_components.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
def test_v3_no_components(mbs, clone_and_start_build):
|
||||
"""Test a minimal mmd - with no RPM components"""
|
||||
_, builds = clone_and_start_build(cancel=False)
|
||||
assert len(builds) == 1
|
||||
build = builds[0]
|
||||
|
||||
mbs.wait_for_module_build_to_succeed(build)
|
||||
assert not build.data["component_builds"]
|
||||
34
tests/integration/test_v3_normal_build.py
Normal file
34
tests/integration/test_v3_normal_build.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
def test_v3_normal_build(mbs, koji, clone_and_start_build):
|
||||
"""Test a normal module-build submitted with v3-packager YAML modulemd."""
|
||||
|
||||
repo, builds = clone_and_start_build("--optional", "rebuild_strategy=all", cancel=False)
|
||||
build = builds[0]
|
||||
|
||||
# actual input (v3 packager mmd)
|
||||
assert len(repo.modulemd["data"]["configurations"]) == 1
|
||||
mmd_configuration = repo.modulemd["data"]["configurations"][0]
|
||||
mmd_context = mmd_configuration["context"]
|
||||
mmd_platform = mmd_configuration["platform"]
|
||||
|
||||
mbs.wait_for_module_build_to_succeed(build)
|
||||
|
||||
# assert module build components
|
||||
assert sorted(build.component_names()) == sorted(repo.components + ["module-build-macros"])
|
||||
for component_rpm in build.components():
|
||||
assert koji.get_task(component_rpm["task_id"])["state"] == 2 # is closed
|
||||
|
||||
# assert produced koji build
|
||||
koji_build = koji.get_build(build.nvr())
|
||||
koji_build_devel = koji.get_build(build.nvr(name_suffix="-devel"))
|
||||
assert koji_build and koji_build_devel
|
||||
module_data = koji_build['extra']['typeinfo']['module']
|
||||
assert module_data['module_build_service_id'] == int(build.id)
|
||||
assert module_data['context'] == mmd_context
|
||||
koji_mmd = koji.get_modulemd(koji_build)
|
||||
actual_platforms = koji_mmd["data"]["dependencies"][0]["buildrequires"]["platform"]
|
||||
assert len(actual_platforms) == 1
|
||||
assert actual_platforms[0] == f"{mmd_platform}.z"
|
||||
@@ -79,6 +79,15 @@ class Koji:
|
||||
self._session = koji.ClientSession(self._server)
|
||||
self._pathinfo = koji.PathInfo(self._topurl)
|
||||
|
||||
def get_task(self, task_id):
|
||||
"""Koji task data for task id
|
||||
|
||||
:param int task_id: task id
|
||||
:return: Dictionary with Koji task data or None, if task is not found
|
||||
:rtype: dict or None
|
||||
"""
|
||||
return self._session.getTaskInfo(task_id)
|
||||
|
||||
def get_build(self, nvr_dict):
|
||||
"""Koji build data for NVR
|
||||
|
||||
|
||||
Reference in New Issue
Block a user