From dfd44e0b0975cb5fa7e9a8de65c401d5f4801888 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mon, 8 Feb 2021 16:24:09 -0500 Subject: [PATCH 1/4] add dependencies to nginx test mmd --- tests/staged_data/nginx_mmd.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/staged_data/nginx_mmd.yaml b/tests/staged_data/nginx_mmd.yaml index c55defa4..db188e01 100644 --- a/tests/staged_data/nginx_mmd.yaml +++ b/tests/staged_data/nginx_mmd.yaml @@ -24,6 +24,11 @@ data: A module for the tests of module build service ’ # Module and content licenses in the Fedora license identifier # format, required + dependencies: + buildrequires: + platform: f33 + requires: + platform: f33 license: # Module license, required # This list covers licenses used for the module metadata, SPEC From df5733d05df295518ed86963b2bf63e8a02a3ae9 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mon, 8 Feb 2021 16:26:30 -0500 Subject: [PATCH 2/4] devel modules require non-devel, not themselves Fixes https://pagure.io/fm-orchestrator/issue/1676 --- module_build_service/builder/KojiContentGenerator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module_build_service/builder/KojiContentGenerator.py b/module_build_service/builder/KojiContentGenerator.py index be8d673c..f7a8a275 100644 --- a/module_build_service/builder/KojiContentGenerator.py +++ b/module_build_service/builder/KojiContentGenerator.py @@ -687,11 +687,12 @@ class KojiContentGenerator(object): mmd = self._sanitize_mmd(self.module.mmd()) if self.devel: # Set the new name - mmd = mmd.copy(mmd.get_module_name() + "-devel") + orig_name = mmd.get_module_name() + mmd = mmd.copy(orig_name + "-devel") # Depend on the actual module for dep in mmd.get_dependencies(): - dep.add_runtime_stream(mmd.get_module_name(), mmd.get_stream_name()) + dep.add_runtime_stream(orig_name, mmd.get_stream_name()) # Delete API and profiles for rpm in mmd.get_rpm_api(): From b9ca83f8b38c57ab0e89e4569aae165be7e40c0e Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mon, 8 Feb 2021 18:51:42 -0500 Subject: [PATCH 3/4] update unit test data --- tests/test_builder/test_content_generator.py | 16 ++++++++-------- .../test_get_generator_json_expected_output.json | 6 +++--- ..._generator_json_expected_output_with_log.json | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test_builder/test_content_generator.py b/tests/test_builder/test_content_generator.py index 1fdf4193..14f40267 100644 --- a/tests/test_builder/test_content_generator.py +++ b/tests/test_builder/test_content_generator.py @@ -193,20 +193,20 @@ class TestBuild: """ Test preparation of directory with output files """ dir_path = self.cg._prepare_file_directory() with io.open(path.join(dir_path, "modulemd.txt"), encoding="utf-8") as mmd: - assert len(mmd.read()) == 1160 + assert len(mmd.read()) == 1271 def test_prepare_file_directory_per_arch_mmds(self): """ Test preparation of directory with output files """ self.cg.arches = ["x86_64", "i686"] dir_path = self.cg._prepare_file_directory() with io.open(path.join(dir_path, "modulemd.txt"), encoding="utf-8") as mmd: - assert len(mmd.read()) == 1160 + assert len(mmd.read()) == 1271 with io.open(path.join(dir_path, "modulemd.x86_64.txt"), encoding="utf-8") as mmd: - assert len(mmd.read()) == 256 + assert len(mmd.read()) == 349 with io.open(path.join(dir_path, "modulemd.i686.txt"), encoding="utf-8") as mmd: - assert len(mmd.read()) == 254 + assert len(mmd.read()) == 347 @patch("koji.ClientSession") def test_tag_cg_build(self, ClientSession): @@ -275,12 +275,12 @@ class TestBuild: assert ret == { "arch": "x86_64", "buildroot_id": 1, - "checksum": "aed2e2774c82cbc19fe9555f70cafd79", + "checksum": "16c5bd74a1d8564293e3b73188acaae6", "checksum_type": "md5", "components": [], "extra": {"typeinfo": {"module": {}}}, "filename": "modulemd.x86_64.txt", - "filesize": 1162, + "filesize": 1273, "type": "file", } @@ -318,7 +318,7 @@ class TestBuild: assert ret == { "arch": "x86_64", "buildroot_id": 1, - "checksum": "5fbad2ef9b6c5496bdce4368ca3182d6", + "checksum": "580e1f880e0872bed58591c55eeb6e7e", "checksum_type": "md5", "components": [ { @@ -333,7 +333,7 @@ class TestBuild: ], "extra": {"typeinfo": {"module": {}}}, "filename": "modulemd.x86_64.txt", - "filesize": 316, + "filesize": 409, "type": "file", } diff --git a/tests/test_builder/test_get_generator_json_expected_output.json b/tests/test_builder/test_get_generator_json_expected_output.json index 92851403..a12d35d6 100644 --- a/tests/test_builder/test_get_generator_json_expected_output.json +++ b/tests/test_builder/test_get_generator_json_expected_output.json @@ -625,8 +625,8 @@ } ], "arch": "noarch", - "filesize": 1162, - "checksum": "aed2e2774c82cbc19fe9555f70cafd79", + "filesize": 1273, + "checksum": "16c5bd74a1d8564293e3b73188acaae6", "checksum_type": "md5", "type": "file", "extra": { @@ -652,7 +652,7 @@ "version": "2", "module_build_service_id": 2, "content_koji_tag": "module-nginx-1.2", - "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n # Module name, optional\n # Typically filled in by the buildsystem, using the VCS repository\n # name as the name of the module.\n name: nginx\n # Module update stream, optional\n # Typically filled in by the buildsystem, using the VCS branch name\n # as the name of the stream.\n stream: 1\n # Module version, integer, optional, cannot be negative\n # Typically filled in by the buildsystem, using the VCS commit\n # timestamp. Module version defines upgrade path for the particular\n # update stream.\n version: 2\n context: '00000000'\n # A short summary describing the module, required\n summary: An example nginx module\n # A verbose description of the module, required\n description: >\n A module for the tests of module build service ’\n # Module and content licenses in the Fedora license identifier\n # format, required\n license:\n # Module license, required\n # This list covers licenses used for the module metadata, SPEC\n # files or extra patches\n module:\n - MIT\n" + "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n # Module name, optional\n # Typically filled in by the buildsystem, using the VCS repository\n # name as the name of the module.\n name: nginx\n # Module update stream, optional\n # Typically filled in by the buildsystem, using the VCS branch name\n # as the name of the stream.\n stream: 1\n # Module version, integer, optional, cannot be negative\n # Typically filled in by the buildsystem, using the VCS commit\n # timestamp. Module version defines upgrade path for the particular\n # update stream.\n version: 2\n context: '00000000'\n # A short summary describing the module, required\n summary: An example nginx module\n # A verbose description of the module, required\n description: >\n A module for the tests of module build service ’\n # Module and content licenses in the Fedora license identifier\n # format, required\n dependencies:\n buildrequires:\n platform: f33\n requires:\n platform: f33\n license:\n # Module license, required\n # This list covers licenses used for the module metadata, SPEC\n # files or extra patches\n module:\n - MIT\n" } } }, diff --git a/tests/test_builder/test_get_generator_json_expected_output_with_log.json b/tests/test_builder/test_get_generator_json_expected_output_with_log.json index 0335db15..ae80d38c 100644 --- a/tests/test_builder/test_get_generator_json_expected_output_with_log.json +++ b/tests/test_builder/test_get_generator_json_expected_output_with_log.json @@ -625,8 +625,8 @@ } ], "arch": "noarch", - "filesize": 1162, - "checksum": "aed2e2774c82cbc19fe9555f70cafd79", + "filesize": 1273, + "checksum": "16c5bd74a1d8564293e3b73188acaae6", "checksum_type": "md5", "type": "file", "extra": { @@ -661,7 +661,7 @@ "version": "2", "module_build_service_id": 2, "content_koji_tag": "module-nginx-1.2", - "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n # Module name, optional\n # Typically filled in by the buildsystem, using the VCS repository\n # name as the name of the module.\n name: nginx\n # Module update stream, optional\n # Typically filled in by the buildsystem, using the VCS branch name\n # as the name of the stream.\n stream: 1\n # Module version, integer, optional, cannot be negative\n # Typically filled in by the buildsystem, using the VCS commit\n # timestamp. Module version defines upgrade path for the particular\n # update stream.\n version: 2\n context: '00000000'\n # A short summary describing the module, required\n summary: An example nginx module\n # A verbose description of the module, required\n description: >\n A module for the tests of module build service ’\n # Module and content licenses in the Fedora license identifier\n # format, required\n license:\n # Module license, required\n # This list covers licenses used for the module metadata, SPEC\n # files or extra patches\n module:\n - MIT\n" + "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n # Module name, optional\n # Typically filled in by the buildsystem, using the VCS repository\n # name as the name of the module.\n name: nginx\n # Module update stream, optional\n # Typically filled in by the buildsystem, using the VCS branch name\n # as the name of the stream.\n stream: 1\n # Module version, integer, optional, cannot be negative\n # Typically filled in by the buildsystem, using the VCS commit\n # timestamp. Module version defines upgrade path for the particular\n # update stream.\n version: 2\n context: '00000000'\n # A short summary describing the module, required\n summary: An example nginx module\n # A verbose description of the module, required\n description: >\n A module for the tests of module build service ’\n # Module and content licenses in the Fedora license identifier\n # format, required\n dependencies:\n buildrequires:\n platform: f33\n requires:\n platform: f33\n license:\n # Module license, required\n # This list covers licenses used for the module metadata, SPEC\n # files or extra patches\n module:\n - MIT\n" } } }, From 0b653b73a0b66fd039074fb41353b949468df83f Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mon, 8 Feb 2021 18:56:08 -0500 Subject: [PATCH 4/4] check that our test data has deps This unit test previously failed to detect a bug because the test data had no deps. --- tests/test_builder/test_content_generator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_builder/test_content_generator.py b/tests/test_builder/test_content_generator.py index 14f40267..54080dd5 100644 --- a/tests/test_builder/test_content_generator.py +++ b/tests/test_builder/test_content_generator.py @@ -958,7 +958,9 @@ class TestBuild: assert new_mmd.get_module_name().endswith("-devel") # Check that -devel requires non-devel. - for dep in new_mmd.get_dependencies(): + dependencies = new_mmd.get_dependencies() + assert dependencies # test data must have deps for this to be valid + for dep in dependencies: requires = [] for name in dep.get_runtime_modules(): for stream in dep.get_runtime_streams(name):