Skip to content

Commit

Permalink
fix: Change juju 3 support strategy
Browse files Browse the repository at this point in the history
- Now all juju 3 will use 3/stable snap release
- Update functional test to run all the supported versions by
zaza
- Drop bionic support
  • Loading branch information
jneo8 committed Apr 9, 2024
1 parent 0a19cd7 commit cf6034b
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 36 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ jobs:
include:
- juju-channel: '2.9/stable'
command: 'make functional'
- juju-channel: '3.1/stable'
command: 'make functional31'
- juju-channel: '3.2/stable'
command: 'make functional32'
- juju-channel: '3.3/stable'
command: 'make functional33-jammy'
- juju-channel: '3.3/stable'
command: 'make functional33-focal'
command: 'make functional33'
with:
command: ${{ matrix.command }}
juju-channel: ${{ matrix.juju-channel }}
Expand Down
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ help:
@echo " make reformat - run lint tools to auto format code"
@echo " make unittests - run the tests defined in the unittest subdirectory"
@echo " make functional - run the tests defined in the functional subdirectory"
@echo " make functional31 - run the tests defined in the functional subdirectory with juju 3.1 requirements"
@echo " make functional32 - run the tests defined in the functional subdirectory with juju 3.2 requirements"
@echo " make functional33 - run the tests defined in the functional subdirectory with juju 3.3 requirements"
@echo " make test - run lint, unittests and functional targets"
@echo ""
Expand Down Expand Up @@ -77,16 +79,20 @@ functional: build
@echo "Executing functional tests using built charm at ${PROJECTPATH}"
@CHARM_LOCATION=${PROJECTPATH} tox -e func -- ${FUNC_ARGS}

functional33-jammy: build
@echo "Executing functional tests using built charm at ${PROJECTPATH} with juju 3.3 requirements"
@CHARM_LOCATION=${PROJECTPATH} tox -e func33-jammy -- ${FUNC_ARGS}
functional31: build
@echo "Executing functional tests using built charm at ${PROJECTPATH} with juju 3.1 requirements"
@CHARM_LOCATION=${PROJECTPATH} tox -e func31 -- ${FUNC_ARGS}

functional32: build
@echo "Executing functional tests using built charm at ${PROJECTPATH} with juju 3.2 requirements"
@CHARM_LOCATION=${PROJECTPATH} tox -e func32 -- ${FUNC_ARGS}

functional33-focal: build
functional33: build
@echo "Executing functional tests using built charm at ${PROJECTPATH} with juju 3.3 requirements"
@CHARM_LOCATION=${PROJECTPATH} tox -e func33-focal -- ${FUNC_ARGS}
@CHARM_LOCATION=${PROJECTPATH} tox -e func33 -- ${FUNC_ARGS}

test: lint unittests functional
@echo "Tests completed for charm ${CHARM_NAME}."

# The targets below don't depend on a file
.PHONY: help dev-environment pre-commit submodules submodules-update clean build lint reformat unittests functional functional33-jammy functional33-focal
.PHONY: help dev-environment pre-commit submodules submodules-update clean build lint reformat unittests functional functional31 functional32 functional33
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
charmhelpers
packaging
# pin ops framework version to
# support bionic deployments
ops >= 1.5.0,< 2.0.0
ops
3 changes: 1 addition & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ def snap_channel(self) -> str:
if controller_version.minor == 9:
return "2.9/stable"
elif controller_version.major == 3:
if controller_version.minor in [1, 2, 3, 4, 5]:
return f"3.{controller_version.minor}/stable"
return "3/stable"

raise ControllerIncompatibleError(
f"Juju controller version {str(controller_version)} is not supported. "
Expand Down
1 change: 0 additions & 1 deletion tests/functional/tests/bundles/bionic.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/functional/tests/bundles/overlays/bionic.yaml.j2

This file was deleted.

2 changes: 1 addition & 1 deletion tests/functional/tests/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def add_machines(self, count: int, timeout: int = 600) -> None:

@tenacity.retry(
wait=tenacity.wait_fixed(5),
stop=tenacity.stop_after_attempt(12),
stop=tenacity.stop_after_attempt(20),
)
def validate_exporter(self, expected_machine_count: int = 1) -> None:
"""Verify that exporter exposes expected data on '/metrics' endpoint.
Expand Down
1 change: 0 additions & 1 deletion tests/functional/tests/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ charm_name: prometheus-juju-exporter
gate_bundles:
- jammy
- focal
- bionic

tests:
- tests.test_charm.BasicPrometheusJujuExporterTests
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ def test_snap_path_property(resource_exists, resource_size, is_path_expected, ha
("2.7.6", "2.8/stable"), # In case controller version is 2.7.x, return 2.8/stable
("2.8.8", "2.8/stable"), # In case controller version is 2.8.x, return 2.8/stable
("2.9.42.2", "2.9/stable"), # In case controller version is 2.9.x, return 2.9/stable
("3.1.5", "3.1/stable"), # In case controller version is 3.1.5, return 3.1/stable
("3.2.5", "3.2/stable"), # In case controller version is 3.2.5, return 3.2/stable
("3.3.4", "3.3/stable"), # In case controller version is 3.3.4, return 3.3/stable
("3.4.1", "3.4/stable"), # In case controller version is 3.4.1, return 3.4/stable
("3.1.5", "3/stable"), # In case controller version is 3.1.5, return 3/stable
("3.2.5", "3/stable"), # In case controller version is 3.2.5, return 3/stable
("3.3.4", "3/stable"), # In case controller version is 3.3.4, return 3/stable
("3.4.1", "3/stable"), # In case controller version is 3.4.1, return 3/stable
("3.5.0", "3/stable"), # In case controller version is 3.5.0, return 3/stable
],
)
def test_snap_channel_property(controller_version, channel, harness, mocker):
Expand All @@ -93,7 +94,6 @@ def test_snap_channel_property(controller_version, channel, harness, mocker):
"controller_version",
[
"2.5.5", # Controller version too low
"3.0.1", # Controller version too high
],
)
def test_snap_channel_property_incompatible_controller(controller_version, harness, mocker):
Expand Down
28 changes: 16 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -80,33 +80,37 @@ deps =
setenv =
TEST_JUJU_CHANNEL = 2.9/stable
changedir = {toxinidir}/tests/functional
commands = functest-run-suite
commands = functest-run-suite {posargs:--keep-faulty-model}
deps =
git+https://github.com/openstack-charmers/zaza.git#egg=zaza
-r {toxinidir}/tests/functional/requirements.txt

[testenv:func33-jammy]
[testenv:func31]
setenv =
TEST_JUJU_CHANNEL = 3.3/stable
changedir = {toxinidir}/tests/functional
commands =
# NOTE(mertkirpici): functest-run-suite -b jammy focal
# or functest-run-suite -b jammy -b focal does not work
# https://github.com/openstack-charmers/zaza/issues/614
functest-run-suite -b jammy
functest-run-suite {posargs:--keep-faulty-model}
deps =
git+https://github.com/openstack-charmers/[email protected]#egg=zaza[juju-33]
git+https://github.com/openstack-charmers/[email protected]#egg=zaza[juju-31]
-r {toxinidir}/tests/functional/requirements.txt

[testenv:func32]
setenv =
TEST_JUJU_CHANNEL = 3.3/stable
changedir = {toxinidir}/tests/functional
commands =
functest-run-suite {posargs:--keep-faulty-model}
deps =
git+https://github.com/openstack-charmers/[email protected]#egg=zaza[juju-32]
-r {toxinidir}/tests/functional/requirements.txt

[testenv:func33-focal]
[testenv:func33]
setenv =
TEST_JUJU_CHANNEL = 3.3/stable
changedir = {toxinidir}/tests/functional
commands =
# NOTE(mertkirpici): functest-run-suite -b jammy focal
# or functest-run-suite -b jammy -b focal does not work
# https://github.com/openstack-charmers/zaza/issues/614
functest-run-suite -b focal
functest-run-suite {posargs:--keep-faulty-model}
deps =
git+https://github.com/openstack-charmers/[email protected]#egg=zaza[juju-33]
-r {toxinidir}/tests/functional/requirements.txt

0 comments on commit cf6034b

Please sign in to comment.