#1515 Integration test for normal build
Merged 4 years ago by csomh. Opened 4 years ago by ejegrova.
ejegrova/fm-orchestrator test_normal_build  into  master

@@ -8,6 +8,7 @@ 

  koji:

    server: https://koji.fedoraproject.org/kojihub

    topurl: https://kojipkgs.fedoraproject.org/

+   weburl: https://brewweb.stage.engineering.redhat.com/brewroot

  # Test data to be used by the tests.

  # Items in here are mapped by their name to the tests that use them.

  # For example test_scratch_build will use scratch_build.
@@ -32,3 +33,10 @@ 

      # List of components expected to complete or canceled in the batch.

      canceled_components:

      - comp2

+   normal_build:

+     module: testmodule

+     branch: normal-build-branch

+     # List of components in order they should be build in. One set represents one batch.

+     buildorder: [{"module-build-macros"}, {"attr"}, {"acl"}]

+     # True if buildrequire a Platform stream representing a GA RHEL release

+     platform_is_ga: true

@@ -0,0 +1,46 @@ 

+ # -*- coding: utf-8 -*-

+ # SPDX-License-Identifier: MIT

+ 

+ import utils

+ 

+ 

+ def test_normal_build(test_env, repo, koji):

+     """

+     Run build with `rhpkg-stage module-build --optional rebuild_strategy=all`

+ 

+     Checks:

+     * Check that MBS will submit all the component builds

+     * Check that buildorder of components is respected

+     * Check that MBS will create two content generator builds representing the module:

+         - [module]

+         - [module]-devel

+     * Check that MBS changed the buildrequired platform to have a suffix of “z”

+         if a Platform stream is representing a GA RHEL release.

+     """

+     build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])

+     build_id = build.run(

+         "--watch",

+         "--scratch",

+         "--optional",

+         "rebuild_strategy=all",

+         reuse=test_env["testdata"]["normal_build"].get("build_id"),

+     )

+     assert sorted(build.components()) == sorted(repo.components + ["module-build-macros"])

+ 

+     expected_buildorder = test_env["testdata"]["normal_build"]["buildorder"]

+     expected_buildorder = [set(batch) for batch in expected_buildorder]

+     actual_buildorder = build.batches()

+     assert actual_buildorder == expected_buildorder

+ 

+     cg_build = koji.get_build(build.nvr())

+     cg_devel_build = koji.get_build(build.nvr(name_suffix="-devel"))

+     assert cg_build and cg_devel_build

+     assert cg_devel_build['extra']['typeinfo']['module']['module_build_service_id'] == int(build_id)

+ 

+     modulemd = koji.get_modulemd(cg_build)

+     actual_platforms = modulemd["data"]["dependencies"][0]["buildrequires"]["platform"]

+     expected_platforms = repo.platform

+     platform_ga = test_env["testdata"]["normal_build"].get("platform_is_ga")

+     if platform_ga:

+         expected_platforms = [f"{pf}.z" for pf in expected_platforms]

+     assert expected_platforms == actual_platforms

file modified
+50 -1
@@ -15,13 +15,17 @@ 

  

      :attribute string _server: URL of the Koji hub

      :attribute string _topurl: URL of the top-level Koji download location

+     :attribute string _weburl: URL of the web interface

      :attribute koji.ClientSession _session: Koji session

+     :attribute koji.PathInfo _pathinfo: Koji path

      """

  

-     def __init__(self, server, topurl):

+     def __init__(self, server, topurl, weburl):

          self._server = server

          self._topurl = topurl

+         self._weburl = weburl

          self._session = koji.ClientSession(self._server)

+         self._pathinfo = koji.PathInfo(self._weburl)

  

      def get_build(self, nvr_dict):

          """Koji build data for NVR
@@ -33,6 +37,18 @@ 

          nvr_string = rpmlib.make_nvr(nvr_dict)

          return self._session.getBuild(nvr_string)

  

+     def get_modulemd(self, cg_build):

+         """Modulemd file of the build from koji archive

+ 

+         :param cg_build: koji build object

+         :return: Modulemd file

+         :rtype: dict

+         """

+         url = self._pathinfo.typedir(cg_build, 'module')

+         r = requests.get(f"{url}/modulemd.txt")

+         r.raise_for_status()

+         return yaml.safe_load(r.content)

+ 

  

  class Repo:

      """Wrapper class to work with module git repositories
@@ -44,6 +60,7 @@ 

      def __init__(self, module_name):

          self.module_name = module_name

          self._modulemd = None

+         self._version = None

  

      @property

      def modulemd(self):
@@ -67,6 +84,21 @@ 

          """

          return list(self.modulemd["data"]["components"]["rpms"])

  

+     @property

+     def platform(self):

+         """

+         List of platforms in the modulemd file, obtaining values differs on version

+ 

+         :return: List of platforms in the modulemd file

+         :rtype: list of strings

+         """

+         if self._version is None:

+             self._version = self._modulemd["version"]

+         if self._version == 1:

+             return [self._modulemd["data"]["dependencies"]["buildrequires"].get("platform")]

+         elif self._version == 2:

+             return self._modulemd["data"]["dependencies"][0]["buildrequires"].get("platform")

+ 

  

  class Build:

      """Wrapper class to work with module builds
@@ -146,6 +178,23 @@ 

  

          return [item["package"] for item in filtered]

  

+     def batches(self):

+         """

+         Components of the module build separated in sets according to batches

+ 

+         :return: list of components according to batches

+         :rtype: list of sets

+         """

+         comps_data = sorted(self.component_data["items"], key=lambda x: x["batch"])

+         batch_count = comps_data[-1]["batch"]

+         batches = batch_count * [set()]

+         for data in comps_data:

+             batch = data["batch"]

+             package = data["package"]

+             batches[batch - 1] = batches[batch - 1].union({package})

+ 

+         return batches

+ 

      def nvr(self, name_suffix=""):

          """NVR dictionary of this module build

  

Adding integration test for normal build scenario

pretty please pagure-ci rebuild

4 years ago

Build #606 failed (commit: 5d313fa9c7f8dd4b2551008789c8a6b7c9d8dcf1).
Rebase or make new commits to rebuild.

9 new commits added

  • Add integration test for normal build
  • Correct function name spelling
  • Fix call of at_concurrent_component_threshold in producer
  • Release v2.30.3
  • Configure the MBS backend code to use the correct SQLite database during local builds
  • Release v2.30.2
  • Stop adding repo entries for empty tags for local builds
  • Set skip_if_unavailable=True on localrepo to avoid module-build-macros failures for local builds
  • WIP: Integration test for failed build
4 years ago

Build #607 failed (commit: fa56eb43f695bf137452d6f58b5862828cc962d8).
Rebase or make new commits to rebuild.

rebased onto d82bb087d177631cc78ba40dc923ea924f77ceb5

4 years ago

Build #610 failed (commit: d82bb087d177631cc78ba40dc923ea924f77ceb5).
Rebase or make new commits to rebuild.

rebased onto f9455114b2ad1a60461eb2467c7b134cf171310a

4 years ago

Build #613 failed (commit: f9455114b2ad1a60461eb2467c7b134cf171310a).
Rebase or make new commits to rebuild.

rebased onto 16f8a7914e0165b61069173686bf9c45802e0994

4 years ago

Build #614 failed (commit: 16f8a7914e0165b61069173686bf9c45802e0994).
Rebase or make new commits to rebuild.

Maybe use .get("platform_is_ga") to allow this configuration to be optional.

Would be nice if this could also capture what are the expectations for batches. How about making it a list of list?

(The syntactically correct way would be a list of sets, but it seems YAML is not able to capture sets.)

Nit: no need for this empty line here.

Nit: no need for the brackets here.

Make pathinfo a member of the class (as _pathinfo). It's very probable that it will end up being used in other methods, too.

rebased onto de3b502e1287289336a6c63fe76d64b38c6559ba

4 years ago

Build #619 failed (commit: de3b502e1287289336a6c63fe76d64b38c6559ba).
Rebase or make new commits to rebuild.

@csomh I made the changes, could you look at it again?

rebased onto cc34b6a5b65d578dcb604398311cd3a11064cfdf

4 years ago

rebased onto 8ad8defb0f1909c004cdefc134494d122fa58f99

4 years ago

Build #626 failed (commit: 8ad8defb0f1909c004cdefc134494d122fa58f99).
Rebase or make new commits to rebuild.

rebased onto fbf6ac4943e442f5bdf2e3177e8d2696e042a951

4 years ago

@csomh made the changes, ptal :)

Build #629 failed (commit: fbf6ac4943e442f5bdf2e3177e8d2696e042a951).
Rebase or make new commits to rebuild.

Build #633 failed (commit: fbf6ac4943e442f5bdf2e3177e8d2696e042a951).
Rebase or make new commits to rebuild.

Hm, maybe you forgot to update this?

rebased onto 9d9bc4840a839af664efdf3d169e753b20a14f8d

4 years ago

Hm, maybe you forgot to update this?

Yes, now it's updated.

Also document the _pathinfo attribute.

Let's change this to koji.get_modulemd(cg_build), basically make get_modulemd to take a koji build object as a parameter, instead of an MBS build object, and so remove the (implicit) dependency between Build and Koji. This should make the code easier to maintain on the long run.

Add a doc-string here, explaining what this does and what it returns.

This segment can be made more readable by using expected_buildorder and actual_buildorder as variable names, and writing:

assert actual_buildorder == expected_buildorder

at the end.

Using expected_platforms and actual_platforms as variable names in this block, will improve readability.

rebased onto 15e772be259774fcb181cd73111f056fd907aea3

4 years ago

rebased onto 1d25b81

4 years ago

Commit 99fc977 fixes this pull-request

Pull-Request has been merged by csomh

4 years ago

Pull-Request has been merged by csomh

4 years ago
Metadata
Flags
jenkins
success (100%)
Build #1340 successful (commit: 1d25b81d)
4 years ago
c3i-jenkins
success (100%)
Build #639 successful (commit: 1d25b81d)
4 years ago
c3i-jenkins
success (100%)
Build #636 successful (commit: 15e772be)
4 years ago
jenkins
success (100%)
Build #1336 successful (commit: 9d9bc484)
4 years ago
c3i-jenkins
success (100%)
Build #635 successful (commit: 9d9bc484)
4 years ago
jenkins
success (100%)
Build #1333 successful (commit: fbf6ac49)
4 years ago
c3i-jenkins
failure
Build #633 failed (commit: fbf6ac49)
4 years ago
jenkins
success (100%)
Build #1328 successful (commit: 8ad8defb)
4 years ago
jenkins
success (100%)
Build #1329 successful (commit: 8ad8defb)
4 years ago
c3i-jenkins
failure
Build #626 failed (commit: 8ad8defb)
4 years ago
jenkins
success (100%)
Build #1321 successful (commit: de3b502e)
4 years ago
c3i-jenkins
failure
Build #619 failed (commit: de3b502e)
4 years ago
c3i-jenkins
failure
Build #614 failed (commit: 16f8a791)
4 years ago
jenkins
success (100%)
Build #1315 successful (commit: 16f8a791)
4 years ago
jenkins
success (100%)
Build #1314 successful (commit: f9455114)
4 years ago
c3i-jenkins
failure
Build #613 failed (commit: f9455114)
4 years ago
jenkins
success (100%)
Build #1311 successful (commit: d82bb087)
4 years ago
c3i-jenkins
failure
Build #610 failed (commit: d82bb087)
4 years ago
c3i-jenkins
failure
Build #607 failed (commit: fa56eb43)
4 years ago
jenkins
success (100%)
Build #1307 successful (commit: fa56eb43)
4 years ago
jenkins
failure
Build #1305 failed (commit: 5d313fa9)
4 years ago
jenkins
failure
Build #1306 failed (commit: 5d313fa9)
4 years ago
c3i-jenkins
failure
Build #606 failed (commit: 5d313fa9)
4 years ago