Skip to content

Commit a47d34d

Browse files
Merge pull request #5008 from canonical/lpetrut/unblock-ci
2 parents 636c313 + 7c4bb20 commit a47d34d

File tree

5 files changed

+67
-94
lines changed

5 files changed

+67
-94
lines changed

.github/actions/test-prep/action.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Prepare test prerequisites
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Setup Python
7+
uses: actions/setup-python@v5
8+
with:
9+
python-version: "3.10"
10+
- name: Install test dependencies
11+
shell: bash
12+
run: |
13+
set -x
14+
sudo pip3 install -U pytest==8.3.4 sh psutil requests
15+
# Docker sets iptables rules that interfere with LXD and K8s.
16+
# https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
17+
- name: Apply Docker iptables workaround
18+
shell: bash
19+
run: sudo iptables -I DOCKER-USER -j ACCEPT
20+
- name: Fetch snap
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: microk8s.snap
24+
path: build

.github/workflows/build-snap.yml

+39-90
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
build:
1010
name: Create snap package
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-22.04
1212

1313
steps:
1414
- name: Checking out repo
@@ -18,6 +18,11 @@ jobs:
1818
sudo lxd init --auto
1919
sudo usermod --append --groups lxd $USER
2020
sg lxd -c 'lxc version'
21+
# Docker sets iptables rules that interfere with LXD or K8s.
22+
# https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
23+
- name: Apply Docker iptables workaround
24+
shell: bash
25+
run: sudo iptables -I DOCKER-USER -j ACCEPT
2126
- name: Install snapcraft
2227
run: |
2328
sudo snap install snapcraft --classic
@@ -37,138 +42,84 @@ jobs:
3742

3843
test-upgrade:
3944
name: Upgrade path test
40-
runs-on: ubuntu-20.04
45+
runs-on: ubuntu-22.04
4146
needs: build
42-
47+
timeout-minutes: 30
4348
steps:
4449
- name: Checking out repo
4550
uses: actions/checkout@v4
46-
- name: Install test dependencies
47-
run: |
48-
set -x
49-
sudo apt-get install python3-setuptools
50-
sudo pip3 install --upgrade pip
51-
sudo pip3 install -U pytest sh psutil
52-
sudo apt-get -y install open-iscsi
53-
sudo systemctl enable iscsid
54-
- name: Fetch snap
55-
uses: actions/download-artifact@v4
56-
with:
57-
name: microk8s.snap
58-
path: build
51+
- name: Prepare test prerequisites
52+
uses: ./.github/actions/test-prep
5953
- name: Running upgrade path test
6054
run: |
6155
sudo -E UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade-path.py
6256
6357
test-addons-core:
6458
name: Test core addons
65-
runs-on: ubuntu-20.04
59+
runs-on: ubuntu-22.04
6660
needs: build
67-
61+
timeout-minutes: 30
6862
steps:
6963
- name: Checking out repo
7064
uses: actions/checkout@v4
71-
- name: Install test dependencies
72-
run: |
73-
set -x
74-
sudo apt-get install python3-setuptools
75-
sudo pip3 install --upgrade pip
76-
sudo pip3 install -U pytest==8.3.4 sh psutil
77-
sudo apt-get -y install open-iscsi
78-
sudo systemctl enable iscsid
79-
- name: Fetch snap
80-
uses: actions/download-artifact@v4
81-
with:
82-
name: microk8s.snap
83-
path: build
65+
- name: Prepare test prerequisites
66+
uses: ./.github/actions/test-prep
8467
- name: Running addons tests
68+
env:
69+
UNDER_TIME_PRESSURE: ${{ !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}
8570
run: |
8671
set -x
8772
sudo snap install build/microk8s.snap --classic --dangerous
8873
./tests/smoke-test.sh
89-
export UNDER_TIME_PRESSURE="True"
9074
export SKIP_PROMETHEUS="False"
9175
sudo -E bash -c "cd /var/snap/microk8s/common/addons/core/tests; pytest -s -ra test-addons.py"
9276
9377
test-addons-community:
9478
name: Test community addons
95-
runs-on: ubuntu-20.04
79+
runs-on: ubuntu-22.04
9680
needs: build
97-
81+
timeout-minutes: 30
9882
steps:
9983
- name: Checking out repo
10084
uses: actions/checkout@v4
101-
- name: Install test dependencies
102-
run: |
103-
set -x
104-
sudo apt-get install python3-setuptools
105-
sudo pip3 install --upgrade pip
106-
sudo pip3 install -U pytest sh
107-
sudo apt-get -y install open-iscsi
108-
sudo systemctl enable iscsid
109-
- name: Fetch snap
110-
uses: actions/download-artifact@v4
111-
with:
112-
name: microk8s.snap
113-
path: build
114-
# - name: Setup tmate session
115-
# uses: mxschmitt/action-tmate@v3
85+
- name: Prepare test prerequisites
86+
uses: ./.github/actions/test-prep
11687
- name: Running addons tests
88+
env:
89+
UNDER_TIME_PRESSURE: ${{ !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}
11790
run: |
11891
set -x
11992
sudo snap install build/microk8s.snap --classic --dangerous
12093
sudo microk8s enable community
121-
export UNDER_TIME_PRESSURE="True"
12294
sudo -E bash -c "cd /var/snap/microk8s/common/addons/community/; pytest -s -ra ./tests/"
12395
12496
test-addons-core-upgrade:
12597
name: Test core addons upgrade
126-
runs-on: ubuntu-20.04
98+
runs-on: ubuntu-22.04
12799
needs: build
128-
100+
timeout-minutes: 30
129101
steps:
130102
- name: Checking out repo
131103
uses: actions/checkout@v4
132-
# - name: Setup tmate session
133-
# uses: mxschmitt/action-tmate@v3
134-
- name: Install test dependencies
135-
run: |
136-
set -x
137-
sudo apt-get install python3-setuptools
138-
sudo pip3 install --upgrade pip
139-
sudo pip3 install -U pytest sh psutil
140-
sudo apt-get -y install open-iscsi
141-
sudo systemctl enable iscsid
142-
- name: Fetch snap
143-
uses: actions/download-artifact@v4
144-
with:
145-
name: microk8s.snap
146-
path: build
104+
- name: Prepare test prerequisites
105+
uses: ./.github/actions/test-prep
147106
- name: Running upgrade tests
107+
env:
108+
UNDER_TIME_PRESSURE: ${{ !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}
148109
run: |
149110
set -x
150-
export UNDER_TIME_PRESSURE="True"
151111
sudo -E bash -c "UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade.py"
152112
153113
test-cluster-agent:
154114
name: Cluster agent health check
155-
runs-on: ubuntu-20.04
115+
runs-on: ubuntu-22.04
156116
needs: build
157-
117+
timeout-minutes: 30
158118
steps:
159119
- name: Checking out repo
160120
uses: actions/checkout@v4
161-
- name: Install test dependencies
162-
run: |
163-
set -x
164-
sudo apt-get install python3-setuptools
165-
sudo pip3 install --upgrade pip
166-
sudo pip3 install -U pytest sh requests
167-
- name: Fetch snap
168-
uses: actions/download-artifact@v4
169-
with:
170-
name: microk8s.snap
171-
path: build
121+
- name: Prepare test prerequisites
122+
uses: ./.github/actions/test-prep
172123
- name: Running cluster agent health check
173124
run: |
174125
set -x
@@ -177,17 +128,14 @@ jobs:
177128
178129
test-airgap:
179130
name: Test airgap installation
180-
runs-on: ubuntu-20.04
131+
runs-on: ubuntu-22.04
181132
needs: build
182-
133+
timeout-minutes: 30
183134
steps:
184135
- name: Checking out repo
185136
uses: actions/checkout@v4
186-
- name: Fetch snap
187-
uses: actions/download-artifact@v4
188-
with:
189-
name: microk8s.snap
190-
path: build
137+
- name: Prepare test prerequisites
138+
uses: ./.github/actions/test-prep
191139
- name: Initialize LXD
192140
run: |
193141
sudo lxd init --auto
@@ -196,12 +144,13 @@ jobs:
196144
sg lxd -c 'lxc version'
197145
- name: Run airgap tests
198146
run: |
199-
sudo -E bash -x -c "./tests/libs/airgap.sh --distro ubuntu:20.04 --channel $PWD/build/microk8s.snap"
147+
sudo -E bash -x -c "./tests/libs/airgap.sh --distro ubuntu:22.04 --channel $PWD/build/microk8s.snap"
200148
201149
security-scan:
202150
name: Security scan
203-
runs-on: ubuntu-20.04
151+
runs-on: ubuntu-22.04
204152
needs: build
153+
timeout-minutes: 30
205154
steps:
206155
- name: Checking out repo
207156
uses: actions/checkout@v4

tests/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kubernetes
22
jinja2
33
pylxd
4-
pytest
4+
pytest==8.3.4
55
pytest-xdist
66
pyyaml
77
sh

tests/test-upgrade-path.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestUpgradePath(object):
1919
"""
2020

2121
@pytest.mark.skipif(
22-
os.environ.get("UNDER_TIME_PRESSURE") == "True",
22+
os.environ.get("UNDER_TIME_PRESSURE", "").lower() == "true",
2323
reason="Skipping refresh path test as we are under time pressure",
2424
)
2525
def test_refresh_path(self):

tests/test-upgrade.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
upgrade_from = os.environ.get("UPGRADE_MICROK8S_FROM", "beta")
2727
# Have UPGRADE_MICROK8S_TO point to a file to upgrade to that file
2828
upgrade_to = os.environ.get("UPGRADE_MICROK8S_TO", "edge")
29-
under_time_pressure = os.environ.get("UNDER_TIME_PRESSURE", "False")
29+
under_time_pressure = os.environ.get("UNDER_TIME_PRESSURE", "false").lower()
3030

3131

3232
class TestUpgrade(object):
@@ -121,7 +121,7 @@ def test_upgrade(self):
121121
print("Will not test the metrics server")
122122

123123
# AMD64 only tests
124-
if platform.machine() == "x86_64" and under_time_pressure == "False":
124+
if platform.machine() == "x86_64" and under_time_pressure == "false":
125125
try:
126126
ip_ranges = (
127127
"192.168.0.105-192.168.0.105,192.168.0.110-192.168.0.111,192.168.1.240/28"

0 commit comments

Comments
 (0)