PR#1587: Add test_highest_version_selection.py

Merges #1587
https://pagure.io/fm-orchestrator/pull-request/1587
This commit is contained in:
Mike McLean
2020-05-13 08:55:49 -04:00
3 changed files with 44 additions and 0 deletions

View File

@@ -100,3 +100,14 @@ def clone_and_start_build(repo, pkg_util):
pkg_util.cancel(build)
except sh.ErrorReturnCode:
pass # we don't need to bother with clean-up errors
@pytest.fixture(scope="function")
def require_koji_resolver(repo, scenario, test_env, mbs):
"""Check that koji resolver is present."""
stream = repo.modulemd['data']['dependencies'][0]['buildrequires']['platform']
platform_build = mbs.get_module_builds(name="platform", stream=stream)[0]
resolver = platform_build.get_modulemd()['data']['xmd']['mbs']\
.get('koji_tag_with_modules')
if not resolver:
pytest.skip('koji resolver is not configured.')

View File

@@ -101,3 +101,12 @@ testdata:
rest_module_build:
module: testmodule
branch: test-rest-module-build
highest_version_selection:
# testmodule2 buildrequires and requires stream from testmodule
# with multiple versions all properly tagged.
# These are expected to be built already.
build_id: 2077
module: testmodule2
branch: test-highest-version-selection
stream_module: testmodule
test_stream: test-stream-highest-version

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
def test_highest_version_selection(pkg_util, scenario, repo, mbs, require_koji_resolver):
"""
Build module with stream with multiple versions in buildrequires.
Checks:
* Check that the highest version of build in required stream is used.
"""
repo.bump()
builds = pkg_util.run("--optional", "rebuild_strategy=all",
reuse=scenario.get("build_id"))
build = builds[0]
module_id = build.module_build_data['id']
build_info = mbs.get_module_build(module_id)
module_version_used = build_info.data['buildrequires']['testmodule']['version']
module_builds = mbs.get_builds(scenario['stream_module'], scenario['test_stream'])
module_versions = [build.data['version'] for build
in module_builds]
assert len(module_versions) >= 2, 'More than one version is needed.'
error_msg = 'Version used is not the latest.'
assert module_version_used == max(module_versions), error_msg