Skip to content

Commit 73a42dc

Browse files
[JUJU-2256] Add integration tests to github actions pinning juju 2.9 (#775)
* Add integration tests to github actions pinning juju 2.9 * Raise an error when Juju versions differs from 2.9.x
1 parent 0bafc11 commit 73a42dc

28 files changed

Lines changed: 111539 additions & 1189 deletions

.github/workflows/test.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Testing
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
name: Linter
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python:
12+
- "3.8"
13+
- "3.9"
14+
- "3.10"
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v3
18+
- name: Setup Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python }}
22+
- name: Install dependencies
23+
run: pip install tox
24+
- name: Run linter
25+
run: tox -e lint
26+
27+
unit-tests:
28+
needs: lint
29+
name: Unit tests
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
python:
34+
- "3.8"
35+
- "3.9"
36+
- "3.10"
37+
steps:
38+
- name: Check out code
39+
uses: actions/checkout@v3
40+
- name: Setup Python
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: ${{ matrix.python }}
44+
- name: Install dependencies
45+
run: pip install tox
46+
- name: Run unit tests
47+
run: tox -e py3
48+
49+
integration:
50+
name: Integration
51+
needs: [lint, unit-tests]
52+
timeout-minutes: 120
53+
runs-on: ubuntu-latest
54+
strategy:
55+
matrix:
56+
python:
57+
- "3.8"
58+
- "3.9"
59+
- "3.10"
60+
steps:
61+
- name: Check out code
62+
uses: actions/checkout@v3
63+
- name: Setup operator environment
64+
uses: charmed-kubernetes/actions-operator@main
65+
with:
66+
provider: lxd
67+
juju-channel: 2.9/stable
68+
- name: Set proxy in controller
69+
run: |
70+
set -euxo pipefail
71+
# build a squid config file
72+
CONTROLLER_IP=$(juju list-controllers --format yaml | yq '.controllers[.current-controller].recent-server' | awk -F '[:]' '{print $1}');
73+
echo "Controller IP is: $CONTROLLER_IP"
74+
PROXY=$CONTROLLER_IP:3128
75+
echo "Proxy address is: $PROXY"
76+
echo "acl all src all" > squid.conf
77+
echo "http_access allow all" >> squid.conf
78+
echo "http_port $PROXY" >> squid.conf
79+
cat squid.conf
80+
# copy to the controller and reconfigure it
81+
juju status -m controller
82+
juju switch controller
83+
juju ssh 0 "sudo apt-get install squid -y"
84+
juju scp squid.conf 0:/tmp/squid.conf
85+
juju ssh 0 "sudo mv /tmp/squid.conf /etc/squid/squid.conf"
86+
juju ssh 0 "sudo squid -k reconfigure"
87+
# Test curl after waiting
88+
sleep 10
89+
echo "Test proxy access"
90+
curl -s -o /dev/null -w "%{http_code}" --proxy http://$PROXY https://charmhub.io
91+
# set model defaults
92+
juju model-defaults apt-http-proxy=$PROXY apt-https-proxy=$PROXY juju-http-proxy=$PROXY juju-https-proxy=$PROXY snap-http-proxy=$PROXY snap-https-proxy=$PROXY
93+
juju model-defaults
94+
- name: Setup Python
95+
uses: actions/setup-python@v4
96+
with:
97+
python-version: ${{ matrix.python }}
98+
- name: Install dependencies
99+
run: pip install tox
100+
- name: Run integration
101+
# Force one single concurrent test
102+
run: tox -e integration -- -n 1

.github/workflows/tox.yaml

Lines changed: 0 additions & 50 deletions
This file was deleted.

docs/readme.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ Documentation: https://pythonlibjuju.readthedocs.io/en/latest/
1111
Requirements
1212
------------
1313

14-
* Python 3.5+
15-
* Juju 2.0+
14+
This version may support old versions of Juju. However, it has been
15+
tested with the following requirements.
16+
17+
* Python 3.8/3.9/3.10
18+
* Juju 2.9.37
1619

1720

1821
Design Notes

examples/unitrun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ async def main():
2727
await model.connect()
2828

2929
app = await model.deploy(
30-
'cs:ubuntu-0',
30+
'jammy',
3131
application_name='ubuntu',
32-
series='trusty',
32+
series='jammy',
3333
channel='stable',
3434
)
3535

juju/client/_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ class EntityWatcherFacade(TypeFactory):
259259
pass
260260

261261

262+
class EnvironUpgraderFacade(TypeFactory):
263+
pass
264+
265+
262266
class ExternalControllerUpdaterFacade(TypeFactory):
263267
pass
264268

0 commit comments

Comments
 (0)