Skip to content

Commit

Permalink
Run integration tests on multipass
Browse files Browse the repository at this point in the history
There are a few issues running the Longhorn integration tests on an LXD
runner, as we currently are, mainly having to do with ISCSI volumes
being exposed and mounted in LXD.

Running on host has its own issues, mainly the Pods have cluster-wide
connectivity issues.

Instead, we'll be testing Longhorn in a multipass VM. We also remove
some of the GitHub runner's bloat in order to free up sufficient space
for the VM and test. Note that according to the Longhorn deployment
guide, Longhorn requires 25% of the root disk to be available (if no
other disks are available).
  • Loading branch information
claudiubelu committed Sep 16, 2024
1 parent 60f7d7b commit 67bb6a0
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
platform-labels: '{"arm64": ["self-hosted", "Linux", "ARM64", "jammy"]}'

run-tests:
uses: canonical/k8s-workflows/.github/workflows/run_tests.yaml@main
uses: ./.github/workflows/run_tests.yaml
needs: [build-and-push-arch-specifics]
secrets: inherit
with:
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Run rocks tests

on:
workflow_call:
inputs:
rock-metas:
description: List of maps featuring the built {name, version, path, arch, image}
type: string
default: "[]"

jobs:
run-tests:
if: ${{ inputs.rock-metas != '[]' }}
name: Run tests
runs-on: ubuntu-22.04
steps:
- name: Maximize build space
uses: AdityaGarg8/remove-unwanted-software@v4.1
with:
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-swapfile: 'true'
- name: Checkout repository
uses: actions/checkout@v4.1.1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Setup environment
run: |
sudo apt-get update
sudo apt-get install -y jq
pip install tox
- name: Install multipass
run: |
set -x
sudo snap install multipass
# We need to authenticate into multipass, since we're not running as root.
# https://github.com/canonical/multipass/issues/1437#issuecomment-1435357872
sudo multipass set local.passphrase=Passw0rd
# If we auth too soon, we might get this error:
# authenticate failed: cannot connect to the multipass socket
sleep 3
multipass auth Passw0rd
- name: Set rock image environment variables
run: |
# NOTE(aznashwan): these env var names are maintained for backwards
# compatibility, but new tests should ideally use the utility functions
# from the shared testing harnesss repository to directly read the
# values from the below-set BUILT_ROCKS_METADATA environment variable.
# https://github.com/canonical/k8s-test-harness/blob/main/k8s_test_harness/util/env_util.py
echo '${{ inputs.rock-metas }}' | jq -c '.[] | select(.arch == "amd64") ' | while read i; do
name=$(echo "$i" | jq -r '.name' | tr '[:lower:]' '[:upper:]' | tr '-' '_')
image=$(echo "$i" | jq -r '.image')
echo "ROCK_$name=$image" >> $GITHUB_ENV
done
- name: Run integration tests
env:
BUILT_ROCKS_METADATA: ${{ inputs.rock-metas }}
run: |
export TEST_SNAP_CHANNEL="latest/edge"
export TEST_SUBSTRATE=multipass
export TEST_MULTIPASS_MEMORY=6G
export TEST_MULTIPASS_DISK=40G
tox --conf tests/tox.ini -e integration

0 comments on commit 67bb6a0

Please sign in to comment.