Skip to content

Commit

Permalink
Fix proxy-auth and proxy-kickstart tests
Browse files Browse the repository at this point in the history
This covers issues rhinstaller#680 and rhinstaller#1108.
  • Loading branch information
jikortus committed Jun 11, 2024
1 parent 6ee065f commit 548913b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
2 changes: 0 additions & 2 deletions containers/runner/skip-testtypes
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ fedora_skip_array=(
gh576 # clearpart-4 test is flaky on all scenarios
gh595 # proxy-cmdline failing on all scenarios
gh641 # packages-multilib failing on systemd conflict
gh680 # proxy-kickstart and proxy-auth failing
gh774 # autopart-luks-1 failing
gh777 # raid-1-reqpart failing
gh910 # stage2-from-ks test needs to be fixed for daily-iso
Expand Down Expand Up @@ -65,7 +64,6 @@ rhel10_skip_array=(
gh804 # tests requiring dvd iso failing
gh1090 # raid-1-reqpart failing
gh1104 # network-prefixdevname failing
gh1108 # proxy-auth, proxy-kickstart failing
gh1107 # rpm-ostree-container failing
gh1110 # storage-multipath-autopart failing
gh1178 # tests using ext2 failing
Expand Down
29 changes: 23 additions & 6 deletions proxy-auth.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,43 @@ if [[ ! -f /mnt/sysroot/etc/yum.repos.d/addon.repo ]]; then
fi

# Check that the proxy configuration was written to the repo file
grep -q 'proxy=http://anaconda:qweqwe@PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
if [[ $? -ne 0 ]]; then
# The repo configuration has a different format on RHEL-10+/Fedora 40+
os_name="@KSTEST_OS_NAME@"
os_version="@KSTEST_OS_VERSION@"
os_major=${os_version%%.*}

if [ "${os_name}" == "rhel" ] && [ ${os_major} -lt 10 ]; then
grep -q 'proxy=http://anaconda:qweqwe@PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
proxy_rc=$?
else
grep -qP 'proxy\s?=\s?http://PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo && \
grep -qP 'proxy_username\s?=\s?anaconda' /mnt/sysroot/etc/yum.repos.d/addon.repo && \
grep -qP 'proxy_password\s?=\s?qweqwe' /mnt/sysroot/etc/yum.repos.d/addon.repo
proxy_rc=$?
fi
if [[ ${proxy_rc} -ne 0 ]]; then
echo 'addon.repo does not contain proxy information' >> /mnt/sysroot/root/RESULT
echo "/etc/yum.repos.d/addon.repo content:" >> /mnt/sysroot/root/RESULT
cat /mnt/sysroot/etc/yum.repos.d/addon.repo >> /mnt/sysroot/root/RESULT
echo >> /mnt/sysroot/root/RESULT

fi

# Check that the installed repo file is usable
# Find if this is using yum or dnf
if [[ -f /mnt/sysroot/usr/bin/dnf ]]; then
BIN="dnf"
BIN="dnf"
else
BIN="yum"
BIN="yum"
fi

# Clean packages to force package download
chroot /mnt/sysroot $BIN clean packages

# Download package to test if the installed repository is usable
chroot /mnt/sysroot \
$BIN --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
reinstall mandatory-package-from-addon 2>/dev/null | \
$BIN reinstall --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
mandatory-package-from-addon 2>/dev/null | \
grep -q 'mandatory-package-from-addon'
if [[ $? -ne 0 ]]; then
echo 'unable to query addon repo' >> /mnt/sysroot/root/RESULT
Expand Down
4 changes: 3 additions & 1 deletion proxy-auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Ignore unused variable parsed out by tooling scripts as test tags metadata
# shellcheck disable=SC2034
TESTTYPE="method proxy gh680 gh1108"
TESTTYPE="method proxy"

. ${KSTESTDIR}/functions.sh
. ${KSTESTDIR}/functions-proxy.sh
Expand All @@ -29,6 +29,8 @@ prepare() {
local tmp_dir=$2
local httpd_url=""
local proxy_url=""
httpd_url=$(cat ${tmpdir}/httpd_url)
proxy_url=$(cat ${tmpdir}/proxy_url)
mkdir "${tmp_dir}/http"

# Create the addon repository.
Expand Down
13 changes: 8 additions & 5 deletions proxy-kickstart.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,28 @@ if [[ ! -f /mnt/sysroot/etc/yum.repos.d/addon.repo ]]; then
fi

# Check that the proxy configuration was written to the repo file
grep -q 'proxy=PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
grep -qP 'proxy\s?=\s?PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
if [[ $? -ne 0 ]]; then
echo 'addon.repo does not contain proxy information' >> /mnt/sysroot/root/RESULT
echo "/etc/yum.repos.d/addon.repo content:" >> /mnt/sysroot/root/RESULT
cat /mnt/sysroot/etc/yum.repos.d/addon.repo >> /mnt/sysroot/root/RESULT
echo >> /mnt/sysroot/root/RESULT
fi

# Check that the installed repo file is usable
# Find if this is using yum or dnf
if [[ -f /mnt/sysroot/usr/bin/dnf ]]; then
BIN="dnf"
BIN="dnf"
else
BIN="yum"
BIN="yum"
fi

# Clean packages to force package download
chroot /mnt/sysroot $BIN clean packages
# Download package to test if the installed repository is usable
chroot /mnt/sysroot \
$BIN --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
reinstall mandatory-package-from-addon 2>/dev/null | \
$BIN reinstall --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
mandatory-package-from-addon 2>/dev/null | \
grep -q 'mandatory-package-from-addon'
if [[ $? -ne 0 ]]; then
echo 'unable to query addon repo' >> /mnt/sysroot/root/RESULT
Expand Down
6 changes: 4 additions & 2 deletions proxy-kickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Ignore unused variable parsed out by tooling scripts as test tags metadata
# shellcheck disable=SC2034
TESTTYPE="method proxy gh680 gh1108"
TESTTYPE="method proxy"

. ${KSTESTDIR}/functions.sh
. ${KSTESTDIR}/functions-proxy.sh
Expand All @@ -30,6 +30,8 @@ prepare() {
local tmp_dir=$2
local httpd_url=""
local proxy_url=""
httpd_url=$(cat ${tmpdir}/httpd_url)
proxy_url=$(cat ${tmpdir}/proxy_url)
mkdir "${tmp_dir}/http"

# Create the addon repository.
Expand All @@ -52,7 +54,7 @@ prepare() {
# Substitute variables in the kickstart file.
sed -e "/^repo/ s|HTTP-ADDON-REPO|${httpd_local_url}|" \
-re "/^(repo|url)/ s|PROXY-ADDON|${proxy_url}|" \
-e "/'proxy=/ s|PROXY-ADDON|${proxy_url%%/*}|" \
-e "/'proxy\\\\s\?=/ s|PROXY-ADDON|${proxy_url%/*}|" \
"${ks}" > "${tmp_dir}/ks.cfg"

echo "${tmp_dir}/ks.cfg"
Expand Down

0 comments on commit 548913b

Please sign in to comment.