Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 7 additions & 3 deletions .github/actions/test-prep/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ runs:
- name: Install test dependencies
shell: bash
run: |
set -x
sudo apt-get remove -y python3-yaml
sudo pip3 install -r ./tests/requirements.txt
set -eux
python -m venv "$RUNNER_TEMP/microk8s-test-venv"
"$RUNNER_TEMP/microk8s-test-venv/bin/python" -m pip install --upgrade pip
"$RUNNER_TEMP/microk8s-test-venv/bin/python" -m pip install \
-r ./tests/requirements.txt
echo "MICROK8S_TEST_VENV=$RUNNER_TEMP/microk8s-test-venv" >> "$GITHUB_ENV"
echo "$RUNNER_TEMP/microk8s-test-venv/bin" >> "$GITHUB_PATH"
# Docker sets iptables rules that interfere with LXD and K8s.
# https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
- name: Apply Docker iptables workaround
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ jobs:
uses: ./.github/actions/test-prep
- name: Running upgrade path test
run: |
sudo -E UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade-path.py
sudo -E env \
UPGRADE_MICROK8S_FROM=latest/edge \
UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap \
"$MICROK8S_TEST_VENV/bin/pytest" -s ./tests/test-upgrade-path.py

test-addons-core:
name: Test core addons
Expand Down Expand Up @@ -82,7 +85,9 @@ jobs:
export POD_GATEWAY="10.200.0.1"
export SKIP_PROMETHEUS="False"
export UNDER_TIME_PRESSURE=${UNDER_TIME_PRESSURE@u}
sudo -E bash -c "cd /var/snap/microk8s/common/addons/core/tests; pytest -s -ra test-addons.py"
sudo -E bash -c \
"cd /var/snap/microk8s/common/addons/core/tests && \
exec \"$MICROK8S_TEST_VENV/bin/pytest\" -s -ra test-addons.py"

test-addons-community:
name: Test community addons
Expand All @@ -102,7 +107,9 @@ jobs:
sudo snap install build/microk8s.snap --classic --dangerous
sudo microk8s enable community
export UNDER_TIME_PRESSURE=${UNDER_TIME_PRESSURE@u}
sudo -E bash -c "cd /var/snap/microk8s/common/addons/community/; pytest -s -ra ./tests/"
sudo -E bash -c \
"cd /var/snap/microk8s/common/addons/community && \
exec \"$MICROK8S_TEST_VENV/bin/pytest\" -s -ra ./tests/"

test-addons-core-upgrade:
name: Test core addons upgrade
Expand All @@ -120,7 +127,11 @@ jobs:
run: |
set -x
export UNDER_TIME_PRESSURE=${UNDER_TIME_PRESSURE@u}
sudo -E bash -c "UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade.py"

sudo -E env \
UPGRADE_MICROK8S_FROM=latest/edge \
UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap \
"$MICROK8S_TEST_VENV/bin/pytest" -s ./tests/test-upgrade.py

test-cluster-agent:
name: Cluster agent health check
Expand All @@ -136,7 +147,8 @@ jobs:
run: |
set -x
sudo snap install build/microk8s.snap --classic --dangerous
sudo -E bash -c "pytest -s ./tests/test-cluster-agent.py"
sudo -E "$MICROK8S_TEST_VENV/bin/pytest" \
-s ./tests/test-cluster-agent.py

test-airgap:
name: Test airgap installation
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/check-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,30 @@ jobs:
- name: Check out code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install dependencies
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"

- name: Install dependencies in venv
run: |
sudo apt-get update
sudo apt-get install tox --fix-missing
sudo pip3 install -U pytest==7.1.3 sh==1.14.3
set -eux
venv="$RUNNER_TEMP/microk8s-unit-test-venv"
python -m venv "$venv"
"$venv/bin/python" -m pip install --upgrade pip
"$venv/bin/python" -m pip install \
-r tests/requirements.txt \
tox \
pytest==7.1.3 \
sh==1.14.3
echo "MICROK8S_UNIT_TEST_VENV=$venv" >> "$GITHUB_ENV"

- name: Check Units
run: |
tox -e scripts
tox -e wrappers
tox -e cluster
"$MICROK8S_UNIT_TEST_VENV/bin/tox" -e scripts
"$MICROK8S_UNIT_TEST_VENV/bin/tox" -e wrappers
"$MICROK8S_UNIT_TEST_VENV/bin/tox" -e cluster

- name: Verify branches
run: |
pytest -s ./tests/verify-branches.py
"$MICROK8S_UNIT_TEST_VENV/bin/pytest" -s ./tests/verify-branches.py
Loading
Loading