-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github/actions/system-test: Add new action for running a system-test
This allows reuse of the system test steps for all groups core, upgrade and Canonical specific tests. Signed-off-by: Julian Pelizäus <[email protected]>
- Loading branch information
1 parent
78e571d
commit e035c9b
Showing
1 changed file
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
name: System test | ||
inputs: | ||
github_runner: | ||
description: Whether or not this test is executed on a GitHub runner. | ||
required: true | ||
default: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Performance tuning | ||
uses: canonical/lxd/.github/actions/tune-disk-performance@main | ||
|
||
- name: Reclaim some space | ||
uses: canonical/lxd/.github/actions/reclaim-disk-space@main | ||
|
||
- name: Reclaim some memory | ||
shell: bash | ||
run: | | ||
set -eux | ||
free -mt | ||
sudo systemctl stop dpkg-db-backup.timer e2scrub_all.timer fstrim.timer logrotate.timer man-db.timer motd-news.timer update-notifier-download.timer update-notifier-motd.timer | ||
sudo systemctl stop iscsid.socket multipathd.socket | ||
sudo systemctl stop cron.service irqbalance.service multipathd.service networkd-dispatcher.service | ||
free -mt | ||
- name: Reclaim some memory (GitHub runners) | ||
if: inputs.github_runner == 'true' | ||
shell: bash | ||
run : | | ||
set -eux | ||
free -mt | ||
sudo systemctl stop phpsessionclean.timer | ||
sudo systemctl stop mono-xsp4.service php8.1-fpm.service | ||
free -mt | ||
- name: Disable Docker (GitHub runners) | ||
if: inputs.github_runner == 'true' | ||
uses: canonical/lxd/.github/actions/disable-docker@main | ||
|
||
- name: "Disable br_netfilter" | ||
shell: bash | ||
run: | | ||
# When br_netfilter is enabled, the multicast traffic that passes the native LXD bridge | ||
# will get masqueraded too which breaks the multicast discovery. | ||
sudo rmmod br_netfilter | ||
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
sudo add-apt-repository ppa:dqlite/dev -y --no-update | ||
sudo apt-get update | ||
sudo apt-get install --no-install-recommends -y libdqlite-dev pkg-config net-tools | ||
- name: Download system test dependencies | ||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | ||
with: | ||
name: system-test-deps | ||
merge-multiple: true | ||
# Pick the right home path of the runner user. | ||
# The GitHub runners use /home/runner and the Canonical ones use /home/ubuntu. | ||
# The path intput supports expansion. | ||
path: ~/go/bin | ||
|
||
- name: Make GOCOVERDIR | ||
shell: bash | ||
run: mkdir -p "${GOCOVERDIR}" | ||
if: env.GOCOVERDIR != '' | ||
|
||
- name: Sideload debug binaries | ||
shell: bash | ||
run: | | ||
set -eux | ||
# Binaries to sideload | ||
export MICROCLOUD_DEBUG_PATH=~/go/bin/microcloud | ||
export MICROCLOUDD_DEBUG_PATH=~/go/bin/microcloudd | ||
echo "MICROCLOUD_DEBUG_PATH=${MICROCLOUD_DEBUG_PATH}" >> "${GITHUB_ENV}" | ||
echo "MICROCLOUDD_DEBUG_PATH=${MICROCLOUDD_DEBUG_PATH}" >> "${GITHUB_ENV}" | ||
- name: Strip debug binaries | ||
if: env.GOCOVERDIR == '' | ||
shell: bash | ||
run: | | ||
set -eux | ||
strip -s "${MICROCLOUD_DEBUG_PATH}" "${MICROCLOUDD_DEBUG_PATH}" | ||
- name: "Free up the ephemeral disk" | ||
shell: bash | ||
run: | | ||
set -eux | ||
if ! mountpoint --quiet /mnt; then | ||
echo "INFO: no ephemeral disk mounted on /mnt" | ||
mount | ||
exit 0 | ||
fi | ||
# If the rootfs and the ephemeral part are on the same physical disk, giving the whole | ||
# disk to microceph would wipe our rootfs. Since it is pretty rare for GitHub Action | ||
# runners to have a single disk, we immediately bail rather than trying to gracefully | ||
# handle it. Once snapd releases with https://github.com/snapcore/snapd/pull/13150, | ||
# we will be able to stop worrying about that special case. | ||
if [ "$(stat -c '%d' /)" = "$(stat -c '%d' /mnt)" ]; then | ||
echo "FAIL: rootfs and ephemeral part on the same disk, aborting" | ||
lsblk | ||
blkid | ||
sudo fdisk -l | ||
exit 1 | ||
fi | ||
# Free-up the ephemeral disk to use it as storage device for LXD. | ||
sudo swapoff /mnt/swapfile | ||
ephemeral_disk="$(findmnt --noheadings --output SOURCE --target /mnt | sed 's/[0-9]\+$//')" | ||
sudo umount /mnt | ||
sudo wipefs -a "${ephemeral_disk}" | ||
export TEST_STORAGE_SOURCE="${ephemeral_disk}" | ||
echo "TEST_STORAGE_SOURCE=${TEST_STORAGE_SOURCE}" >> "${GITHUB_ENV}" | ||
- name: "Setup host LXD" | ||
shell: bash | ||
run: | | ||
set -eux | ||
sudo snap install lxd --channel 5.21/edge | ||
sudo lxd init --auto --storage-backend=zfs | ||
# Save cached images into the (compressed) zpool | ||
sudo lxc storage volume create default images | ||
sudo lxc config set storage.images_volume=default/images | ||
- name: "Prepare for system tests" | ||
shell: bash | ||
run: | | ||
set -eux | ||
chmod +x ~ | ||
export BASE_OS="${{ matrix.os }}" | ||
export LXD_SNAP_CHANNEL="${{ matrix.lxd }}" | ||
export MICROCEPH_SNAP_CHANNEL="${{ matrix.microceph }}" | ||
export MICROOVN_SNAP_CHANNEL="${{ matrix.microovn }}" | ||
export MICROCLOUD_SNAP_CHANNEL="${{ matrix.microcloud }}" | ||
cd test | ||
sudo --preserve-env=GOCOVERDIR,DEBUG,GITHUB_ACTIONS,MICROCLOUD_DEBUG_PATH,MICROCLOUDD_DEBUG_PATH,SKIP_VM_LAUNCH,SNAPSHOT_RESTORE,TEST_STORAGE_SOURCE,TESTBED_READY,BASE_OS,LXD_SNAP_CHANNEL,MICROCEPH_SNAP_CHANNEL,MICROOVN_SNAP_CHANNEL,MICROCLOUD_SNAP_CHANNEL ./main.sh setup | ||
echo "TESTBED_READY=1" >> "${GITHUB_ENV}" | ||
echo "BASE_OS=${BASE_OS}" >> "${GITHUB_ENV}" | ||
echo "LXD_SNAP_CHANNEL=${LXD_SNAP_CHANNEL}" >> "${GITHUB_ENV}" | ||
echo "MICROCEPH_SNAP_CHANNEL=${MICROCEPH_SNAP_CHANNEL}" >> "${GITHUB_ENV}" | ||
echo "MICROOVN_SNAP_CHANNEL=${MICROOVN_SNAP_CHANNEL}" >> "${GITHUB_ENV}" | ||
echo "MICROCLOUD_SNAP_CHANNEL=${MICROCLOUD_SNAP_CHANNEL}" >> "${GITHUB_ENV}" | ||
- name: "Run system tests (${{ matrix.suite }})" | ||
shell: bash | ||
run: | | ||
set -eux | ||
chmod +x ~ | ||
cd test | ||
sudo --preserve-env=GOCOVERDIR,DEBUG,GITHUB_ACTIONS,MICROCLOUD_DEBUG_PATH,MICROCLOUDD_DEBUG_PATH,SKIP_VM_LAUNCH,SNAPSHOT_RESTORE,TEST_STORAGE_SOURCE,TESTBED_READY,BASE_OS,LXD_SNAP_CHANNEL,MICROCEPH_SNAP_CHANNEL,MICROOVN_SNAP_CHANNEL,MICROCLOUD_SNAP_CHANNEL ./main.sh ${{ matrix.suite }} | ||
echo "TIMESTAMP=$(date +%Y%m%d_%H%M%S_%N)" >> "${GITHUB_ENV}" | ||
- name: Upload coverage data | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | ||
with: | ||
name: coverage-${{ matrix.suite }}-${{ env.TIMESTAMP }} | ||
path: ${{ env.GOCOVERDIR }} | ||
if: env.GOCOVERDIR != '' |