Files
fm-orchestrator/tests/integration/test_reuse_components.py
Hunor Csomortáni 5f7442f8c1 Tests: Create a fixture for scenario configuration
Until now, to access the configuration of a scenario, the full path in
test_env had to be specified.

This might be cumbersome and error prone.

Create a scenario fixture, to make it easier to access the same
configuration.

Instead of

    test_env["testdata"]["my_scenario"]["my_config"]

one can use the following:

    scenario["my_config"]

Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
2020-01-16 10:29:14 +01:00

56 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
import utils
def test_reuse_components(test_env, scenario, repo, koji):
"""
Bump the commit of one of the components that MBS uses.
Bump the commit of the same testmodule that was mentioned in the preconditions.
Submit a testmodule build again with `fedpkg module-build -w --optional
rebuild_strategy=only-changed` (this is the default rebuild strategy).
Checks:
* Verify all the components were reused except for the component that had their commit change.
* Verify that the component with the changed commit was rebuilt.
"""
repo.bump()
baseline_build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])
baseline_build.run(
"--watch",
"--optional",
"rebuild_strategy=all",
reuse=scenario.get("baseline_build_id"),
)
package = scenario.get("package")
component = utils.Component(
package,
scenario.get("component_branch")
)
component.clone(test_env["packaging_utility"])
component.bump()
repo.bump()
build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])
build.run(
"--watch",
"--optional",
"rebuild_strategy=only-changed",
reuse=scenario.get("build_id"),
)
comp_task_ids_base = baseline_build.component_task_ids()
comp_task_ids = build.component_task_ids()
comp_task_ids_base.pop('module-build-macros')
comp_task_ids.pop('module-build-macros')
changed_package_base_task_id = comp_task_ids_base.pop(package)
changed_package_task_id = comp_task_ids.pop(package)
assert changed_package_base_task_id != changed_package_task_id
assert comp_task_ids == comp_task_ids_base
assert build.components(package=package)[0]['state_name'] == 'COMPLETE'
state_reason = build.components(package=package)[0]['state_reason']
assert state_reason != "Reused component from previous module build"