From 06974ef2020a8b536173b99aef2f6a9662f3b8fc Mon Sep 17 00:00:00 2001 From: Mariana Ulaieva Date: Wed, 4 Dec 2019 08:50:41 +0100 Subject: [PATCH] Reuse all components test Implement the integration test for the Reuse All components Scenario. --- tests/integration/example.test.env.yaml | 8 +++++ .../integration/test_reuse_all_components.py | 36 +++++++++++++++++++ tests/integration/utils.py | 12 +++++++ 3 files changed, 56 insertions(+) create mode 100644 tests/integration/test_reuse_all_components.py diff --git a/tests/integration/example.test.env.yaml b/tests/integration/example.test.env.yaml index b364754e..0c2b720a 100644 --- a/tests/integration/example.test.env.yaml +++ b/tests/integration/example.test.env.yaml @@ -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 diff --git a/tests/integration/test_reuse_all_components.py b/tests/integration/test_reuse_all_components.py new file mode 100644 index 00000000..d856361f --- /dev/null +++ b/tests/integration/test_reuse_all_components.py @@ -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 diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 1ea3e183..2f05deb3 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -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)