Skip to content

Commit 22bee6e

Browse files
committed
tests: clean up logic for repositories in various test scenarios
* Always pull anaconda-core from COPR build from master branch, previously it was happening only if TEST_SCENARIO was not empty (fix for 082c360) * Add scenario for anaconda-webui PR * Rename build-rpms to vm.install as the RPMs even for anaconda-webui are conditionally built Document all options better.
1 parent 418391c commit 22bee6e

File tree

3 files changed

+101
-87
lines changed

3 files changed

+101
-87
lines changed

test/build-rpms

-84
This file was deleted.

test/prepare-updates-img

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ set -eu
44

55
TEST_RPMS="${TEST_RPMS:-""}"
66

7-
# build the anaconda-webui rpm && download anaconda-webui missing dependencies
8-
make srpm
9-
test/build-rpms -v anaconda-webui*.src.rpm
7+
# Prepare tmp/rpms folder with anaconda-webui missing dependencies
8+
test/vm.install -v
109

1110
# Copy the extra RPMs to the /tmp/rpms directory
1211
for i in ${TEST_RPMS//,/ }; do

test/vm.install

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env python3
2+
3+
# derived from test/image-prepare in cockpit-project/cockpit
4+
5+
import argparse
6+
import glob
7+
import os
8+
import shutil
9+
import subprocess
10+
import sys
11+
12+
BOTS_DIR = os.path.realpath(f'{__file__}/../../bots')
13+
sys.path.append(BOTS_DIR)
14+
15+
missing_packages = "cockpit-ws cockpit-bridge cockpit-storaged fedora-logos"
16+
# Install missing firefox dependencies.
17+
# Resolving all dependencies with dnf download is possible,
18+
# but it packs to many packages to updates.img
19+
missing_packages_incl_deps = "firefox"
20+
21+
from machine.machine_core import machine_virtual # NOQA: imported through parent.py
22+
23+
24+
def vm_install(image, verbose, quick):
25+
subprocess.check_call([os.path.join(BOTS_DIR, "image-download"), image])
26+
machine = machine_virtual.VirtMachine(image=image)
27+
packages_to_download = missing_packages + " anaconda-core";
28+
try:
29+
machine.start()
30+
machine.wait_boot()
31+
32+
scenario = os.environ.get("TEST_SCENARIO")
33+
# Pull cockpit dependencies from the image default compose
34+
# unless we are testing a PR on cockpit-project/cockpit, then pull it from the PR COPR repo
35+
if scenario and scenario.startswith("cockpit-pr-"):
36+
cockpit_pr = scenario.split("-")[-1]
37+
machine.execute(f"dnf copr enable -y packit/cockpit-project-cockpit-{cockpit_pr}", stdout=sys.stdout)
38+
39+
# Build anaconda-webui from SRPM unless we are testing a anaconda-webui PR scenario
40+
# from a different repo, then pull it from the anaconda-webui PR COPR repo
41+
if not scenario or not scenario.startswith("anaconda-webui-pr-"):
42+
subprocess.run(["rm", "anaconda-webui-*.rpm anaconda-webui-*.tar.xz"])
43+
subprocess.run(["make", "srpm"])
44+
srpm = glob.glob("anaconda-webui*.src.rpm")[0]
45+
machine.execute("su builder -c 'mkdir -p /var/tmp/build/SRPMS'")
46+
vm_srpm = os.path.join("/var/tmp/build/SRPMS", os.path.basename(srpm))
47+
machine.upload([os.path.realpath(srpm)], vm_srpm)
48+
49+
# build rpms
50+
mock_opts = ("--verbose" if verbose else "") + (" --nocheck" if quick else "")
51+
machine.execute("su builder -c 'mock --no-clean --disablerepo=* --offline --resultdir /var/tmp/build "
52+
f"{mock_opts} --rebuild /var/tmp/build/SRPMS/*.src.rpm'", timeout=1800)
53+
else:
54+
anaconda_webui_pr = scenario.split("-")[-1]
55+
machine.execute(f"dnf copr enable -y packit/rhinstaller-anaconda-webui-{anaconda_webui_pr}", stdout=sys.stdout)
56+
packages_to_download += f" anaconda-webui"
57+
58+
# Pull anaconda-core from the COPR repo packit builds from master branch
59+
# unless we are testing a PR on rhinstaller/anaconda, then pull it from the PR COPR repo
60+
if not scenario or not scenario.startswith("anaconda-pr-"):
61+
machine.execute(f"dnf copr enable -y @rhinstaller/Anaconda ", stdout=sys.stdout)
62+
else:
63+
anaconda_pr = scenario.split("-")[-1]
64+
machine.execute(f"dnf copr enable -y packit/rhinstaller-anaconda-{anaconda_pr}", stdout=sys.stdout)
65+
66+
# Download missing dependencies rpms
67+
# FIXME boot.iso on rawhide does not currently contain the new anaconda-webui dependencies
68+
# This will change once we include this changes upstream and start building boot.iso with the new dependencies
69+
# Then we can enable this only for the various scenarios above
70+
machine.execute(f"dnf download --destdir /var/tmp/build/ {packages_to_download}", stdout=sys.stdout, timeout=300)
71+
machine.execute(f"dnf download --resolve --destdir /var/tmp/build/ {missing_packages_incl_deps}", stdout=sys.stdout, timeout=300)
72+
73+
# download rpms
74+
vm_rpms = machine.execute("find /var/tmp/build -name '*.rpm' -not -name '*.src.rpm'").strip().split()
75+
76+
destdir = os.path.abspath("tmp/rpms")
77+
if os.path.exists(destdir):
78+
shutil.rmtree(destdir)
79+
os.makedirs(destdir)
80+
81+
rpms = []
82+
for rpm in vm_rpms:
83+
machine.download(rpm, destdir)
84+
rpms.append(os.path.join(destdir, os.path.basename(rpm)))
85+
return rpms
86+
finally:
87+
machine.stop()
88+
89+
90+
def main():
91+
parser = argparse.ArgumentParser()
92+
parser.add_argument('--quick', '-q', action='store_true')
93+
parser.add_argument('--verbose', '-v', action='store_true')
94+
parser.add_argument('--image', default='fedora-rawhide')
95+
args = parser.parse_args()
96+
97+
vm_install(args.image, args.verbose, args.quick)
98+
99+
main()

0 commit comments

Comments
 (0)