Skip to content

Commit

Permalink
Merge pull request #1210 from rvykydal/hdd-part-test
Browse files Browse the repository at this point in the history
Add harddrive-iso-single test and "harddrive" tests updates
  • Loading branch information
rvykydal authored Jun 28, 2024
2 parents 08b5c95 + 179676c commit 2d4430e
Show file tree
Hide file tree
Showing 18 changed files with 143 additions and 16 deletions.
1 change: 1 addition & 0 deletions containers/runner/skip-testtypes
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ rhel10_skip_array=(
gh1110 # storage-multipath-autopart failing
gh1178 # tests using ext2 failing
gh1207 # packages-multilib failing
gh1213 # harddrive-iso-single failing
)

# used in workflows/daily-boot-iso-rhel8.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Create a variable in the pre/post section with link to a Fedora rawhide server DVD.
# The curl tool will download this ISO and it will be processed later in the section.
_LINK="http://ftp.tu-chemnitz.de/pub/linux/fedora/linux/development/rawhide/Server/x86_64/iso"
#_LINK="http://ftp.tu-chemnitz.de/pub/linux/fedora/linux/development/rawhide/Server/x86_64/iso"
REPO_URL=@KSTEST_URL@
_LINK=${REPO_URL%Everything/x86_64/os/}Server/x86_64/iso/
ISO_LOCATION="$(curl -L $_LINK | grep -Po "Fedora-Server-dvd-x86_64-.*?.iso" | head -n 1)"
ISO_LOCATION="${_LINK}/${ISO_LOCATION}"

Expand Down
4 changes: 3 additions & 1 deletion fragments/platform/rhel10/section-data/server-dvd-link.ks
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Create a variable in the pre/post section with link to a RHEL DVD.
# The curl tool will download this ISO and it will be processed later in the section.
_LINK=<ADD_LINK_TO_RHEL-10_ISO_HERE>
#_LINK=<ADD_LINK_TO_RHEL-10_ISO_HERE>
REPO_URL=@KSTEST_URL@
_LINK=${REPO_URL%os/}iso/
ISO_LOCATION="$(curl -L $_LINK | grep -Po "RHEL-10.*?-x86_64-dvd1.iso" | head -n 1)"
ISO_LOCATION="${_LINK}/${ISO_LOCATION}"

Expand Down
4 changes: 3 additions & 1 deletion fragments/platform/rhel8/section-data/server-dvd-link.ks
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Create a variable in the pre/post section with link to a RHEL DVD.
# The curl tool will download this ISO and it will be processed later in the section.
_LINK=<ADD_LINK_TO_RHEL-8_ISO_HERE>
#_LINK=<ADD_LINK_TO_RHEL-8_ISO_HERE>
REPO_URL=@KSTEST_URL@
_LINK=${REPO_URL%os/}iso/
ISO_LOCATION="$(curl -L $_LINK | grep -Po "RHEL-8.*?-x86_64-dvd1.iso" | head -n 1)"
ISO_LOCATION="${_LINK}/${ISO_LOCATION}"

Expand Down
4 changes: 3 additions & 1 deletion fragments/platform/rhel9/section-data/server-dvd-link.ks
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Create a variable in the pre/post section with link to a RHEL DVD.
# The curl tool will download this ISO and it will be processed later in the section.
_LINK=<ADD_LINK_TO_RHEL-9_ISO_HERE>
#_LINK=<ADD_LINK_TO_RHEL-9_ISO_HERE>
REPO_URL=@KSTEST_URL@
_LINK=${REPO_URL%os/}iso/
ISO_LOCATION="$(curl -L $_LINK | grep -Po "RHEL-9.*?-x86_64-dvd1.iso" | head -n 1)"
ISO_LOCATION="${_LINK}/${ISO_LOCATION}"

Expand Down
3 changes: 3 additions & 0 deletions harddrive-install-tree-relative.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ harddrive --partition=/dev/vdb --dir=repo/
DISK="/dev/vdb"
DIRECTORY="repo"

# Prepare storage for the source
format_whole_disk "${DISK}"

# Download the content of the ISO.
prepare_tree "${ISO_LOCATION}" "${DISK}" "${DIRECTORY}"
%end
Expand Down
2 changes: 1 addition & 1 deletion harddrive-install-tree-relative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# SourceSetupError: Nothing useful found for Hard drive ISO source at partition=/dev/sdb directory=/repo/
# Ignore unused variable parsed out by tooling scripts as test tags metadata
# shellcheck disable=SC2034
TESTTYPE="packaging gh804"
TESTTYPE="packaging harddrive gh804"

. ${KSTESTDIR}/harddrive-install-tree.sh

3 changes: 3 additions & 0 deletions harddrive-install-tree.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ harddrive --partition=/dev/vdb --dir=/repo/
DISK="/dev/vdb"
DIRECTORY="repo"

# Prepare storage for the source
format_whole_disk "${DISK}"

# Download the content of the ISO.
prepare_tree "${ISO_LOCATION}" "${DISK}" "${DIRECTORY}"
%end
Expand Down
8 changes: 6 additions & 2 deletions harddrive-install-tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@
# SourceSetupError: Nothing useful found for Hard drive ISO source at partition=/dev/sdb directory=/repo/
# Ignore unused variable parsed out by tooling scripts as test tags metadata
# shellcheck disable=SC2034
TESTTYPE=${TESTTYPE:-"packaging gh804"}
TESTTYPE=${TESTTYPE:-"packaging harddrive gh804"}

. ${KSTESTDIR}/functions.sh

prepare_disks() {
tmpdir=$1

qemu-img create -q -f qcow2 ${tmpdir}/disk-a.img 10G
qemu-img create -q -f qcow2 ${tmpdir}/disk-b.img 12G
qemu-img create -q -f qcow2 ${tmpdir}/disk-b.img 22G

echo ${tmpdir}/disk-a.img ${tmpdir}/disk-b.img
}

get_timeout() {
echo "45"
}
38 changes: 38 additions & 0 deletions harddrive-iso-single.ks.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#version=DEVEL
#test name: harddrive-iso-single

# This test is for testing the install from an harddrive ks command with ISO
# using single disk (RHEL-35701).
#
# Server dvd is downloaded during the test execution. This test can be resource demanding!
#
%ksappend common/common_no_storage_and_payload.ks

zerombr
clearpart --all --initlabel --drives=/dev/vda
autopart

harddrive --partition=/dev/vda1 --dir=/

%ksappend payload/default_packages.ks

%pre
# Include helpful functions.
@KSINCLUDE@ pre-lib-harddrive.sh

# This will add ISO_LOCATION with link to an ISO
%ksappend section-data/server-dvd-link.ks

# Where we want to download the ISO?
DISK="/dev/vda"

# Prepare storage for the source
format_single_partition "${DISK}" 12GiB

# Download and mount the ISO.
prepare_iso "${ISO_LOCATION}" "${DISK}1"
%end

%post
%ksappend validation/success_if_result_empty.ks
%end
36 changes: 36 additions & 0 deletions harddrive-iso-single.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright (C) 2024 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
# Red Hat Author(s): Radek Vykydal <[email protected]>

# Ignore unused variable parsed out by tooling scripts as test tags metadata
# shellcheck disable=SC2034
TESTTYPE=${TESTTYPE:-"packaging harddrive gh804 gh1213"}

. ${KSTESTDIR}/functions.sh

prepare_disks() {
tmpdir=$1

qemu-img create -q -f qcow2 ${tmpdir}/disk-a.img 22G

echo ${tmpdir}/disk-a.img
}

get_timeout() {
echo "45"
}
3 changes: 3 additions & 0 deletions harddrive-iso.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ harddrive --partition=/dev/vdb --dir=/
# Where we want to download the ISO?
DISK="/dev/vdb"

# Prepare storage for the source
format_whole_disk "${DISK}"

# Download and mount the ISO.
prepare_iso "${ISO_LOCATION}" "${DISK}"
%end
Expand Down
2 changes: 1 addition & 1 deletion harddrive-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

# Ignore unused variable parsed out by tooling scripts as test tags metadata
# shellcheck disable=SC2034
TESTTYPE=${TESTTYPE:-"packaging gh804"}
TESTTYPE=${TESTTYPE:-"packaging harddrive gh804"}

. ${KSTESTDIR}/harddrive-install-tree.sh
33 changes: 25 additions & 8 deletions pre-lib-harddrive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ MOUNT_DIR="/var/tmp/prep-mount"
# Download the ISO on a hard drive.
function prepare_iso() {
local url="$1"
local disk="$2"
local device="$2"

wipefs -a "${disk}"
mkfs.ext4 -F "${disk}"
mkdir "${MOUNT_DIR}"
pushd "${MOUNT_DIR}"

# Mount the new source
mkdir hdd-mount
mount "${disk}" hdd-mount
mount "${device}" hdd-mount

# Download iso to the DVD
curl -L "${url}" -o hdd-mount/dvd.iso
Expand All @@ -29,15 +27,13 @@ function prepare_iso() {
# Download the content of the ISO on a hard drive.
function prepare_tree() {
local url="$1"
local disk="$2"
local device="$2"
local directory="$3"

wipefs -a "${disk}"
mkfs.ext4 -F "${disk}"
mkdir "${MOUNT_DIR}"

# Mount the new source
mount "${disk}" "${MOUNT_DIR}"
mount "${device}" "${MOUNT_DIR}"
pushd "${MOUNT_DIR}"

# Mount the ISO
Expand All @@ -59,3 +55,24 @@ function prepare_tree() {
umount "${MOUNT_DIR}"
rm -rf "${MOUNT_DIR}"
}

# Format a complete disk for hdd payload source
function format_whole_disk () {
local disk="$1"

# wipefs -a "${disk}"
sgdisk --zap-all ${disk}
mkfs.ext4 -F "${disk}"
}


# Format single partition on a disk for hdd payload source
function format_single_partition () {
local disk="$1"
# for example 12GiB
local size="$2"

sgdisk --zap-all ${disk}
sgdisk --new=0:0:+${size} ${disk}
mkfs.ext4 ${disk}1
}
3 changes: 3 additions & 0 deletions repo-addrepo-hd-iso.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ url --url=EMPTY_REPO_URL
# Where we want to download the ISO?
DISK="/dev/vdb"

# Prepare storage for the source
format_whole_disk "${DISK}"

# Download and mount the ISO.
prepare_iso "${ISO_LOCATION}" "${DISK}"
%end
Expand Down
4 changes: 4 additions & 0 deletions repo-addrepo-hd-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ cleanup() {
local tmp_dir="${1}"
stop_httpd "${tmp_dir}"
}

get_timeout() {
echo "45"
}
3 changes: 3 additions & 0 deletions repo-addrepo-hd-tree.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ url --url=EMPTY_REPO_URL
DISK="/dev/vdb"
DIRECTORY="repo"

# Prepare storage for the source
format_whole_disk "${DISK}"

# Download the content of the ISO.
prepare_tree "${ISO_LOCATION}" "${DISK}" "${DIRECTORY}"
%end
Expand Down
4 changes: 4 additions & 0 deletions repo-addrepo-hd-tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ cleanup() {
local tmp_dir="${1}"
stop_httpd "${tmp_dir}"
}

get_timeout() {
echo "45"
}

0 comments on commit 2d4430e

Please sign in to comment.