Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change juju 3 support strategy #50

Closed
Closed
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
9 changes: 6 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ jobs:
include:
- juju-channel: '2.9/stable'
command: 'make functional'
- juju-channel: '3.1/stable'
command: 'TEST_JUJU_CHANNEL=3.1/stable make functional3'
- juju-channel: '3.2/stable'
command: 'TEST_JUJU_CHANNEL=3.2/stable make functional3'
- juju-channel: '3.3/stable'
command: 'make functional33-jammy'
- juju-channel: '3.3/stable'
command: 'make functional33-focal'
command: 'TEST_JUJU_CHANNEL=3.3/stable make functional3'

with:
command: ${{ matrix.command }}
juju-channel: ${{ matrix.juju-channel }}
Expand Down
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
RELEASE_CHANNEL:=edge
METADATA_FILE="metadata.yaml"
CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E '^name:' | awk '{print $$2}')
TEST_JUJU_CHANNEL ?= "3.3/stable"

help:
@echo "This project supports the following targets"
Expand All @@ -24,7 +25,7 @@ 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 functional33 - run the tests defined in the functional subdirectory with juju 3.3 requirements"
@echo " make functional3 - run the tests defined in the functional subdirectory with juju 3.x requirements"
@echo " make test - run lint, unittests and functional targets"
@echo ""

Expand Down Expand Up @@ -75,18 +76,14 @@ unittests:

functional: build
@echo "Executing functional tests using built charm at ${PROJECTPATH}"
@CHARM_LOCATION=${PROJECTPATH} tox -e func -- ${FUNC_ARGS}
@TEST_JUJU_CHANNEL=2.9/stable CHARM_LOCATION=${PROJECTPATH} tox -e func -- ${FUNC_ARGS}
Pjack marked this conversation as resolved.
Show resolved Hide resolved

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}

functional33-focal: build
@echo "Executing functional tests using built charm at ${PROJECTPATH} with juju 3.3 requirements"
@CHARM_LOCATION=${PROJECTPATH} tox -e func33-focal -- ${FUNC_ARGS}
functional3: build
@echo "Executing functional tests using built charm at ${PROJECTPATH} with juju 3.x requirements"
@TEST_JUJU_CHANNEL=${TEST_JUJU_CHANNEL} TEST_JUJU3=1 CHARM_LOCATION=${PROJECTPATH} tox -e func3 -- ${FUNC_ARGS}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a comment explaining the usage of TEST_JUJU3 similar to Robert's juju 3.4 support PR?


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 functional3
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
30 changes: 5 additions & 25 deletions tox.ini
chanchiwai-ray marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ passenv =
SNAP_HTTP_PROXY
SNAP_HTTPS_PROXY
OS_*
TEST_*

[testenv:dev-environment]
envdir = {toxinidir}/.venv
Expand Down Expand Up @@ -77,36 +78,15 @@ deps =
pytest-cov

[testenv:func]
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]
setenv =
TEST_JUJU_CHANNEL = 3.3/stable
[testenv:func3]
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
deps =
git+https://github.com/openstack-charmers/[email protected]#egg=zaza[juju-33]
-r {toxinidir}/tests/functional/requirements.txt

[testenv:func33-focal]
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
commands = 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
rgildein marked this conversation as resolved.
Show resolved Hide resolved
-r {toxinidir}/tests/functional/requirements.txt
Loading