mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-02 02:11:19 +08:00
Add test_build_stream_collision.py and example config
This commit is contained in:
@@ -51,6 +51,15 @@ testdata:
|
||||
buildrequires:
|
||||
module: testmodule
|
||||
branch: test-stream-with-logrotate
|
||||
build_stream_collision:
|
||||
build_id: 2010
|
||||
module: testmodule
|
||||
branch: test-stream-collision
|
||||
conflicting_module: postgresql
|
||||
# Version in conflicting stream
|
||||
conflicting_stream: 9.6-rhel-8.0.0
|
||||
# Version present in buildroot
|
||||
expected_version: 10.6
|
||||
resume_cancelled_build:
|
||||
# This scenario doesn't support reusing past builds. "build_id" is not used.
|
||||
module: testmodule
|
||||
|
||||
31
tests/integration/test_build_stream_collision.py
Normal file
31
tests/integration/test_build_stream_collision.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
def test_build_stream_collision(pkg_util, scenario, repo, koji, mbs):
|
||||
"""Build module which contains streams collision.
|
||||
|
||||
Checks:
|
||||
* Verify that build.log contains info about conflict.
|
||||
* Verify that correct version is used in macro specfile.
|
||||
"""
|
||||
error_msg = "Stream for collision is not available."
|
||||
assert mbs.get_builds(module=scenario['conflicting_module'],
|
||||
stream=scenario['conflicting_stream']), error_msg
|
||||
repo.bump()
|
||||
builds = pkg_util.run(
|
||||
"--optional",
|
||||
"rebuild_strategy=all",
|
||||
reuse=scenario.get("build_id"),
|
||||
)
|
||||
pkg_util.watch(builds)
|
||||
build = builds[0]
|
||||
buildlog = koji.get_build_log(build.components()[0], "build.log")
|
||||
|
||||
error_msg = "Conflict module was not found in build.log"
|
||||
assert f"Conflicts: {scenario['conflicting_module']}" in buildlog, error_msg
|
||||
|
||||
spec = koji.get_macro_specfile(build)
|
||||
error_msg = "Expected version not found in macro specfile."
|
||||
assert f"Conflicts: {scenario['conflicting_module']} " \
|
||||
f"= 0:{scenario['expected_version']}" in spec, error_msg
|
||||
@@ -11,6 +11,7 @@ import yaml
|
||||
import requests
|
||||
import tempfile
|
||||
import sh
|
||||
import os
|
||||
|
||||
our_sh = sh(_out=sys.stdout, _err=sys.stderr, _tee=True)
|
||||
from our_sh import Command, git, pushd # noqa
|
||||
@@ -74,6 +75,27 @@ class Koji:
|
||||
r.raise_for_status()
|
||||
return r.text
|
||||
|
||||
def get_macro_specfile(self, build):
|
||||
"""
|
||||
Download macro src.rpm and extract spec file .
|
||||
|
||||
:param build: build object
|
||||
:return: content of module-build-macros.spec
|
||||
:rtype: str
|
||||
"""
|
||||
parent_id = build.component_task_ids()['module-build-macros']
|
||||
child_id = next(child['id'] for child in
|
||||
self._session.getTaskChildren(parent_id)
|
||||
if child['method'] == 'buildArch')
|
||||
nvr = next(component['nvr'] for component in build.components()
|
||||
if component['package'] == 'module-build-macros')
|
||||
file_name = nvr + ".src.rpm"
|
||||
src_rpm = self._session.downloadTaskOutput(child_id, file_name)
|
||||
with tempfile.NamedTemporaryFile() as temp_file:
|
||||
temp_file.write(src_rpm)
|
||||
return os.popen(f"rpm2cpio {temp_file.name} | "
|
||||
f"cpio -ci --to-stdout '*.spec'").read()
|
||||
|
||||
|
||||
class Repo:
|
||||
"""Wrapper class to work with module git repositories
|
||||
|
||||
Reference in New Issue
Block a user