From 6ae9e1aeffa1eaa013d2cc375b54ce79e37208d1 Mon Sep 17 00:00:00 2001 From: Martin Filip Date: May 13 2020 12:52:46 +0000 Subject: Add test_highest_version_selection.py, example.test.env.yaml and expand utils.py --- diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 0ed44cc..aa4295a 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -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.') diff --git a/tests/integration/example.test.env.yaml b/tests/integration/example.test.env.yaml index 38714e1..d2576fb 100644 --- a/tests/integration/example.test.env.yaml +++ b/tests/integration/example.test.env.yaml @@ -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 diff --git a/tests/integration/test_highest_version_selection.py b/tests/integration/test_highest_version_selection.py new file mode 100644 index 0000000..20c0dcc --- /dev/null +++ b/tests/integration/test_highest_version_selection.py @@ -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