Cirrus: Support additional test-storage

Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
Chris Evich 2019-08-13 10:23:19 -04:00
parent 83d93c2f2f
commit 1fb3e1d7c8
No known key found for this signature in database
GPG Key ID: 03EDC70FD578067F
5 changed files with 158 additions and 41 deletions

View File

@ -50,31 +50,48 @@ gce_instance:
disk: 200
image_name: "${FEDORA_CACHE_IMAGE_NAME}"
testing_task:
depends_on:
- lint
# Not all $TEST_DRIVER combinations are valid for all OS types.
# Note: Nested-variable resolution happens at runtime, not eval. time.
# Use verbose logic for ease of reading/maintaining.
only_if: >-
( $VM_IMAGE =~ '.*UBUNTU.*' && $TEST_DRIVER == "vfs" ) ||
( $VM_IMAGE =~ '.*UBUNTU.*' && $TEST_DRIVER == "aufs" ) ||
( $VM_IMAGE =~ '.*UBUNTU.*' && $TEST_DRIVER == "overlay" ) ||
( $VM_IMAGE =~ '.*UBUNTU.*' && $TEST_DRIVER == "fuse-overlay" ) ||
( $VM_IMAGE =~ '.*FEDORA.*' && $TEST_DRIVER != "aufs" )
env:
matrix:
VM_IMAGE: "${FEDORA_CACHE_IMAGE_NAME}"
VM_IMAGE: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
VM_IMAGE: "${UBUNTU_CACHE_IMAGE_NAME}"
# VM_IMAGE: "${PRIOR_UBUNTU_CACHE_IMAGE_NAME}" # No fuse3 support
matrix: # See ./contrib/cirrus/build_and_test.sh
TEST_DRIVER: "vfs"
TEST_DRIVER: "aufs"
TEST_DRIVER: "overlay"
TEST_DRIVER: "fuse-overlay"
TEST_DRIVER: "devicemapper"
TEST_DRIVER: "fuse-overlay-whiteout"
gce_instance: # Only need to specify differences from defaults (above)
matrix: # Duplicate this task for each matrix product.
image_name: "${FEDORA_CACHE_IMAGE_NAME}"
image_name: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
image_name: "${UBUNTU_CACHE_IMAGE_NAME}"
# image_name: "${PRIOR_UBUNTU_CACHE_IMAGE_NAME}" # No fuse3 support
image_name: "${VM_IMAGE}"
# Separate scripts for separate outputs, makes debugging easier.
setup_script: '${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}'
build_and_test_script: '${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/build_and_test.sh |& ${_TIMESTAMP}'
# Log collection when job was successful
df_script: '${_DFCMD} || true'
rh_audit_log_script: '${_RAUDITCMD} || true'
ubuntu_audit_log_script: '${_UAUDITCMD} || true'
journal_log_script: '${_JOURNALCMD} || true'
on_failure: # Script names must be different from above
failure_df_script: '${_DFCMD} || true'
failure_rh_audit_log_script: '${_RAUDITCMD} || true'
failure_ubuntu_audit_log_script: '${_UAUDITCMD} || true'
failure_journal_log_script: '${_JOURNALCMD} || true'
always:
df_script: '${_DFCMD} || true'
rh_audit_log_script: '${_RAUDITCMD} || true'
ubuntu_audit_log_script: '${_UAUDITCMD} || true'
journal_log_script: '${_JOURNALCMD} || true'
lint_task:
env:

View File

@ -0,0 +1,62 @@
#!/bin/bash
# N/B: This script could mega f*!@up your disks if run by mistake.
# it is left without the execute-bit on purpose!
# $SLASH_DEVICE is the disk device to be f*xtuP
SLASH_DEVICE="/dev/sda" # Always the case on GCP
# The unallocated space results from the difference in disk-size between VM Image
# and runtime request. The check_image.sh test includes a minimum-space check,
# with the Image size set initially lower by contrib/cirrus/packer/libpod_images.yml
NEW_PART_START="50%"
NEW_PART_END="100%"
set -eo pipefail
source $(dirname $0)/lib.sh
if [[ ! -r "/root" ]] || [[ -r "/root/second_partition_ready" ]]
then
echo "Warning: Ignoring attempted execution of $(basename $0)"
exit 0
fi
[[ -n "type -P parted" ]] || \
die 2 "The parted command is required."
[[ ! -b ${SLASH_DEVICE}2 ]] || \
die 5 "Found unexpected block device ${SLASH_DEVICE}2"
PPRINTCMD="parted --script ${SLASH_DEVICE} print"
FINDMNTCMD="findmnt --source=${SLASH_DEVICE}1 --mountpoint=/ --canonicalize --evaluate --first-only --noheadings"
TMPF=$(mktemp -p '' $(basename $0)_XXXX)
trap "rm -f $TMPF" EXIT
if $FINDMNTCMD | tee $TMPF | egrep -q "^/\s+${SLASH_DEVICE}1"
then
echo "Repartitioning original partition table:"
$PPRINTCMD
else
die 6 "Unexpected output from '$FINDMNTCMD': $(<$TMPF)"
fi
echo "Adding partition offset within unpartitioned space."
parted --script --align optimal /dev/sda unit % mkpart primary "" "" "$NEW_PART_START" "$NEW_PART_END"
echo "New partition table:"
$PPRINTCMD
echo "Growing ${SLASH_DEVICE}1 meet start of ${SLASH_DEVICE}2"
growpart ${SLASH_DEVICE} 1
FSTYPE=$(findmnt --first-only --noheadings --output FSTYPE ${SLASH_DEVICE}1)
echo "Expanding $FSTYPE filesystem on ${SLASH_DEVICE}1"
case $FSTYPE in
ext*) resize2fs ${SLASH_DEVICE}1 ;;
*) die 11 "Script $(basename $0) doesn't know how to resize a $FSTYPE filesystem." ;;
esac
# Must happen last - signals completion to other tooling
echo "Recording newly available disk partition device into /root/second_partition_ready"
echo "${SLASH_DEVICE}2" > /root/second_partition_ready

View File

@ -9,24 +9,29 @@ make install.tools
showrun make local-binary
showrun make local-cross
showrun make local-test-unit
# TODO: Some integration tests fail on Fedora
if [[ "$OS_RELEASE_ID" != "fedora" ]]; then
showrun make STORAGE_DRIVER=overlay local-test-integration
fi
showrun make STORAGE_DRIVER=overlay STORAGE_OPTION=overlay.mount_program=/usr/bin/fuse-overlayfs local-test-integration
showrun make STORAGE_DRIVER=overlay FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 STORAGE_OPTION=overlay.mount_program=/usr/bin/fuse-overlayfs local-test-integration
showrun make STORAGE_DRIVER=vfs local-test-integration
if [[ "$OS_RELEASE_ID" == "ubuntu" ]]; then
showrun make STORAGE_DRIVER=aufs local-test-integration
fi
# TODO: Requires partitioning of $(cat /root/second_partition_ready) device after running
# https://github.com/containers/libpod/blob/v1.6.2/contrib/cirrus/add_second_partition.sh
#
#showrun make STORAGE_DRIVER=devicemapper STORAGE_OPTION=dm.directlvm_device=/dev/abc local-test-integration
case $TEST_DRIVER in
overlay)
showrun make STORAGE_DRIVER=overlay local-test-integration
;;
fuse-overlay)
showrun make STORAGE_DRIVER=overlay STORAGE_OPTION=overlay.mount_program=/usr/bin/fuse-overlayfs local-test-integration
;;
fuse-overlay-whiteout)
showrun make STORAGE_DRIVER=overlay FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 STORAGE_OPTION=overlay.mount_program=/usr/bin/fuse-overlayfs local-test-integration
;;
devicemapper)
# Setup by devicemapper_setup in lib.sh
DM_DEVICE=$(< $DM_REF_FILEPATH)
echo "WARNING: Performing destructive testing against $DM_DEVICE"
showrun make STORAGE_DRIVER=devicemapper STORAGE_OPTION=dm.directlvm_device=$DM_DEVICE local-test-integration
;;
vfs)
showrun make STORAGE_DRIVER=vfs local-test-integration
;;
aufs)
showrun make STORAGE_DRIVER=aufs local-test-integration
;;
*)
die 11 "Unknown/Unsupported \$TEST_DRIVER=$TEST_DRIVER (see .cirrus.yml and $(basename $0))"
;;
esac

View File

@ -77,6 +77,14 @@ RPMS_CONFLICTING="gcc-go"
DEBS_REQUIRED=""
DEBS_CONFLICTING=""
# For devicemapper testing, device names need to be passed down for use in tests
if [[ "$TEST_DRIVER" == "devicemapper" ]]; then
DM_LVM_VG_NAME="test_vg"
DM_REF_FILEPATH="/root/volume_group_ready"
else
unset DM_LVM_VG_NAME DM_REF_FILEPATH
fi
# Pass in a list of one or more envariable names; exit non-zero with
# helpful error message if any value is empty
req_env_var() {
@ -191,3 +199,25 @@ showrun() {
"$@"
fi
}
devicemapper_setup() {
req_env_var TEST_DRIVER DM_LVM_VG_NAME DM_REF_FILEPATH
# Requires add_second_partition.sh to have already run successfully
if [[ -r "/root/second_partition_ready" ]]
then
device=$(< /root/second_partition_ready)
if [[ -n "$device" ]] # LVM setup should only ever happen once
then
echo "Setting up LVM PV on $device to validate it's functional"
showrun pvcreate --force --yes "$device"
echo "Wiping LVM signatures from $device to prepare it for testing use"
showrun pvremove --force --yes "$device"
# Block setup from happening ever again
truncate --size=0 /root/second_partition_ready # mark completion|in-use
echo "$device" > "$DM_REF_FILEPATH"
fi
echo "Test device $(cat $DM_REF_FILEPATH) is ready to go."
else
echo "WARNING: Can't read /root/second_partition_ready, created by $(dirname $0)/add_second_partition.sh"
fi
}

View File

@ -4,7 +4,7 @@ set -e
source $(dirname $0)/lib.sh
req_env_var GOSRC OS_RELEASE_ID OS_RELEASE_VER SHORT_APTGET
req_env_var GOSRC OS_RELEASE_ID OS_RELEASE_VER SHORT_APTGET TEST_DRIVER
install_ooe
@ -20,6 +20,12 @@ case "$OS_RELEASE_ID" in
$SHORT_DNFY install $RPMS_REQUIRED
[[ -z "$RPMS_CONFLICTING" ]] || \
$SHORT_DNFY erase $RPMS_CONFLICTING
# Only works on Fedora VM images
bash "$SCRIPT_BASE/add_second_partition.sh"
if [[ "$TEST_DRIVER" == "devicemapper" ]]; then
$SHORT_DNFY install lvm2
devicemapper_setup
fi
;;
ubuntu)
$SHORT_APTGET update # Fetch latest package metadata
@ -35,6 +41,3 @@ case "$OS_RELEASE_ID" in
esac
install_fuse_overlayfs_from_git
echo "Installing common tooling"
#make install.tools