#1567 Module Stream Expansion integration test
Merged 4 years ago by csomh. Opened 4 years ago by mulaieva.
mulaieva/fm-orchestrator stream_exp  into  master

@@ -28,6 +28,16 @@ 

      return env

  

  

+ @pytest.fixture(scope="session")

+ def pkg_util(test_env):

+     """Fixture to interact with the packaging utility

+ 

+     :return: Packaging utility configured for the tests

+     :rtype: object of utils.PackagingUtility

+     """

+     return utils.PackagingUtility(test_env["packaging_utility"], test_env["mbs_api"])

+ 

+ 

  @pytest.fixture(scope="function")

  def scenario(request, test_env):

      """Configuration data for the scenario

@@ -64,3 +64,9 @@ 

    no_components:

      module: testmodule

      branch: test-no-components-branch

+   stream_expansion:

+     # testmodule2 buildrequires and requires 2 streams from testmodule.

+     # These are expected to be built already.

+     # For this scenario reusing former builds doesn't make sense.

+     module: testmodule2

+     branch: test-stream-expans-branch

@@ -1,10 +1,8 @@ 

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

  # SPDX-License-Identifier: MIT

  

- import utils

  

- 

- def test_failed_build(test_env, scenario, repo, koji):

+ def test_failed_build(pkg_util, scenario, repo, koji):

      """

      Run the build with "rebuild_strategy=all".

  
@@ -13,14 +11,15 @@ 

        * Check that any other components in the same batch as the failed component are

          cancelled, if not completed.

      """

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

      repo.bump()

-     build.run(

+     builds = pkg_util.run(

          "--optional",

          "rebuild_strategy=all",

          reuse=scenario.get("build_id"),

      )

-     build.watch()

+     assert len(builds) == 1

+     build = builds[0]

+     pkg_util.watch(builds)

  

      assert build.state_name == "failed"

      batch = scenario["batch"]

@@ -1,10 +1,8 @@ 

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

  # SPDX-License-Identifier: MIT

  

- import utils

  

- 

- def test_no_components(test_env, scenario, repo, koji):

+ def test_no_components(pkg_util, scenario, repo, koji):

      """

      Submit the testmodule build with `fedpkg module-build`

  
@@ -13,10 +11,12 @@ 

      * Verify that the testmodule build succeeds

  

      """

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

      repo.bump()

-     build.run(reuse=scenario.get("build_id"))

-     build.watch()

+     builds = pkg_util.run(reuse=scenario.get("build_id"))

+     assert len(builds) == 1

+ 

+     pkg_util.watch(builds)

+     build = builds[0]

  

      assert build.state_name == "ready"

      assert not build.data["component_builds"]

@@ -1,10 +1,8 @@ 

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

  # SPDX-License-Identifier: MIT

  

- import utils

  

- 

- def test_normal_build(test_env, scenario, repo, koji):

+ def test_normal_build(pkg_util, scenario, repo, koji):

      """

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

  
@@ -17,14 +15,15 @@ 

      * 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"])

      repo.bump()

-     build_id = build.run(

+     builds = pkg_util.run(

          "--optional",

          "rebuild_strategy=all",

          reuse=scenario.get("build_id"),

      )

-     build.watch()

+     assert len(builds) == 1

+     pkg_util.watch(builds)

+     build = builds[0]

  

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

  
@@ -36,7 +35,7 @@ 

      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)

+     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"]

@@ -1,11 +1,10 @@ 

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

  # SPDX-License-Identifier: MIT

  

- import utils

  import time

  

  

- def test_resume_cancelled_build(test_env, scenario, repo, koji):

+ def test_resume_cancelled_build(pkg_util, scenario, repo, koji):

      """

      Run the  build with "rebuild_strategy=all".

      Wait until the module-build-macros build is submitted to Koji.
@@ -17,17 +16,20 @@ 

        * Check that the testmodule build succeeded

  

      """

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

      repo.bump()

-     build.run(

+     builds = pkg_util.run(

          "--optional",

          "rebuild_strategy=all",

      )

+ 

+     assert len(builds) == 1

+     build = builds[0]

      build.wait_for_koji_task_id(package="module-build-macros", batch=1)

-     build.cancel()

+     pkg_util.cancel(build)

      # Behave like a human: restarting the build too quickly would lead to an error.

      time.sleep(10)

-     build.run("--watch")

- 

+     builds = pkg_util.run("--watch")

+     assert len(builds) == 1

+     build = builds[0]

      assert build.state_name == "ready"

      assert build.was_cancelled()

@@ -1,10 +1,8 @@ 

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

  # SPDX-License-Identifier: MIT

  

- import utils

  

- 

- def test_reuse_all_components(test_env, scenario, repo, koji):

+ def test_reuse_all_components(pkg_util, scenario, repo, koji):

      """Rebuild the test module again, without changing any of the components with:

  

      `fedpkg module-build -w --optional rebuild_strategy=only-changed`
@@ -13,23 +11,28 @@ 

      * Verify that all the components are reused from the first build.

      * Verify that module-build-macros is not built in the second build.

      """

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

      repo.bump()

-     build.run(

+     builds = pkg_util.run(

          "--watch",

          "--optional",

          "rebuild_strategy=all",

          reuse=scenario.get("build_id"),

      )

+     assert len(builds) == 1

+ 

+     build = builds[0]

      task_ids = build.component_task_ids()

      task_ids.pop("module-build-macros")

  

      repo.bump()

-     build.run(

+     builds = pkg_util.run(

          "-w",

          "--optional",

          "rebuild_strategy=only-changed",

          reuse=scenario.get("build_id_reused"))

+ 

+     assert len(builds) == 1

+     build = builds[0]

      reused_task_ids = build.component_task_ids()

  

      assert not build.components(package="module-build-macros")

@@ -4,7 +4,7 @@ 

  import utils

  

  

- def test_reuse_components(test_env, scenario, repo, koji):

+ def test_reuse_components(pkg_util, test_env, scenario, repo, koji):

      """

      Bump the commit of one of the components that MBS uses.

      Bump the commit of the same testmodule that was mentioned in the preconditions.
@@ -16,14 +16,15 @@ 

      * Verify that the component with the changed commit was rebuilt.

      """

      repo.bump()

-     baseline_build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])

-     baseline_build.run(

+     baseline_builds = pkg_util.run(

          "--watch",

          "--optional",

          "rebuild_strategy=all",

          reuse=scenario.get("baseline_build_id"),

      )

+     assert len(baseline_builds) == 1

  

+     baseline_build = baseline_builds[0]

      package = scenario.get("package")

      component = utils.Component(

          package,
@@ -33,14 +34,14 @@ 

      component.bump()

  

      repo.bump()

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

-     build.run(

+     builds = pkg_util.run(

          "--watch",

          "--optional",

          "rebuild_strategy=only-changed",

          reuse=scenario.get("build_id"),

      )

- 

+     assert len(builds) == 1

+     build = builds[0]

      comp_task_ids_base = baseline_build.component_task_ids()

      comp_task_ids = build.component_task_ids()

      comp_task_ids_base.pop('module-build-macros')

@@ -1,10 +1,8 @@ 

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

  # SPDX-License-Identifier: MIT

  

- import utils

  

- 

- def test_scratch_build(test_env, scenario, repo, koji):

+ def test_scratch_build(pkg_util, scenario, repo, koji):

      """

      Run a scratch build with "rebuild_strategy=all".

  
@@ -14,14 +12,16 @@ 

        (as opposed to the "ready" state)

      * no content generator builds are created in Koji

      """

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

-     build.run(

+     builds = pkg_util.run(

          "--scratch",

          "--optional",

          "rebuild_strategy=all",

          reuse=scenario.get("build_id"),

      )

-     build.watch()

+ 

+     assert len(builds) == 1

+     pkg_util.watch(builds)

+     build = builds[0]

  

      assert build.state_name == "done"

      assert sorted(build.component_names(state="COMPLETE")) == sorted(

@@ -0,0 +1,21 @@ 

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

+ # SPDX-License-Identifier: MIT

+ 

+ 

+ def test_stream_expansion(pkg_util, scenario, repo, koji):

+     """

+ 

+     Submit the testmodule2 build with `rhpkg-stage module-build`

+         The produced builds can be cancelled after the test cases have been verified to save on

+         resources and time

+ 

+     Checks:

+      * Verify two module builds were generated from this build submission
csomh commented 4 years ago

@mprahl is this check sufficient?

+ 

+     """

+     repo.bump()

+     builds = pkg_util.run()

+ 

+     assert len(builds) == 2

+     for build in builds:

+         pkg_util.cancel(build)

file modified
+48 -29
@@ -114,15 +114,12 @@ 

          git("push")

  

  

- class Build:

-     """Wrapper class to work with module builds

+ class PackagingUtility:

+     """Wrapper class to work with the packaging utility configured for the tests

  

      :attribute sh.Command _packaging_utility: packaging utility command used to

          kick off this build

      :attribute string _mbs_api: URL of the MBS API (including trailing '/')

-     :attribute string _url: URL of this MBS module build

-     :attribute string _data: Module build data cache for this build fetched from MBS

-     :attribute string _module_build_data: Verbose module build data cache for this build

      """

  

      def __init__(self, packaging_utility, mbs_api):
@@ -130,54 +127,76 @@ 

              _out=sys.stdout, _err=sys.stderr, _tee=True

          )

          self._mbs_api = mbs_api

-         self._data = None

-         self._component_data = None

-         self._build_id = None

-         self._module_build_data = None

  

      def run(self, *args, reuse=None):

-         """Run a module build

+         """Run one or more module builds

  

          :param args: Options and arguments for the build command

-         :param int reuse: Optional MBS build id to be reused for this run.

-             When specified, the corresponding module build will be used,

-             instead of triggering and waiting for a new one to finish.

+         :param int reuse: An optional MBS build id or a list of MBS build

+             ids to be reused for this run.

+             When specified, the corresponding module build(s) will be used,

+             instead of triggering and waiting for new one(s) to finish.

              Intended to be used while developing the tests.

-         :return: MBS build id of the build created

-         :rtype: int

+         :return: list of Build objects for the MBS builds created

+         :rtype: list of Build objects

          """

-         current_build_id = self._build_id

+         build_ids = []

+ 

          if reuse is not None:

-             self._build_id = int(reuse)

+             if isinstance(reuse, list):

+                 build_ids = reuse

+             else:

+                 build_ids = [reuse]

          else:

              stdout = self._packaging_utility("module-build", *args).stdout.decode("utf-8")

-             self._build_id = int(re.search(self._mbs_api + r"module-builds/(\d+)", stdout).group(1))

-         # Clear cached data

-         if current_build_id != self._build_id:

-             self._component_data = None

-         return self._build_id

+             build_ids = re.findall(self._mbs_api + r"module-builds/(\d+)", stdout)

+         return [Build(self._mbs_api, int(build_id)) for build_id in build_ids]

  

-     def watch(self):

-         """Watch the build till the finish"""

-         if self._build_id is None:

-             raise RuntimeError("Build was not started. Cannot watch.")

+     def watch(self, builds):

+         """Watch one or more builds till the finish

  

+         :param list builds: list of Build objects of the builds to be watched.

+         :return: Stdout of the watch command

+         :rtype: string

+         """

          stdout = self._packaging_utility(

-             "module-build-watch", str(self._build_id)

+             "module-build-watch", [str(build.id) for build in builds]

          ).stdout.decode("utf-8")

  

          return stdout

  

-     def cancel(self):

+     def cancel(self, build):

          """Cancel the module build

  

+         :param list build: the Build object of the module build to be cancelled.

          :return: Standard output of the "module-build-cancel <build id=""> command

          :rtype: str

          """

-         stdout = self._packaging_utility("module-build-cancel", self._build_id).stdout.decode(

+         stdout = self._packaging_utility("module-build-cancel", build.id).stdout.decode(

              "utf-8")

          return stdout

  

+ 

+ class Build:

+     """Wrapper class to work with module builds

+ 

+     :attribute string _mbs_api: URL of the MBS API (including trailing '/')

+     :attribute int _build_id: id of this MBS module build

+     :attribute string _data: Module build data cache for this build fetched from MBS

+     :attribute string _module_build_data: Verbose module build data cache for this build

+     """

+ 

+     def __init__(self, mbs_api, build_id):

+         self._mbs_api = mbs_api

+         self._data = None

+         self._component_data = None

+         self._build_id = build_id

+         self._module_build_data = None

+ 

+     @property

+     def id(self):

+         return self._build_id

+ 

      @property

      def data(self):

          """Module build data cache for this build fetched from MBS"""

Implement the Module Stream Expansion integration test.

rebased onto d2e2856de78cd10f57946f99d3fd9f154ad97813

4 years ago

rebased onto 0e43d9c5aaa82344e24a03ed375433aded0e687f

4 years ago

rebased onto 3f87a2bd3cff40314aefa030b917fd7a24e381a3

4 years ago

Build #734 failed (commit: 3f87a2bd3cff40314aefa030b917fd7a24e381a3).
Rebase or make new commits to rebuild.

rebased onto 16bd82ee8289ed41cf36409da2021f8954453f04

4 years ago

rebased onto 12f55890b5bc0ceb8515dde62e5735271d6f8988

4 years ago

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

rebased onto 7e4275a926dbfa34ce1197d3e5b09527309d2fea

4 years ago

Build #736 failed (commit: 7e4275a926dbfa34ce1197d3e5b09527309d2fea).
Rebase or make new commits to rebuild.

Should cancelling be implemented (as written in the test description)?

It might happen that we will need to wait some time before doing that.

We discussed with @mulaieva that we'll need to refactor the test env in order to make this test more streamlined. Work in progress...

Is test_stream_expansion.py going to have tests to cover all possible stream expansion combinations?

Is test_stream_expansion.py going to have tests to cover all possible stream expansion combinations?

Sorry. I don't understand what do you mean. Can you explain? Or give an example?

rebased onto aa0f862d27ecba3cda1508c6ae15ced3bf785389

4 years ago

2 new commits added

  • Factor out packaging utility
  • Module Stream Expansion integration test
4 years ago

Build #748 failed (commit: 61921893fcf0558fce801f163291a20f728d70be).
Rebase or make new commits to rebuild.

2 new commits added

  • Factor out packaging utility
  • Module Stream Expansion integration test
4 years ago

Build #751 failed (commit: fcf98010598060940450bdc55424a13f7cf3e7b9).
Rebase or make new commits to rebuild.

rebased onto d9117744dd6f7f1e0337bd4f0b2e7d6d6643d622

4 years ago

Build #752 failed (commit: 70eeaf754ef93d6bb96a3f0e57bb83e90516a63f).
Rebase or make new commits to rebuild.

3 new commits added

  • Revert "Module Stream Expansion integration test"
  • Module Stream Expansion integration test
  • Factor out packaging utility
4 years ago

2 new commits added

  • Module Stream Expansion integration test
  • Factor out packaging utility
4 years ago

1 new commit added

  • fixup! Module Stream Expansion integration test
4 years ago

2 new commits added

  • fixup! fixup! Module Stream Expansion integration test
  • Factor out packaging utility
4 years ago

2 new commits added

  • Implement the Stream Expansion scenario
  • Factor out packaging utility
4 years ago

Build #753 failed (commit: 4f771be9b40a9a685fb2753ec6a21669fff17e2e).
Rebase or make new commits to rebuild.

Build #754 failed (commit: 2cbda1304723f792a492cbc7c2a3377fe911576d).
Rebase or make new commits to rebuild.

Build #755 failed (commit: ec30948c05ef81fe12b22ed4500cb282376adeb0).
Rebase or make new commits to rebuild.

Build #756 failed (commit: ec30948c05ef81fe12b22ed4500cb282376adeb0).
Rebase or make new commits to rebuild.

1 new commit added

  • fixup! Implement the Stream Expansion scenario
4 years ago

2 new commits added

  • Implement the Stream Expansion scenario
  • Factor out packaging utility
4 years ago

Build #757 failed (commit: f4d7c3332b69c2f87c7e80744a224be9885529b8).
Rebase or make new commits to rebuild.

Build #758 failed (commit: 170488aa2a1d1f6bd84b34ca309101a549fb5466).
Rebase or make new commits to rebuild.

example.test.env.yaml should be also updated. Maybe also mention that for this scenario it doesn't make sense reusing a former build.

1 new commit added

  • fixup! Factor out packaging utility
4 years ago

rebased onto a447a447ae47b50bd2ef05771c220d8afe3a249a

4 years ago

Please do this @mulaieva :)

@csomh , done.
example.test.env.yaml is updated also.

Build #761 failed (commit: dcf3d4585f4ad99c721ec2f25f14c2a1ada5d1ab).
Rebase or make new commits to rebuild.

Build #762 failed (commit: 7d9fc0ab23c113c45258eb1a3ca2e441f04d051d).
Rebase or make new commits to rebuild.

rebased onto a5f6d8f

4 years ago

Commit 7f67c2f 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 #1493 successful (commit: fefeafa5)
4 years ago
jenkins
success (100%)
Build #1488 successful (commit: 7d9fc0ab)
4 years ago
jenkins
success (100%)
Build #1487 successful (commit: 7d9fc0ab)
4 years ago
c3i-jenkins
failure
Build #762 failed (commit: 7d9fc0ab)
4 years ago
c3i-jenkins
failure
Build #761 failed (commit: dcf3d458)
4 years ago
jenkins
success (100%)
Build #1484 successful (commit: 170488aa)
4 years ago
c3i-jenkins
failure
Build #758 failed (commit: 170488aa)
4 years ago
jenkins
success (100%)
Build #1483 successful (commit: f4d7c333)
4 years ago
c3i-jenkins
failure
Build #757 failed (commit: f4d7c333)
4 years ago
jenkins
failure
Build #1480 failed (commit: ec30948c)
4 years ago
jenkins
failure
Build #1482 failed (commit: ec30948c)
4 years ago
jenkins
failure
Build #1481 failed (commit: ec30948c)
4 years ago
c3i-jenkins
failure
Build #756 failed (commit: ec30948c)
4 years ago
c3i-jenkins
failure
Build #754 failed (commit: 2cbda130)
4 years ago
jenkins
success (100%)
Build #1479 successful (commit: 4f771be9)
4 years ago
jenkins
success (100%)
Build #1478 successful (commit: 4f771be9)
4 years ago
c3i-jenkins
failure
Build #753 failed (commit: 4f771be9)
4 years ago
jenkins
failure
Build #1477 failed (commit: 70eeaf75)
4 years ago
c3i-jenkins
failure
Build #752 failed (commit: 70eeaf75)
4 years ago
jenkins
success (100%)
Build #1476 successful (commit: fcf98010)
4 years ago
c3i-jenkins
failure
Build #751 failed (commit: fcf98010)
4 years ago
jenkins
failure
Build #1473 failed (commit: 61921893)
4 years ago
jenkins
error
Build #1472 aborted (commit: 61921893)
4 years ago
c3i-jenkins
failure
Build #748 failed (commit: 61921893)
4 years ago
jenkins
success (100%)
Build #1457 successful (commit: 7e4275a9)
4 years ago
jenkins
success (100%)
Build #1458 successful (commit: 7e4275a9)
4 years ago
c3i-jenkins
failure
Build #736 failed (commit: 7e4275a9)
4 years ago
jenkins
failure
Build #1456 failed (commit: 7e4275a9)
4 years ago
c3i-jenkins
failure
Build #735 failed (commit: 16bd82ee)
4 years ago
jenkins
failure
Build #1455 failed (commit: 16bd82ee)
4 years ago
c3i-jenkins
failure
Build #734 failed (commit: 3f87a2bd)
4 years ago
c3i-jenkins
success (100%)
Build #727 successful (commit: 0e43d9c5)
4 years ago
jenkins
success (100%)
Build #1447 successful (commit: 0e43d9c5)
4 years ago
jenkins
success (100%)
Build #1446 successful (commit: d2e2856d)
4 years ago
jenkins
failure
Build #1443 failed (commit: a7a42638)
4 years ago