Tests: separate starting and watching the builds

This makes the tests more explicit, but also prepares the ground to
enable canceling test builds during session teardown in the future.

Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
This commit is contained in:
Hunor Csomortáni
2019-12-06 12:25:07 +01:00
parent 72bb5a2943
commit 343f1b9818
4 changed files with 15 additions and 5 deletions

View File

@@ -16,12 +16,11 @@ def test_failed_build(test_env, repo, koji):
build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])
repo.bump()
build.run(
"--watch",
"--scratch",
"--optional",
"rebuild_strategy=all",
reuse=test_env["testdata"]["failed_build"].get("build_id"),
)
build.watch()
assert build.state_name == "failed"
batch = test_env["testdata"]["failed_build"]["batch"]

View File

@@ -20,12 +20,12 @@ def test_normal_build(test_env, repo, koji):
build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])
repo.bump()
build_id = build.run(
"--watch",
"--scratch",
"--optional",
"rebuild_strategy=all",
reuse=test_env["testdata"]["normal_build"].get("build_id"),
)
build.watch()
assert sorted(build.component_names()) == sorted(repo.components + ["module-build-macros"])
expected_buildorder = test_env["testdata"]["normal_build"]["buildorder"]

View File

@@ -16,12 +16,12 @@ def test_scratch_build(test_env, repo, koji):
"""
build = utils.Build(test_env["packaging_utility"], test_env["mbs_api"])
build.run(
"--watch",
"--scratch",
"--optional",
"rebuild_strategy=all",
reuse=test_env["testdata"]["scratch_build"].get("build_id"),
)
build.watch()
assert build.state_name == "done"
assert sorted(build.component_names(state="COMPLETE")) == sorted(

View File

@@ -154,6 +154,17 @@ class Build:
self._build_id = int(re.search(self._mbs_api + r"module-builds/(\d+)", stdout).group(1))
return self._build_id
def watch(self):
"""Watch the build till the finish"""
if self._build_id is None:
raise RuntimeError("Build was not started. Cannot watch.")
stdout = self._packaging_utility(
"module-build-watch", str(self._build_id)
).stdout.decode("utf-8")
return stdout
def cancel(self):
"""Cancel the module build