Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug system tests #288

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f3fcf41
test/includes/microcloud: allow using a dedicated storage source device
simondeziel Apr 10, 2024
460a715
test/includes/microcloud: only install zfsutils-linux and htop if CLO…
simondeziel Apr 10, 2024
894df61
test/includes/microcloud: stop adding ubuntu-minimal:
simondeziel Apr 13, 2024
a3db46f
test/includes/check: require instance_ready_state API on host LXD
simondeziel Apr 10, 2024
29d4fd4
test/suites/basic: use ubuntu-minimal for c1/v1
simondeziel Apr 10, 2024
5782411
test/suites/basic: poll less frequently when waiting on c1/v1
simondeziel Apr 10, 2024
6703cab
test/suites/basic: report when c1/v1 have booted successfully
simondeziel Apr 10, 2024
84af383
test/main: fix indentation
simondeziel Apr 10, 2024
d9c0bb7
github: fix check for compat with Go 1.22.0
simondeziel Apr 10, 2024
63aef4e
github: align tests job with LXD's
simondeziel Apr 10, 2024
65027ba
github: add initial (snap-based) system tests
simondeziel Apr 10, 2024
e37f1cb
github: require system tests to pass before triggering LP build
simondeziel Apr 10, 2024
312586a
test/includes/microcloud: nicer output when wiping/deleting disks
simondeziel Apr 15, 2024
1685e7d
test/suite/basic: nicer output when starting c1/v1
simondeziel Apr 15, 2024
a4e80b0
test/includes/microcloud: use lxd default channel (5.21/stable as of …
simondeziel Apr 11, 2024
8a82f7b
test/includes/microcloud: fix restore_system arg passing
simondeziel Apr 12, 2024
841546a
test/suites/basic: create smaller c1/v1 instances
simondeziel Apr 11, 2024
05d2021
test/suites/basic: rename test_instances to test_instances_launch
simondeziel Apr 15, 2024
6647c2f
test/main: rename test_instances to test_instances_launch
simondeziel Apr 15, 2024
6044ed4
test/includes/microcloud: set suitable PATH in the profile
simondeziel Apr 15, 2024
c26b1e6
test/includes/microcloud: call new_system() in new_systems()
simondeziel Apr 15, 2024
1fc2abc
test/includes/microcloud: use wait even if CONCURRENT_SETUP!=1
simondeziel Apr 15, 2024
210ba10
test/suites/basic: use less subshells in test_instances_launch()
simondeziel Apr 15, 2024
cc1f5f6
test/suites/basic: add test_instances_config() test
simondeziel Apr 15, 2024
28f140d
test/suites/preseed: use less subshells
simondeziel Apr 15, 2024
a21f3a6
test/main: add test_instances_config
simondeziel Apr 15, 2024
552cc7d
test/suites/basic: optionally skip launching VMs on microcloud
simondeziel Apr 15, 2024
603022d
github: skip launching VMs on top of microcloud VMs
simondeziel Apr 15, 2024
5718473
test/suites/basic: fix TEST_CONSOLE=0
simondeziel Apr 15, 2024
51bb646
test/suites/preseed: fix TEST_CONSOLE=0
simondeziel Apr 15, 2024
5913911
test/suites/add: reduce subshell use
simondeziel Apr 16, 2024
bb2da36
test/includes/microcloud: safer grep
simondeziel Apr 16, 2024
b357b8d
test/suites/add: less subshells
simondeziel Apr 16, 2024
8bf8980
test/suites/basic: safer grep
simondeziel Apr 16, 2024
05237c6
test/suites/basic: less subshells
simondeziel Apr 16, 2024
05edfae
test/main: running single test case also require the new_systems call
simondeziel Apr 16, 2024
acb3363
test/suites/basic: s/test_case/_test_case/ as it's not an actual test…
simondeziel Apr 16, 2024
ea238de
test/main: rework how individual/group test(s) are run
simondeziel Apr 16, 2024
4bc8ba5
github: split system tests into suites
simondeziel Apr 16, 2024
f488f18
test/includes/microcloud: only take a snapshot if SNAPSHOT_RESTORE=1
simondeziel Apr 16, 2024
2d2333d
test/includes/microcloud: use cohorts for micro{ceph,ovn,cloud} too
simondeziel Apr 16, 2024
1655238
test/includes/microcloud: workaround for LXD shutdown bug (debug)
simondeziel Apr 16, 2024
867fd0a
test/includes/microcloud: add some echos to set_debug_binaries()
simondeziel Apr 16, 2024
4badb3f
test/includes/microcloud: poll less aggressively in lxd_wait_vm()
simondeziel Apr 16, 2024
faf9cf1
test/includes/microcloud: less subshells
simondeziel Apr 17, 2024
f6cd47a
test/includes/microcloud: use LXD latest/edge (https://github.com/can…
simondeziel Apr 17, 2024
a4d84df
test/includes/microcloud: safer grep
simondeziel Apr 17, 2024
d4cd4c3
test/includes/microcloud: safer grep for matching numeric args
simondeziel Apr 18, 2024
c72c720
test/includes/microcloud: use quiet file pushes
simondeziel Apr 18, 2024
a74a6d9
github: sideload microcloud{,d} binaries for system-tests
simondeziel Apr 17, 2024
78f92bc
test/suites/basic: add test OVN connectivity
simondeziel Apr 18, 2024
c1eef92
test/suites/basic: use smaller rootfs
simondeziel Apr 18, 2024
a827156
test/includes/microcloud: simplify rm -rf globbing
simondeziel Apr 18, 2024
a565f16
microcloud/test: Only run mismatch
masnax Apr 18, 2024
3067243
microcloud/test/suites: Run interactive first
masnax Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 125 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ on:
- main
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
# Make sure bash is always invoked with `-eo pipefail`
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash

jobs:
code-tests:
name: Code tests
name: Code
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -21,12 +30,6 @@ jobs:
uses: actions/dependency-review-action@v4
if: github.event_name == 'pull_request'

- name: Check compatibility with min Go version (${{ matrix.go }})
if: matrix.go == '1.22.x'
run: |
set -eux
go mod tidy -go=1.22.0

- id: ShellCheck
name: Differential ShellCheck
uses: redhat-plumbers-in-action/differential-shellcheck@v5
Expand All @@ -46,6 +49,12 @@ jobs:
with:
go-version: 1.22.x

- name: Check compatibility with min Go version (1.22.0)
working-directory: microcloud
run: |
set -eux
go mod tidy -go=1.22.0

- name: Install dependencies
run: |
sudo add-apt-repository ppa:dqlite/dev -y --no-update
Expand All @@ -64,6 +73,113 @@ jobs:
working-directory: microcloud
run: make check-unit

system-tests:
env:
DEBUG: "1"
SKIP_VM_LAUNCH: "1"
SNAPSHOT_RESTORE: "1"
name: System
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
go: ["1.22.x"]
suite: ["add", "basic", "preseed"]

steps:
- name: Performance tuning
run: |
set -eux
# optimize ext4 FSes for performance, not reliability
for fs in $(findmnt --noheading --type ext4 --list --uniq | awk '{print $1}'); do
# nombcache and data=writeback cannot be changed on remount
sudo mount -o remount,noatime,barrier=0,commit=6000 "${fs}" || true
done

# disable dpkg from calling sync()
echo "force-unsafe-io" | sudo tee /etc/dpkg/dpkg.cfg.d/force-unsafe-io

- name: Reclaim some space
run: |
set -eux

sudo snap remove lxd --purge
# Purge older snap revisions that are disabled/superseded by newer revisions of the same snap
snap list --all | while read -r name _ rev _ _ notes _; do
[[ "${notes}" =~ disabled$ ]] && sudo snap remove "${name}" --revision "${rev}" --purge
done || true

# This was inspired from https://github.com/easimon/maximize-build-space
df -h /
# dotnet
sudo rm -rf /usr/share/dotnet
# android
sudo rm -rf /usr/local/lib/android
# haskell
sudo rm -rf /opt/ghc
df -h /

- name: Remove docker
run: |
set -eux
sudo apt-get autopurge -y containerd.io moby-containerd docker docker-ce podman uidmap
sudo ip link delete docker0
sudo nft flush ruleset

- name: Checkout
uses: actions/checkout@v4

- name: Install Go (${{ matrix.go }})
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Install dependencies
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

- name: Build
working-directory: microcloud
run: make

- name: "Run system tests (${{ matrix.go }}, ${{ matrix.suite }})"
run: |
set -eux

# 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"
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}"

# Setup host LXD
sudo snap install lxd --channel 5.21/stable || sudo snap refresh lxd --channel 5.21/stable
sudo lxd init --auto

# Binaries to sideload
export MICROCLOUD_DEBUG_PATH=~/go/bin/microcloud
export MICROCLOUDD_DEBUG_PATH=~/go/bin/microcloudd

# strip debug binaries
strip -s "${MICROCLOUD_DEBUG_PATH}" "${MICROCLOUDD_DEBUG_PATH}"

chmod +x ~
cd microcloud/test
sudo --preserve-env=DEBUG,GITHUB_ACTIONS,MICROCLOUD_DEBUG_PATH,MICROCLOUDD_DEBUG_PATH,SKIP_VM_LAUNCH,SNAPSHOT_RESTORE,TEST_STORAGE_SOURCE ./main.sh ${{ matrix.suite }}

documentation-checks:
uses: canonical/documentation-workflows/.github/workflows/documentation-checks.yaml@main
with:
Expand All @@ -72,7 +188,7 @@ jobs:
snap:
name: Trigger snap edge build
runs-on: ubuntu-22.04
needs: [code-tests, documentation-checks]
needs: [code-tests, system-tests, documentation-checks]
if: ${{ github.repository == 'canonical/microcloud' && github.event_name == 'push' && github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout code
Expand All @@ -93,7 +209,7 @@ jobs:
ssh-keyscan git.launchpad.net >> ~/.ssh/known_hosts
ssh-keygen -qlF git.launchpad.net | grep -xF 'git.launchpad.net RSA SHA256:UNOzlP66WpDuEo34Wgs8mewypV0UzqHLsIFoqwe8dYo'

- name: Install Go
- name: Install Go (${{ matrix.go }})
uses: actions/setup-go@v5
with:
go-version: 1.22.x
Expand Down
6 changes: 6 additions & 0 deletions microcloud/test/includes/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ check_dependencies() {
echo "Missing dependencies: $missing" >&2
exit 1
fi

# Instances need to be able to self-report on their state
if ! lxc info | sed -ne '/^api_extensions:/,/^[^-]/ s/^- //p' | grep -qxF "instance_ready_state"; then
echo "Missing LXD instance_ready_state extension" >&2
exit 1
fi
}

check_empty() {
Expand Down
Loading
Loading