mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-12-04 08:07:04 +00:00
test(netboot): stage shared root image assets in fixtures
Stage shared checksum and installation assets in complete dracut fixtures. Keep real split-/usr directories so the fixture can load its shell on systems where /bin and /lib64 are not symlinks. The fixtures also run against the original implementation, before shared assets exist.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
load "${BASH_SOURCE[0]%/*}/shell_source.bash"
|
||||
|
||||
stage_dracut_module()
|
||||
{
|
||||
local variant=$1 destination=$2 helper source
|
||||
mkdir -p "$destination"
|
||||
cp -a "$(repo_path "xCAT-server/share/xcat/netboot/$variant")/." "$destination/"
|
||||
for helper in xcat-rootimg-checksum.sh xcat-rootimg-install.sh; do
|
||||
source=$(repo_path "xCAT-server/share/xcat/netboot/imgutils/$helper")
|
||||
[ ! -f "$source" ] || cp "$source" "$destination/"
|
||||
done
|
||||
}
|
||||
@@ -5,12 +5,12 @@
|
||||
# - the boot NIC gets a DHCPv4 lease, and
|
||||
# - the initqueue has a finished condition, or it ends before it runs the settled hooks.
|
||||
|
||||
load 'helpers/shell_source'
|
||||
load 'helpers/dracut_module'
|
||||
|
||||
setup()
|
||||
{
|
||||
INSTALL="$(require_repo_file 'xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot')"
|
||||
MOD="$(dirname "$INSTALL")"
|
||||
MOD="${BATS_TEST_TMPDIR}/module"
|
||||
stage_dracut_module ubuntu/dracut "$MOD"
|
||||
LOG="${BATS_TEST_TMPDIR}/installed"
|
||||
: >"$LOG"
|
||||
HOOKS="${BATS_TEST_TMPDIR}/hooks"
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
# On 26.04 the initramfs then fetches no root: measured on xcat32-cn, zero DHCP from the initrd,
|
||||
# zero httpd requests for rootimg.cpio.gz, and dracut in emergency mode 3.3 seconds in.
|
||||
|
||||
load 'helpers/shell_source'
|
||||
load 'helpers/dracut_module'
|
||||
|
||||
setup()
|
||||
{
|
||||
INSTALL="$(require_repo_file 'xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot')"
|
||||
MOD="$(dirname "$INSTALL")"
|
||||
MOD="${BATS_TEST_TMPDIR}/module"
|
||||
stage_dracut_module ubuntu/dracut "$MOD"
|
||||
LOG="${BATS_TEST_TMPDIR}/installed"
|
||||
: >"$LOG"
|
||||
}
|
||||
|
||||
@@ -162,16 +162,27 @@ run_xcatroot()
|
||||
local script="$1" shell="$2"
|
||||
shift 2
|
||||
local sandbox=("$bwrap" --unshare-all --die-with-parent --new-session
|
||||
--ro-bind /usr /usr --ro-bind /etc /etc --symlink usr/bin /bin --symlink usr/sbin /sbin
|
||||
--ro-bind /usr /usr --ro-bind /etc /etc
|
||||
--dir /lib --proc /proc --dev /dev --tmpfs /tmp --dir /sysroot
|
||||
--bind "$FX" /fx --ro-bind "$FX/lib/dracut-lib.sh" /lib/dracut-lib.sh
|
||||
--ro-bind "$(repo_path "$script")" /xcatroot --chdir /
|
||||
--setenv PATH /fx/bin:/usr/bin:/bin --setenv imgurl "$URL" --setenv XCAT 192.0.2.1:3001
|
||||
--setenv rootimgchecksum "${CMDLINE#rootimgchecksum=}" --setenv XCAT_UFTP_POLL 60 "$@")
|
||||
[ ! -e /usr/lib64 ] || sandbox+=(--symlink usr/lib64 /lib64)
|
||||
local directory
|
||||
for directory in bin sbin; do
|
||||
if [ -L "/$directory" ]; then
|
||||
sandbox+=(--symlink "usr/$directory" "/$directory")
|
||||
else
|
||||
sandbox+=(--ro-bind "/$directory" "/$directory")
|
||||
fi
|
||||
done
|
||||
[ ! -e /lib64 ] || sandbox+=(--ro-bind /lib64 /lib64)
|
||||
for multiarch in /usr/lib/*-linux-gnu; do
|
||||
[ ! -d "$multiarch" ] || sandbox+=(--ro-bind "$multiarch" "/lib/${multiarch##*/}")
|
||||
done
|
||||
local checksum_helper
|
||||
checksum_helper=$(repo_path xCAT-server/share/xcat/netboot/imgutils/xcat-rootimg-checksum.sh)
|
||||
[ ! -f "$checksum_helper" ] || sandbox+=(--ro-bind "$checksum_helper" /lib/xcat-rootimg-checksum.sh)
|
||||
# genimage puts the helper in every initial ramdisk that can receive the root image over UFTP.
|
||||
[ -n "$NO_UFTP_HELPER" ] || sandbox+=(--ro-bind "$(repo_path xCAT-server/share/xcat/netboot/imgutils/xcat-rootimg-fetch.sh)" /lib/xcat-rootimg-fetch.sh)
|
||||
echo "imgurl=$URL XCAT=192.0.2.1:3001 nonodestatus $CMDLINE $UFTP $KERNEL_ARGS" >"$FX/cmdline"
|
||||
|
||||
@@ -74,6 +74,9 @@ getarg()
|
||||
}
|
||||
SH
|
||||
copy($source, "$root/xcatroot") or die $!;
|
||||
my $checksum_helper = "$netboot/../imgutils/xcat-rootimg-checksum.sh";
|
||||
copy($checksum_helper, "$root/lib/xcat-rootimg-checksum.sh") or die $!
|
||||
if -f $checksum_helper;
|
||||
my $archive = "$root/rootimg.$method.gz";
|
||||
my @pack = $method eq 'cpio'
|
||||
? ('/bin/bash', '-o', 'pipefail', '-c', 'cd "$1" && find . -print0 | cpio -0 -o -H newc | gzip > "$2"', 'pack', $payload, $archive)
|
||||
|
||||
Reference in New Issue
Block a user