Skip to content

Commit a92fb91

Browse files
committed
Add additional repository support
Make it possible to add additional repo for a kickstart test run. At the moment we assume the repository is a regular RPM repository, as for example created by running createrepo_c on a directory containing a bunch of RPMs. The main aim of this functionality is to make it possible to add additional packages to the RPM transaction Anaconda runs during a regular RPM based installation. Also by adding packages with a higher version number than those in the normal package repositories it is possible to override them with the package from the additional repo. This can be useful to test Anaconda and/or Initial Setup scratchbuilds. To use this feature use the -a or --additional-repo flag to the appropriate runner script and pass either a local filesystem path to a RPM repository or to a remote RPM repository. If a local path is detected a localhost web server on the runner will be used to serve the repo folder to the VM running the test. If a remote path to a RPM repository is passed, it will be passed directly to the VM. In both cases the additional repositories are passed via the inst.addrepo boot option as "inst.addrepo=KSTEST_ADDITIONAL_REPOSITORY,<repo_path>".
1 parent 1d0985d commit a92fb91

6 files changed

Lines changed: 67 additions & 7 deletions

File tree

containers/runner/launch

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Options:
3434
-t, --testtype TYPE Only run TYPE tests
3535
-s, --skip-testtypes TYPE[,TYPE..] Don't run tests with given types
3636
-u, --updates PATH|URL Set updates.img path or URL
37+
-a, --additional-repo PATH|URL Set additional repo path or URL
3738
-r, --retry Retry failed tests once, to guard against random
3839
infrastructure failures
3940
--daily-iso TOKEN_FILE Download and use daily boot.iso instead of rawhide's
@@ -46,7 +47,7 @@ EOF
4647
}
4748

4849
# parse options
49-
eval set -- "$(getopt -o j:p:t:s:u:rh --long jobs:,platform:,testtype:,skip-testtypes:,updates:,retry,daily-iso:,defaults:,run-args:,help -- "$@")"
50+
eval set -- "$(getopt -o j:p:t:s:u:a:rh --long jobs:,platform:,testtype:,skip-testtypes:,updates:additional-repo:,retry,daily-iso:,defaults:,run-args:,help -- "$@")"
5051

5152
while true; do
5253
case "${1:-}" in
@@ -55,6 +56,7 @@ while true; do
5556
-t|--testtype) shift; TESTTYPE="$1" ;;
5657
-s|--skip-testtypes) shift; SKIP_TESTTYPES="$1" ;;
5758
-u|--updates) shift; UPDATES_IMAGE="$1" ;;
59+
-a|--additional-repo) shift; ADDITIONAL_REPO="$1" ;;
5860
-r|--retry) TEST_RETRY=1 ;;
5961
--daily-iso) shift; DAILY_ISO_TOKEN="$1" ;;
6062
--defaults) shift; DEFAULTS_SH="$1" ;;
@@ -103,6 +105,15 @@ elif [ -n "${UPDATES_IMAGE:-}" ]; then
103105
UPDATES_IMG_ARGS="--env UPDATES_IMAGE=$UPDATES_IMAGE"
104106
fi
105107

108+
# support both path and URL for additional repo
109+
if [ -e "${ADDITIONAL_REPO:-}" ]; then
110+
# local folder; bind mount into container
111+
ADDITIONAL_REPO_ARGS="-v $ADDITIONAL_REPO:/kstest_additional_repo:ro,Z --env ADDITIONAL_REPO=/kstest_additional_repo"
112+
elif [ -n "${ADDITIONAL_REPO:-}" ]; then
113+
# URL, pass through
114+
ADDITIONAL_REPO_ARGS="--env ADDITIONAL_REPO=$ADDITIONAL_REPO"
115+
fi
116+
106117
if [ -n "${DEFAULTS_SH:-}" ]; then
107118
DEFAULTS_SH_ARGS="-v $DEFAULTS_SH:/home/kstest/.kstests.defaults.sh:ro,z"
108119
fi
@@ -126,6 +137,7 @@ fi
126137
set -x
127138
$CRUN run -it --rm --device=/dev/kvm --publish 127.0.0.1::16509 $PODMAN_SELINUX_FIX \
128139
--env KSTESTS_TEST="$KSTESTS_TEST" --env TESTTYPE="${TESTTYPE:-}" --env SKIP_TESTTYPES="${SKIP_TESTTYPES:-}" \
129-
--env TEST_JOBS="$TEST_JOBS" --env PLATFORM="${PLATFORM:-}" --env TEST_RETRY="${TEST_RETRY:-}" ${UPDATES_IMG_ARGS:-} ${CONTAINER_RUN_ARGS:-} \
140+
--env TEST_JOBS="$TEST_JOBS" --env PLATFORM="${PLATFORM:-}" --env TEST_RETRY="${TEST_RETRY:-}" \
141+
${UPDATES_IMG_ARGS:-} ${ADDITIONAL_REPO_ARGS:-} ${CONTAINER_RUN_ARGS:-} \
130142
${VAR_TMP:-} -v "$PWD/data:/opt/kstest/data:z" -v "$BASEDIR:/kickstart-tests:ro,z" ${DEFAULTS_SH_ARGS:-} \
131143
$CONTAINER /kickstart-tests/containers/runner/run-kstest

containers/runner/run-kstest

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ if [ -n "${UPDATES_IMAGE}" ]; then
3030
UPDATES_IMAGE_ARG="-u ${UPDATES_IMAGE}"
3131
fi
3232

33+
ADDITIONAL_REPO_ARG=""
34+
if [ -n "${ADDITIONAL_REPO}" ]; then
35+
ADDITIONAL_REPO_ARG="-a ${ADDITIONAL_REPO}"
36+
fi
37+
3338
PLATFORM_ARG=""
3439
if [ -n "${PLATFORM}" ]; then
3540
PLATFORM_ARG="-p ${PLATFORM}"
@@ -74,7 +79,7 @@ fi
7479
TEST_LOG=/var/tmp/kstest.log
7580
pushd ${KSTESTS_DIR}
7681
set +e
77-
scripts/run_kickstart_tests.sh -k ${KSTESTS_KEEP} -i ${ISO_DIR}/${BOOT_ISO} ${UPDATES_IMAGE_ARG} ${PLATFORM_ARG} ${TESTTYPE_ARG} ${SKIP_TESTTYPES_ARG} ${RETRY_ARG} ${KSTESTS_TEST} 2>&1 | tee $TEST_LOG
82+
scripts/run_kickstart_tests.sh -k ${KSTESTS_KEEP} -i ${ISO_DIR}/${BOOT_ISO} ${UPDATES_IMAGE_ARG} ${ADDITIONAL_REPO_ARG} ${PLATFORM_ARG} ${TESTTYPE_ARG} ${SKIP_TESTTYPES_ARG} ${RETRY_ARG} ${KSTESTS_TEST} 2>&1 | tee $TEST_LOG
7883
RC=$?
7984
set -e
8085
popd

scripts/launcher/lib/conf/configuration.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __init__(self):
8383
self._image_path = ""
8484
self._keep_option = KeepLevel.NOTHING
8585
self._updates_img_path = ""
86+
self._additional_repo_path = ""
8687
self._append_host_id = False
8788
self._hung_task_timeout_secs = 1200
8889

@@ -138,6 +139,14 @@ def updates_img_path(self):
138139
def updates_img_path(self, val):
139140
self._updates_img_path = val
140141

142+
@property
143+
def additional_repo_path(self):
144+
return self._additional_repo_path
145+
146+
@additional_repo_path.setter
147+
def additional_repo_path(self, val):
148+
self._additional_repo_path = val
149+
141150
@property
142151
def script_path(self):
143152
path = os.path.join(__file__, "..")

scripts/launcher/lib/conf/runner_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def _configure_parser(self):
8585
self._parser.add_argument("--updates", '-u', metavar="Path",
8686
type=str, dest="updates_path",
8787
help="Updates image path used in the test")
88+
self._parser.add_argument("--additional_repo", '-a', metavar="Path",
89+
type=str, dest="additional_repo_path",
90+
help="Additionl repo path used in the test")
8891
self._parser.add_argument("--append-host-id", default=False, action="store_true",
8992
dest="append_host_id",
9093
help="append an id of the host running the test to the result")
@@ -115,6 +118,9 @@ def get_configuration(self):
115118
if ns.updates_path:
116119
conf.updates_img_path = ns.updates_path
117120

121+
if ns.additional_repo_path:
122+
conf.additional_repo_path = ns.additional_repo_path
123+
118124
if ns.append_host_id:
119125
conf.append_host_id = ns.append_host_id
120126

scripts/launcher/run_one_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ def _create_virtual_conf(self, log_path) -> VirtualConfiguration:
135135
if self._conf.updates_img_path:
136136
kernel_args += " inst.updates={}".format(self._conf.updates_img_path)
137137

138+
if self._conf.additional_repo_path:
139+
kernel_args += " inst.addrepo=KSTEST_ADDITIONAL_REPO,{}".format(self._conf.additional_repo_path)
140+
138141
if self._conf.hung_task_timeout_secs:
139142
kernel_args += " inst.kernel.hung_task_timeout_secs={}".format(
140143
self._conf.hung_task_timeout_secs)

scripts/run_kickstart_tests.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ KEEPIT=${KEEPIT:-0}
6161
# responsibility, this can break tests.
6262
UPDATES_IMG=""
6363

64+
# Local or remote path to an additional repo that will be added for the installation transaction.
65+
ADDITIONAL_REPO=""
66+
6467
TESTTYPE=""
6568
SKIP_TESTTYPES=""
6669

67-
while getopts ":i:k:t:s:u:b:p:o:r" opt; do
70+
while getopts ":i:k:t:s:u:a:b:p:o:r" opt; do
6871
case $opt in
6972
i)
7073
# If this wasn't set from the environment, set it from the command line
@@ -97,6 +100,12 @@ while getopts ":i:k:t:s:u:b:p:o:r" opt; do
97100
# This may not be compatible with all the tests.
98101
UPDATES_IMG=$OPTARG
99102
;;
103+
a)
104+
# Path to a RPM repo on a server or in local directory. This will be added as
105+
# a kernel parameter inst.addrepo=KSTEST_ADDITIONAL_REPO,<server> to the VM boot options.
106+
# This may not be compatible with all the tests.
107+
ADDITIONAL_REPO=$OPTARG
108+
;;
100109
b)
101110
# Use additional boot options. Will be added to kernel_args from .sh file.
102111
BOOT_ARGS=$OPTARG
@@ -118,7 +127,7 @@ while getopts ":i:k:t:s:u:b:p:o:r" opt; do
118127
RETRY=--retry
119128
;;
120129
*)
121-
echo "Usage: run_kickstart_tests.sh [-i boot.iso] [-k 0|1|2] [-t test_type_to_run] [-s test_types_to_ignore] [-u link_to_updates.img] [-b additional_boot_options] [-p platform_name] [-o ksappend_overrides] [tests]"
130+
echo "Usage: run_kickstart_tests.sh [-i boot.iso] [-k 0|1|2] [-t test_type_to_run] [-s test_types_to_ignore] [-u link_to_updates.img] [-a local_or_remote_repo_path] [-b additional_boot_options] [-p platform_name] [-o ksappend_overrides] [tests]"
122131
exit 1
123132
;;
124133
esac
@@ -351,6 +360,22 @@ if [[ -n "$UPDATES_IMG" ]]; then
351360
UPDATES_ARG="-u ${UPDATES_IMG}"
352361
fi
353362
363+
# set up additional package repo
364+
ADDITIONAL_REPO_ARG=""
365+
if [[ -n "$ADDITIONAL_REPO" ]]; then
366+
if [ -e "$ADDITIONAL_REPO" ]; then
367+
# set up a local web server for the local runner local
368+
# folder containing the repo
369+
python3 -m http.server --directory ${ADDITIONAL_REPO} 9999 &
370+
# stop it when this script exits
371+
trap "kill $!" EXIT INT QUIT PIPE
372+
# SLIRP networking address as seem from QEMU guests
373+
ADDITIONAL_REPO="http://10.0.2.2:9999/${ADDITIONAL_REPO}"
374+
fi
375+
376+
ADDITIONAL_REPO_ARG="-a ${ADDITIONAL_REPO}"
377+
fi
378+
354379
BOOT_ARG=""
355380
if [[ -n "$BOOT_ARGS" ]]; then
356381
BOOT_ARG="-b \"${BOOT_ARGS}\""
@@ -416,7 +441,7 @@ if [[ "$TEST_REMOTES" != "" ]]; then
416441
-i ../install_images/${_IMAGE} \
417442
-k ${KEEPIT} \
418443
--append-host-id \
419-
${RETRY} ${UPDATES_ARG} ${BOOT_ARG} {} ::: ${tests}
444+
${RETRY} ${UPDATES_ARG} ${ADDITIONAL_REPO_ARG} ${BOOT_ARG} {} ::: ${tests}
420445
rc=$?
421446
cd -
422447
@@ -448,7 +473,7 @@ else
448473
-i ${IMAGE} \
449474
-k ${KEEPIT} \
450475
--append-host-id \
451-
${RETRY} ${UPDATES_ARG} ${BOOT_ARG} {} ::: ${tests}
476+
${RETRY} ${UPDATES_ARG} ${ADDITIONAL_REPO_ARG} ${BOOT_ARG} {} ::: ${tests}
452477
rc=$?
453478
fi
454479

0 commit comments

Comments
 (0)