Test suite updates

pull/155/head
Jesus Alvarez 6 years ago
parent eea1f5c7dc
commit d0beee6170
  1. 6
      TODO.rst
  2. 10
      testing/README.rst
  3. 15
      testing/tests/archzfs-qemu-git-test-00-bootfs/fs.sh
  4. 13
      testing/tests/archzfs-qemu-git-test-00-bootfs/pacman.sh
  5. 12
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/archiso.sh
  6. 6
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/boot.sh
  7. 29
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/chroot.sh
  8. 20
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/conf.sh
  9. 26
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/config.sh
  10. 100
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/fs.sh
  11. 12
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/hooks.sh
  12. 56
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/pacman.sh
  13. 8
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/syslinux.cfg
  14. 0
      testing/tests/archzfs-qemu-lts-git-test-00-bootfs/vm.sh
  15. 16
      testing/tests/archzfs-qemu-std-test-00-bootfs/fs.sh
  16. 13
      testing/tests/archzfs-qemu-std-test-00-bootfs/pacman.sh
  17. 13
      testing/tests/archzfs-qemu-std-test-00-default/pacman.sh

@ -4,14 +4,16 @@ Things To Do
* Mon Jul 17 00:30 2017: Finish documenting how to run tests in testing/README.rst
* Mon Jul 17 00:30 2017: Add tests for lts-git
* Sat Sep 17 01:16 2016: ADD TESTS for run_hook
Test the args! Make sure ash can parse them.
These tests will close #76 and #77
* Wed Jul 26 20:25 2017: add run in qemu command for test.sh
Runs the image built by packer in qemu
* Sun Feb 12 15:57 2017: more scraper stuff
verify aur packages not flagged out of date

@ -1,7 +1,7 @@
=====================
archzfs testing guide
=====================
:Modified: Mon Jul 17 00:53 2017
:Modified: Fri Jul 28 01:06 2017
.. content:
@ -82,8 +82,8 @@ modified to use the archzfs-lts packages to boot.
cd files/packer_work/
qemu-system-x86_64 -machine type=pc,accel=kvm -boot once=d \
-device virtio-net,netdev=user.0 -drive file=output-qemu/archzfs-qemu-lts-test-00-bootfs-archiso-2017.07.16,if=virtio,cache=writeback,discard=ignore \
-name archzfs-qemu-lts-test-00-bootfs-archiso-2017.07.16 -netdev user,id=user.0,hostfwd=tcp::2487-:22 -display sdl -m 512M -vnc 0.0.0.0:2
-device virtio-net,netdev=user.0 -drive file=output-qemu/archzfs-qemu-std-test-00-bootfs-archiso-2017.07.16,if=virtio,cache=writeback,discard=ignore \
-name archzfs-qemu-std-test-00-bootfs-archiso-2017.07.16 -netdev user,id=user.0,hostfwd=tcp::2487-:22 -display sdl -m 512M -vnc 0.0.0.0:2
login as root user and password "azfstest"
@ -285,9 +285,9 @@ Booting the qemu image:
.. code:: console
sudo /usr/bin/qemu-system-x86_64 -device virtio-net,netdev=user.0 \
-drive file=testing/files/packer_work/output-qemu/archzfs-qemu-std-test-00-default-archiso-2016.09.10,if=virtio,cache=writeback,discard=ignore \
-drive file=testing/files/packer_work/output-qemu/archzfs-qemu-std-test-00-bootfs-archiso-2017.07.16,if=virtio,cache=writeback,discard=ignore \
-vnc 0.0.0.0:32 -netdev user,id=user.0,hostfwd=tcp::3333-:22 \
-name archzfs-qemu-std-test-00-default-archiso-2016.09.10 -machine type=pc,accel=kvm -display sdl -boot once=d -m 512M
-name archzfs-qemu-std-test-00-bootfs-archiso-2017.07.16 -machine type=pc,accel=kvm -display sdl -boot once=d -m 512M
Connection via ssh:

@ -24,41 +24,56 @@ test_fs_config_root_preinstall() {
msg2 "Clearing partition table on ${disk}"
run_cmd "sgdisk --zap ${disk}"
run_cmd_check 1 "Could not clear partition table!"
msg2 "Destroying magic strings and signatures on ${disk}"
run_cmd "dd if=/dev/zero of=${disk} bs=512 count=2048"
run_cmd_check 1 "Problem clearing disk using dd!"
run_cmd "wipefs --all ${disk}"
run_cmd_check 1 "Problem clearing disk using wipefs!"
# See http://www.rodsbooks.com/gdisk/sgdisk-walkthrough.html
# http://www.rodsbooks.com/gdisk/sgdisk.htm
msg2 "Creating boot partition on ${disk}"
run_cmd "sgdisk --new=1:0:512M --typecode=1:8300 ${disk}"
run_cmd_check 1 "A problem occurred creating boot partition using sgdisk!"
msg2 "Creating root partition on ${disk}"
run_cmd "sgdisk --new=2:0:0 --typecode=2:bf00 ${disk}"
run_cmd_check 1 "A problem occurred creating root partition using sgdisk!"
msg2 "The disk"
run_cmd "sgdisk -p ${disk}"
msg2 "Creating root filesystem"
run_cmd "zpool create -m ${test_target_dir} -f zroot /dev/vda2"
run_cmd_check 1 "Failed to create zfs pool"
run_cmd "zfs create -o mountpoint=none zroot/ROOT"
run_cmd_check 1 "Failed to create zfs root!"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT zroot/ROOT/default"
run_cmd_check 1 "Failed to create zfs zroot/ROOT/default mountpoint!"
run_cmd "zfs create -o mountpoint=none zroot/data"
run_cmd_check 1 "Failed to create zfs zroot/data mountpoint!"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT/home zroot/data/home"
run_cmd_check 1 "Failed to create zfs zroot/data/home mountpoint!"
run_cmd "zfs set mountpoint=legacy zroot/data/home"
run_cmd_check 1 "Failed to set zfs legacy mount option on mountpoint!"
msg2 "Mounting /home"
run_cmd "mount -t zfs -o default,noatime zroot/data/home ${test_target_dir}/ROOT/home"
run_cmd_check 1 "Problem mount the zfs home mountpoint!"
msg2 "Create boot directory"
run_cmd "mkdir -p ${test_target_dir}/ROOT/boot"
run_cmd_check 1 "Problem occurred creating boot directory!"
msg2 "Creating /boot filesystem (ext4)"
run_cmd "mkfs.ext4 -F -m 0 -q -L boot /dev/vda1"
run_cmd_check 1 "Problem occurred formatting the bootfs!"
msg2 "Mounting boot filesystem"
run_cmd "mount -o noatime,errors=remount-ro /dev/vda1 ${test_target_dir}/ROOT/boot"
run_cmd_check 1 "Problem occurred mounting the boot fs!"
}

@ -17,6 +17,19 @@ test_pacman_config() {
msg2 "Setting up gnupg"
run_cmd "${arch_chroot} dirmngr < /dev/null"
# Wait for networking
for i in `seq 1 10`; do
if [[ check_internet -eq 0 ]]; then
break
fi
msg2 "Attempt $i -- Google.com did not respond, trying again in 3 seconds..."
sleep 3
if [[ $i == "10" ]]; then
error "Tried 10 times, giving up!"
exit 1
fi
done
msg2 "Installing the signer key"
run_cmd "${arch_chroot} pacman-key -r 0EE7A126"
run_cmd_check 1

@ -0,0 +1,12 @@
# We need an archiso with the lts kernel used by default
test_build_archiso() {
msg "Building archiso"
cd ${test_root_dir}/../../../archiso/ &> /dev/null
if [[ -d ${packer_work_dir}/out ]] && [[ $(ls -1 | wc -l) -gt 0 ]]; then
run_cmd "rm -rf ${test_root_dir}/archiso/out/archlinux*"
fi
run_cmd "./build.sh -v"
msg2 "Copying archiso to packer_work_dir"
run_cmd "cp ${test_root_dir}/../../../archiso/out/archlinux* ${packer_work_dir} && rm -rf ${test_root_dir}/archiso/work"
cd - &> /dev/null
}

@ -0,0 +1,6 @@
test_bootloader_install() {
# Setup the boot loader
run_cmd "mkdir -p ${arch_target_dir}/boot/syslinux; cp -f /root/syslinux.cfg '${arch_target_dir}/boot/syslinux/syslinux.cfg'"
run_cmd "arch-chroot ${arch_target_dir} /usr/bin/syslinux-install_update -i -a -m"
run_cmd_check 1
}

@ -0,0 +1,29 @@
test_chroot_setup() {
# $1 arch-chroot target dir
msg "Setting up arch install..."
export arch_target_dir="${test_target_dir}"
if [[ -n $1 ]]; then
arch_target_dir="${1}"
fi
msg2 "Setting base image pacman mirror"
run_cmd "/usr/bin/cp /etc/pacman.d/mirrorlist ${arch_target_dir}/etc/pacman.d/mirrorlist"
msg2 "generating the filesystem table"
run_cmd "/usr/bin/genfstab -p ${arch_target_dir} >> '${arch_target_dir}/etc/fstab'"
# http://comments.gmane.org/gmane.linux.arch.general/48739
msg2 "Adding workaround for shutdown race condition"
run_cmd "/usr/bin/install --mode=0644 poweroff.timer '${arch_target_dir}/etc/systemd/system/poweroff.timer'"
msg2 "Create config.sh"
run_cmd "/usr/bin/install --mode=0755 /dev/null '${arch_target_dir}/usr/bin/config.sh'"
# Special filesystem configure script
source_safe /root/test-config.sh
msg2 "Entering chroot and configuring system"
run_cmd "/usr/bin/arch-chroot ${arch_target_dir} /usr/bin/config.sh"
msg2 "Deleting config.sh"
rm ${arch_target_dir}/usr/bin/config.sh
}

@ -0,0 +1,20 @@
#!/bin/bash
export test_root_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
debug "test_root_dir='${test_root_dir}'"
export test_target_dir='/mnt'
export test_archzfs_repo_name="archzfs-testing"
# Additional packages to install in the archiso
export test_archiso_packages="archzfs-linux-lts"
# Additional packages to install in the archiso. The 'packages' file is placed in /root on the archiso qemu environment.
export test_chroot_packages="$(< packages) archzfs-linux-lts-git"
export fqdn='test.archzfs.test'
export keymap='us'
export language='en_US.UTF-8'
export password=$(/usr/bin/openssl passwd -crypt 'azfstest')
export timezone='UTC'

@ -0,0 +1,26 @@
#!/bin/bash
cat <<-EOF > "${arch_target_dir}/usr/bin/config.sh"
echo '${fqdn}' > /etc/hostname
/usr/bin/ln -s /usr/share/zoneinfo/${timezone} /etc/localtime
echo 'KEYMAP=${keymap}' > /etc/vconsole.conf
/usr/bin/sed -i 's/#${language}/${language}/' /etc/locale.gen
/usr/bin/locale-gen
/usr/bin/sed -i 's/filesystems/zfs filesystems/' /etc/mkinitcpio.conf
/usr/bin/mkinitcpio -p linux
/usr/bin/usermod --password ${password} root
# https://wiki.archlinux.org/index.php/Network_Configuration#Device_names
/usr/bin/ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
/usr/bin/ln -s '/usr/lib/systemd/system/dhcpcd@.service' '/etc/systemd/system/multi-user.target.wants/dhcpcd@eth0.service'
# Configure ssh
sed -e '/^#PermitRootLogin prohibit-password$/c PermitRootLogin yes' \
-e '/^#UseDNS no$/c UseDNS no' \
-i /etc/ssh/sshd_config
/usr/bin/systemctl enable sshd.service
EOF

@ -0,0 +1,100 @@
test_fs_config_nfs() {
# $1 arch-chroot directory
# prefix="${test_target_dir}"
if [[ -n $1 ]]; then
prefix="${1}"
fi
msg "Create NFS mount points"
run_cmd "/usr/bin/mkdir -p ${prefix}/repo"
msg "Setting the package cache (nfs mount)"
run_cmd "mount -t nfs4 -o rsize=32768,wsize=32768,timeo=3 10.0.2.2:/var/cache/pacman/pkg ${prefix}/var/cache/pacman/pkg"
msg "Mounting the AUR package repo"
run_cmd "mount -t nfs4 -o rsize=32768,wsize=32768,timeo=3 10.0.2.2:/mnt/data/pacman/repo ${prefix}/repo"
}
test_fs_config_root_preinstall() {
msg "Configuring root filesystem!"
export disk='/dev/vda'
export root_partition="${disk}1"
msg2 "Clearing partition table on ${disk}"
run_cmd "sgdisk --zap ${disk}"
run_cmd_check 1 "Could not clear partition table!"
msg2 "Destroying magic strings and signatures on ${disk}"
run_cmd "dd if=/dev/zero of=${disk} bs=512 count=2048"
run_cmd_check 1 "Problem clearing disk using dd!"
run_cmd "wipefs --all ${disk}"
run_cmd_check 1 "Problem clearing disk using wipefs!"
# See http://www.rodsbooks.com/gdisk/sgdisk-walkthrough.html
# http://www.rodsbooks.com/gdisk/sgdisk.htm
msg2 "Creating boot partition on ${disk}"
run_cmd "sgdisk --new=1:0:512M --typecode=1:8300 ${disk}"
run_cmd_check 1 "A problem occurred creating boot partition using sgdisk!"
msg2 "Creating root partition on ${disk}"
run_cmd "sgdisk --new=2:0:0 --typecode=2:bf00 ${disk}"
run_cmd_check 1 "A problem occurred creating root partition using sgdisk!"
msg2 "The disk"
run_cmd "sgdisk -p ${disk}"
msg2 "Creating root filesystem"
run_cmd "zpool create -m ${test_target_dir} -f zroot /dev/vda2"
run_cmd_check 1 "Failed to create zfs pool"
run_cmd "zfs create -o mountpoint=none zroot/ROOT"
run_cmd_check 1 "Failed to create zfs root!"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT zroot/ROOT/default"
run_cmd_check 1 "Failed to create zfs zroot/ROOT/default mountpoint!"
run_cmd "zfs create -o mountpoint=none zroot/data"
run_cmd_check 1 "Failed to create zfs zroot/data mountpoint!"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT/home zroot/data/home"
run_cmd_check 1 "Failed to create zfs zroot/data/home mountpoint!"
run_cmd "zfs set mountpoint=legacy zroot/data/home"
run_cmd_check 1 "Failed to set zfs legacy mount option on mountpoint!"
msg2 "Mounting /home"
run_cmd "mount -t zfs -o default,noatime zroot/data/home ${test_target_dir}/ROOT/home"
run_cmd_check 1 "Problem mount the zfs home mountpoint!"
msg2 "Create boot directory"
run_cmd "mkdir -p ${test_target_dir}/ROOT/boot"
run_cmd_check 1 "Problem occurred creating boot directory!"
msg2 "Creating /boot filesystem (ext4)"
run_cmd "mkfs.ext4 -F -m 0 -q -L boot /dev/vda1"
run_cmd_check 1 "Problem occurred formatting the bootfs!"
msg2 "Mounting boot filesystem"
run_cmd "mount -o noatime,errors=remount-ro /dev/vda1 ${test_target_dir}/ROOT/boot"
run_cmd_check 1 "Problem occurred mounting the boot fs!"
}
test_fs_config_root_postinstall() {
msg "Performing final filesystem operations"
msg2 "Unmounting boot partition"
run_cmd "umount ${test_target_dir}/ROOT/boot"
msg2 "Unmounting nfs partitions"
run_cmd "umount -a -t nfs4"
msg2 "Unmounting home partition"
run_cmd "umount ${test_target_dir}/ROOT/home"
msg2 "Setting flags and exporting ZFS root"
run_cmd "zfs umount -a"
run_cmd "zpool set bootfs=zroot/ROOT/default zroot"
run_cmd "zfs set mountpoint=none zroot"
run_cmd "zfs set mountpoint=/ zroot/ROOT/default"
run_cmd "zfs set mountpoint=/home zroot/data/home"
run_cmd "zfs set mountpoint=legacy zroot/data/home"
run_cmd "zpool export zroot"
}

@ -0,0 +1,12 @@
#!/bin/bash
test_setup_exit() {
msg "Installation complete!"
systemctl reboot
}
test_met_acceptance_criteria() {
return 1
}

@ -0,0 +1,56 @@
# Requires the pacman cache and pacman package repos be mounted via NFS
test_pacman_config() {
# $1 arch-chroot target directory
arch_target_dir=""
arch_packages="${test_archiso_packages}"
if [[ -n $1 ]]; then
arch_target_dir="${1}"
arch_chroot="/usr/bin/arch-chroot ${1}"
fi
msg "Overriding mirrorlist"
run_cmd "cp mirrorlist ${arch_target_dir}/etc/pacman.d/mirrorlist"
msg "Installing archzfs repo into chroot"
printf "\n%s\n%s\n" "[${test_archzfs_repo_name}]" "Server = file:///repo/\$repo/\$arch" >> ${arch_target_dir}/etc/pacman.conf
msg2 "Setting up gnupg"
run_cmd "${arch_chroot} dirmngr < /dev/null"
# Wait for networking
for i in `seq 1 10`; do
if [[ check_internet -eq 0 ]]; then
break
fi
msg2 "Attempt $i -- Google.com did not respond, trying again in 3 seconds..."
sleep 3
if [[ $i == "10" ]]; then
error "Tried 10 times, giving up!"
exit 1
fi
done
msg2 "Installing the signer key"
run_cmd "${arch_chroot} pacman-key -r 0EE7A126"
run_cmd_check 1
run_cmd "${arch_chroot} pacman-key --lsign-key 0EE7A126"
run_cmd_check 1
if [[ ! -n $1 ]]; then
msg2 "Installing test packages"
# Install the required packages in the image
run_cmd "${arch_chroot} pacman -Sy --noconfirm ${arch_packages}"
run_cmd_check 1
msg2 "Loading zfs modules"
run_cmd "modprobe zfs"
fi
}
test_pacman_pacstrap() {
msg "bootstrapping the base installation"
debug "TEST_CHROOT_PACKAGES: ${test_chroot_packages}"
run_cmd "/usr/bin/pacstrap -c '${test_target_dir}/ROOT' base base-devel ${test_chroot_packages}"
run_cmd_check 1
}

@ -0,0 +1,8 @@
DEFAULT arch
TIMEOUT 0.1
LABEL arch
MENU LABEL Arch Linux
LINUX ../vmlinuz-linux
APPEND zfs=zroot/ROOT/default rw
INITRD ../initramfs-linux.img

@ -24,41 +24,55 @@ test_fs_config_root_preinstall() {
msg2 "Clearing partition table on ${disk}"
run_cmd "sgdisk --zap ${disk}"
run_cmd_check 1 "Could not clear partition table!"
msg2 "Destroying magic strings and signatures on ${disk}"
run_cmd "dd if=/dev/zero of=${disk} bs=512 count=2048"
run_cmd_check 1 "Problem clearing disk using dd!"
run_cmd "wipefs --all ${disk}"
run_cmd_check 1 "Problem clearing disk using wipefs!"
# See http://www.rodsbooks.com/gdisk/sgdisk-walkthrough.html
# http://www.rodsbooks.com/gdisk/sgdisk.htm
msg2 "Creating boot partition on ${disk}"
run_cmd "sgdisk --new=1:0:512M --typecode=1:8300 ${disk}"
run_cmd_check 1 "A problem occurred creating boot partition using sgdisk!"
msg2 "Creating root partition on ${disk}"
run_cmd "sgdisk --new=2:0:0 --typecode=2:bf00 ${disk}"
run_cmd_check 1 "A problem occurred creating root partition using sgdisk!"
msg2 "The disk"
run_cmd "sgdisk -p ${disk}"
msg2 "Creating root filesystem"
run_cmd "zpool create -m ${test_target_dir} -f zroot /dev/vda2"
run_cmd_check 1 "Failed to create zfs pool"
run_cmd "zfs create -o mountpoint=none zroot/ROOT"
run_cmd_check 1 "Failed to create zfs root!"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT zroot/ROOT/default"
run_cmd_check 1 "Failed to create zfs zroot/ROOT/default mountpoint!"
run_cmd "zfs create -o mountpoint=none zroot/data"
run_cmd_check 1 "Failed to create zfs zroot/data mountpoint!"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT/home zroot/data/home"
run_cmd_check 1 "Failed to create zfs zroot/data/home mountpoint!"
run_cmd "zfs set mountpoint=legacy zroot/data/home"
run_cmd_check 1 "Failed to set zfs legacy mount option on mountpoint!"
msg2 "Mounting /home"
run_cmd "mount -t zfs -o default,noatime zroot/data/home ${test_target_dir}/ROOT/home"
run_cmd_check 1 "Problem mount the zfs home mountpoint!"
msg2 "Create boot directory"
run_cmd "mkdir -p ${test_target_dir}/ROOT/boot"
run_cmd_check 1 "Problem occurred creating boot directory!"
msg2 "Creating /boot filesystem (ext4)"
run_cmd "mkfs.ext4 -F -m 0 -q -L boot /dev/vda1"
run_cmd_check 1 "Problem occurred formatting the bootfs!"
msg2 "Mounting boot filesystem"
run_cmd "mount -o noatime,errors=remount-ro /dev/vda1 ${test_target_dir}/ROOT/boot"
run_cmd_check 1 "Problem occurred mounting the boot fs!"
}

@ -17,6 +17,19 @@ test_pacman_config() {
msg2 "Setting up gnupg"
run_cmd "${arch_chroot} dirmngr < /dev/null"
# Wait for networking
for i in `seq 1 10`; do
if [[ check_internet -eq 0 ]]; then
break
fi
msg2 "Attempt $i -- Google.com did not respond, trying again in 3 seconds..."
sleep 3
if [[ $i == "10" ]]; then
error "Tried 10 times, giving up!"
exit 1
fi
done
msg2 "Installing the signer key"
run_cmd "${arch_chroot} pacman-key -r 0EE7A126"
run_cmd_check 1

@ -17,6 +17,19 @@ test_pacman_config() {
msg2 "Setting up gnupg"
run_cmd "${arch_chroot} dirmngr < /dev/null"
# Wait for networking
for i in `seq 1 10`; do
if [[ check_internet -eq 0 ]]; then
break
fi
msg2 "Attempt $i -- Google.com did not respond, trying again in 3 seconds..."
sleep 3
if [[ $i == "10" ]]; then
error "Tried 10 times, giving up!"
exit 1
fi
done
msg2 "Installing the signer key"
run_cmd "${arch_chroot} pacman-key -r 0EE7A126"
if [[ ${run_cmd_return} -ne 0 ]]; then

Loading…
Cancel
Save