Skip to content

Commit 7e451a0

Browse files
author
Adam Dyess
authored
chore: bump versions of things to support testing of this charm again (#16)
* chore: bump action versions in tests workflow * Build with charmcraft 2.x/stable * Update to run only on jammy LTS * Upgrade charm and tests to juju3 standards
1 parent 1a0ff15 commit 7e451a0

12 files changed

Lines changed: 57 additions & 109 deletions

File tree

.charmcraft-channel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.x/stable

.github/workflows/tests.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [pull_request]
44
jobs:
55
call-inclusive-naming-check:
66
name: Inclusive naming
7-
uses: canonical-web-and-design/Inclusive-naming/.github/workflows/woke.yaml@main
7+
uses: canonical/inclusive-naming/.github/workflows/woke.yaml@main
88
with:
99
fail-on-error: "true"
1010

@@ -14,28 +14,29 @@ jobs:
1414
needs:
1515
- call-inclusive-naming-check
1616
with:
17-
python: "['3.8', '3.9', '3.10']"
17+
python: "['3.10', '3.12']"
1818

1919
integration-test:
2020
name: Integration tests
21-
runs-on: ubuntu-22.04
21+
runs-on: ubuntu-latest
2222
needs:
2323
- lint-unit
2424
steps:
2525
- name: Check out code
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727
- name: Setup Python
28-
uses: actions/setup-python@v4
28+
uses: actions/setup-python@v6
2929
with:
30-
python-version: 3.8
31-
- name: Install Dependencies
32-
run: |
33-
pip install tox
30+
python-version: 3.12
31+
- name: Read charmcraft version file
32+
id: charmcraft
33+
run: echo "channel=$(cat .charmcraft-channel)" >> $GITHUB_OUTPUT
3434
- name: Setup operator environment
3535
uses: charmed-kubernetes/actions-operator@main
3636
with:
37-
provider: microk8s
38-
channel: 1.26/stable
37+
provider: microk8s
38+
channel: 1.34-strict/stable
39+
charmcraft-channel: ${{ steps.charmcraft.outputs.channel }}
3940
- name: Run test
4041
run: tox -e integration
4142
- name: Setup Debug Artifact Collection
@@ -50,7 +51,7 @@ jobs:
5051
run: sudo juju debug-log --replay --no-tail -i gatekeeper-manager-operator | tee tmp/unit-gatekeeper-manager-operator-0.log
5152
- name: Upload debug artifacts
5253
if: ${{ failure() }}
53-
uses: actions/upload-artifact@v2
54+
uses: actions/upload-artifact@v4
5455
with:
5556
name: test-run-artifacts
5657
path: tmp

opa-audit-operator/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ there are multiple ways to gather the audit results. The opa-audit-operator prov
3737
to make it easier.
3838
Any namespaces violating a constraint can be listed using the `get-violation` action, e.g. for the constraint described above:
3939
```
40-
juju run-action gatekeeper-audit/0 get-violation constraint-template=K8sRequiredLabels constraint=ns-must-have-gk --wait
40+
juju run gatekeeper-audit/0 get-violation constraint-template=K8sRequiredLabels constraint=ns-must-have-gk --wait
4141
```
4242

4343
To see how many resources violate each policy you need to run:
4444
```
45-
juju run-action gatekeeper-audit/0 list-violations --wait
45+
juju run gatekeeper-audit/0 list-violations --wait
4646
```
4747

4848
### List policies
4949
To list all the policies that are currently applied run:
5050
```
51-
juju run-action {unit_name} list-constraints --wait
51+
juju run {unit_name} list-constraints --wait
5252
```
5353

5454
## Developing

opa-audit-operator/charmcraft.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@ type: charm
22
bases:
33
- build-on:
44
- name: "ubuntu"
5-
channel: "20.04"
5+
channel: "22.04"
66
architectures: ["amd64"]
77
run-on:
8-
- name: "ubuntu"
9-
channel: "20.04"
10-
architectures:
11-
- amd64
12-
- arm
13-
- arm64
148
- name: "ubuntu"
159
channel: "22.04"
1610
architectures:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ops
2-
lightkube
1+
ops >= 2.2.0,<3.0
2+
lightkube>=0.10.1,<0.18.0
33
lightkube-models
4-
git+https://github.com/canonical/ops-lib-manifest.git@a02d83af8febeed39b7324b0247368cfc7105d73
4+
ops.manifest>=1.1.0,<2.0.0

opa-audit-operator/src/charm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _on_update_status(self, event):
170170
elif self.manifests.resources != self.manifests.installed_resources():
171171
self.unit.status = BlockedStatus(
172172
"Missing resources, to reconcile run: "
173-
f"`juju run-action {self.unit.name} reconcile-resources`"
173+
f"`juju run {self.unit.name} reconcile-resources`"
174174
)
175175
elif unready := self.collector.unready:
176176
# Wait for all installed resource to be ready

opa-audit-operator/tests/integration/test_charm.py

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,9 @@ class TestPolicies:
135135
async def test_list_no_violations(self, ops_test):
136136
"""This will run before the resources have been audited"""
137137
unit = list(ops_test.model.units.values())[0]
138-
unit_name = unit.name
139-
res = await ops_test.juju(
140-
"run-action",
141-
unit_name,
142-
"list-violations",
143-
"--wait",
144-
"-m",
145-
ops_test.model.info.name,
146-
)
147-
res = yaml.full_load(res[1])[unit.tag]
148-
violations = json.loads(res["results"]["constraint-violations"])
138+
action = await unit.run_action("list-violations")
139+
res = await action.wait()
140+
violations = yaml.safe_load(res.results["constraint-violations"])
149141
assert len(violations) == 2, json.dumps(violations, indent=2)
150142
assert any(
151143
v
@@ -191,18 +183,11 @@ async def test_audit(self, ops_test, client):
191183

192184
async def test_list_violations(self, ops_test):
193185
unit = list(ops_test.model.units.values())[0]
194-
unit_name = unit.name
195-
res = await ops_test.juju(
196-
"run-action",
197-
unit_name,
198-
"list-violations",
199-
"--wait",
200-
"-m",
201-
ops_test.model.info.name,
202-
)
203-
res = yaml.full_load(res[1])[unit.tag]
204-
violations = json.loads(res["results"]["constraint-violations"])
205-
assert res["status"] == "completed"
186+
action = await unit.run_action("list-violations")
187+
res = await action.wait()
188+
violations = yaml.safe_load(res.results["constraint-violations"])
189+
190+
assert res.status == "completed"
206191
assert len(violations) == 2
207192
assert any(
208193
violation["constraint"] == "ns-must-have-gk"
@@ -228,21 +213,19 @@ async def test_get_violations(self, ops_test):
228213
}
229214

230215
unit = list(ops_test.model.units.values())[0]
231-
unit_name = unit.name
232-
res = await ops_test.juju(
233-
"run-action",
234-
unit_name,
216+
action = await unit.run_action(
235217
"get-violation",
236-
"constraint-template=K8sRequiredLabels",
237-
"constraint=ns-must-have-gk",
238-
"--wait",
239-
"-m",
240-
ops_test.model.info.name,
218+
**{
219+
"constraint-template": "K8sRequiredLabels",
220+
"constraint": "ns-must-have-gk",
221+
},
222+
)
223+
res = await action.wait()
224+
violations = yaml.safe_load(res.results["violations"])
225+
assert res.status == "completed"
226+
assert any(v == expected_model_violation for v in violations), json.dumps(
227+
violations, indent=2
241228
)
242-
res = yaml.full_load(res[1])[unit.tag]
243-
violations = json.loads(res["results"]["violations"])
244-
assert res["status"] == "completed"
245-
assert any(v == expected_model_violation for v in violations)
246229

247230
async def test_reconciliation_required(self, ops_test, client):
248231
model = ops_test.model
@@ -254,18 +237,9 @@ async def test_reconciliation_required(self, ops_test, client):
254237
)
255238

256239
unit = list(ops_test.model.units.values())[0]
257-
unit_name = unit.name
258-
res = await ops_test.juju(
259-
"run-action",
260-
unit_name,
261-
"reconcile-resources",
262-
"--wait",
263-
"-m",
264-
ops_test.model.info.name,
265-
)
266-
267-
res = yaml.full_load(res[1])[unit.tag]
268-
assert res["status"] == "completed"
240+
action = await unit.run_action("reconcile-resources")
241+
res = await action.wait()
242+
assert res.status == "completed"
269243
await model.wait_for_idle(
270244
apps=["gatekeeper-audit"], status="active", timeout=60
271245
)

opa-manager-operator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Existing namespaces are not affected by this.
3737
### Getting policies
3838
To list all the policies that are currently applied run:
3939
```
40-
juju run-action {unit_name} list-constraints --wait
40+
juju run {unit_name} list-constraints --wait
4141
```
4242

4343
## Developing

opa-manager-operator/charmcraft.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@ type: charm
22
bases:
33
- build-on:
44
- name: "ubuntu"
5-
channel: "20.04"
5+
channel: "22.04"
66
architectures: ["amd64"]
77
run-on:
8-
- name: "ubuntu"
9-
channel: "20.04"
10-
architectures:
11-
- amd64
12-
- arm
13-
- arm64
148
- name: "ubuntu"
159
channel: "22.04"
1610
architectures:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ops
2-
lightkube
1+
ops >= 2.2.0,<3.0
2+
lightkube>=0.10.1,<0.18.0
33
lightkube-models
4-
git+https://github.com/canonical/ops-lib-manifest.git@a02d83af8febeed39b7324b0247368cfc7105d73
4+
ops.manifest>=1.1.0,<2.0.0

0 commit comments

Comments
 (0)