mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Reuse all components test
Implement the integration test for the Reuse All components Scenario.
This commit is contained in:
@@ -23,6 +23,7 @@ testdata:
|
||||
# Branch which is going to be built for this test.
|
||||
branch: scratch-build-branch
|
||||
failed_build:
|
||||
build_id: 1234
|
||||
module: testmodule
|
||||
branch: failed-build-branch
|
||||
# Batch considered by this test.
|
||||
@@ -34,6 +35,7 @@ testdata:
|
||||
canceled_components:
|
||||
- comp2
|
||||
normal_build:
|
||||
build_id: 1234
|
||||
module: testmodule
|
||||
branch: normal-build-branch
|
||||
# List of components in order they should be build in. One set represents one batch.
|
||||
@@ -41,5 +43,11 @@ testdata:
|
||||
# True if buildrequire a Platform stream representing a GA RHEL release
|
||||
platform_is_ga: true
|
||||
resume_cancelled_build:
|
||||
# This scenario doesn't support reusing past builds. "build_id" is not used.
|
||||
module: testmodule
|
||||
branch: cancel-build-branch
|
||||
reuse_all_components:
|
||||
build_id: 1234
|
||||
build_id_reused: 1235
|
||||
module: testmodule
|
||||
branch: reuse-all-components-branch
|
||||
|
||||
36
tests/integration/test_reuse_all_components.py
Normal file
36
tests/integration/test_reuse_all_components.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import utils
|
||||
|
||||
|
||||
def test_reuse_all_components(test_env, repo, koji):
|
||||
"""Rebuild the test module again, without changing any of the components with:
|
||||
|
||||
`fedpkg module-build -w --optional rebuild_strategy=only-changed`
|
||||
|
||||
Checks:
|
||||
* Verify that all the components are reused from the first build.
|
||||
* Verify that module-build-macros is not built in the second build.
|
||||
"""
|
||||
build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])
|
||||
repo.bump()
|
||||
build.run(
|
||||
"--watch",
|
||||
"--optional",
|
||||
"rebuild_strategy=all",
|
||||
reuse=test_env["testdata"]["reuse_all_components"].get("build_id"),
|
||||
)
|
||||
task_ids = build.component_task_ids()
|
||||
task_ids.pop("module-build-macros")
|
||||
|
||||
repo.bump()
|
||||
build.run(
|
||||
"-w",
|
||||
"--optional",
|
||||
"rebuild_strategy=only-changed",
|
||||
reuse=test_env["testdata"]["reuse_all_components"].get("build_id_reused"))
|
||||
reused_task_ids = build.component_task_ids()
|
||||
|
||||
assert not build.components(package="module-build-macros")
|
||||
assert task_ids == reused_task_ids
|
||||
@@ -145,11 +145,15 @@ class Build:
|
||||
:return: MBS build id of the build created
|
||||
:rtype: int
|
||||
"""
|
||||
current_build_id = self._build_id
|
||||
if reuse is not None:
|
||||
self._build_id = int(reuse)
|
||||
else:
|
||||
stdout = self._packaging_utility("module-build", *args).stdout.decode("utf-8")
|
||||
self._build_id = int(re.search(self._mbs_api + r"module-builds/(\d+)", stdout).group(1))
|
||||
# Clear cached data
|
||||
if current_build_id != self._build_id:
|
||||
self._component_data = None
|
||||
return self._build_id
|
||||
|
||||
def watch(self):
|
||||
@@ -264,6 +268,14 @@ class Build:
|
||||
|
||||
return batches
|
||||
|
||||
def component_task_ids(self):
|
||||
"""Dictionary containing all names of packages from build and appropriate task ids
|
||||
|
||||
:return: Dictionary containing name of packages and their task id
|
||||
:rtype: dict
|
||||
"""
|
||||
return {comp["package"]: comp["task_id"] for comp in self.components()}
|
||||
|
||||
def wait_for_koji_task_id(self, package, batch, timeout=300, sleep=10):
|
||||
"""Wait until the component is submitted to Koji (has a task_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user