#1584 Add test_build_stream_collision.py and example config
Merged 4 years ago by mikem. Opened 4 years ago by mfilip.
mfilip/fm-orchestrator build-stream-collision  into  master

@@ -51,6 +51,15 @@ 

      buildrequires:

        module: testmodule

        branch: test-stream-with-logrotate

+   build_stream_collision:

+     build_id: 2010

Remove this?

+     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

@@ -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 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 @@ 

          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

Add test_build_stream_collision.py and example config

Is checking the logs sufficient?

Alternatively, you could find the module-build-macros component build:
/module-build-service/2/component-builds/?module_build=2010&package=module-build-macros

Then fetch the srpm from Koji, and check the module-build-macros.spec file.

1 new commit added

  • Fix second check to use a specfile
4 years ago

build_id: is common in the other test examples. Should I really remove it?

Build #795 failed (commit: d0f1b8d40e477e457876fc25b19bf4b17387fec1).
Rebase or make new commits to rebuild.

This feels a bit dangerous. Can we just use the specific filename here?

/me I also wish there was better way to do this without having to resort pipes. Will this actually work without shell=True ?

pretty please pagure-ci rebuild

4 years ago

@mfilip, ah! it looks like testing is failing due to flake8 errors:

tests/integration/utils.py:97:30: E127 continuation line over-indented for visual indent

1 new commit added

  • fix indent
4 years ago

Build #814 failed (commit: cb94497b17e569b4091b1eb7841272afafb7a300).
Rebase or make new commits to rebuild.

rebased onto c28bf3436412ac21af8cb56249976c3b4fb670e8

4 years ago

rebased onto 22ebbad

4 years ago

Pull-Request has been merged by mikem

4 years ago