Skip to content

test: migrate from Harness to Scenario - #71

Open
tonyandrewmeyer wants to merge 4 commits into
canonical:mainfrom
tonyandrewmeyer:w-error
Open

test: migrate from Harness to Scenario#71
tonyandrewmeyer wants to merge 4 commits into
canonical:mainfrom
tonyandrewmeyer:w-error

Conversation

@tonyandrewmeyer

@tonyandrewmeyer tonyandrewmeyer commented Jun 30, 2026

Copy link
Copy Markdown

Replaces Harness with Scenario (ops.testing Context/State) across the unit tests, and turns on -Werror (via filterwarnings = ["error"] in pyproject.toml) so deprecations and resource leaks fail the suite rather than piling up quietly.

ops[testing] is added to tests/unit/requirements.txt to pull in Scenario.

Also picks up a few drive-by reformats in tests/functional/test_charm.py from running the current Black against it.

@tonyandrewmeyer
tonyandrewmeyer marked this pull request as ready for review June 30, 2026 11:40
@tonyandrewmeyer
tonyandrewmeyer requested a review from a team as a code owner June 30, 2026 11:40
@jneo8

jneo8 commented Aug 4, 2026

Copy link
Copy Markdown

The functional test failed because of:

Install Juju
  /usr/bin/sudo snap install juju --channel=3.4/stable
  error: snap "juju" is not available on 3.4/stable but is available to install
         on the following channels:
  
         3.4/candidate  snap install --channel=3.4/candidate juju
         3.4/beta       snap install --channel=3.4/beta juju
         3.4/edge       snap install --channel=3.4/edge juju
  
         Please be mindful pre-release channels may include features not
         completely tested or implemented. Get more information with 'snap info
         juju'.
  /usr/bin/sudo snap install juju --channel=3.4/stable
  error: snap "juju" is not available on 3.4/stable but is available to install
         on the following channels:
  
         3.4/candidate  snap install --channel=3.4/candidate juju
         3.4/beta       snap install --channel=3.4/beta juju
         3.4/edge       snap install --channel=3.4/edge juju
  
         Please be mindful pre-release channels may include features not
         completely tested or implemented. Get more information with 'snap info
         juju'.
  /usr/bin/sudo snap install juju --channel=3.4/stable
  error: snap "juju" is not available on 3.4/stable but is available to install
         on the following channels:
  
         3.4/candidate  snap install --channel=3.4/candidate juju
         3.4/beta       snap install --channel=3.4/beta juju
         3.4/edge       snap install --channel=3.4/edge juju
  
         Please be mindful pre-release channels may include features not
         completely tested or implemented. Get more information with 'snap info
         juju'.
  /usr/bin/sudo snap install juju --channel=3.4/stable
  error: snap "juju" is not available on 3.4/stable but is available to install
         on the following channels:
  
         3.4/candidate  snap install --channel=3.4/candidate juju
         3.4/beta       snap install --channel=3.4/beta juju
         3.4/edge       snap install --channel=3.4/edge juju
  
         Please be mindful pre-release channels may include features not
         completely tested or implemented. Get more information with 'snap info
         juju'.
  /usr/bin/sudo snap install juju --channel=3.4/stable
  error: snap "juju" is not available on 3.4/stable but is available to install
         on the following channels:
  
         3.4/candidate  snap install --channel=3.4/candidate juju
         3.4/beta       snap install --channel=3.4/beta juju
         3.4/edge       snap install --channel=3.4/edge juju
  
         Please be mindful pre-release channels may include features not
         completely tested or implemented. Get more information with 'snap info
         juju'.
               

@jneo8

jneo8 commented Aug 4, 2026

Copy link
Copy Markdown

fix juju version issue: #73

claude and others added 4 commits August 17, 2026 17:16
Rewrite the unit tests to use ops.testing's Context/State (Scenario)
instead of the deprecated ops.testing.Harness. Behavioural coverage is
preserved (same assertions and edge cases); a couple of assertions are
adjusted for Scenario's richer model (relation databags include default
network data; actions surface results via Context.action_results).

Add the ops[testing] extra to the unit test requirements to pull in
Scenario.
Treat warnings as errors in the unit tests via filterwarnings = ["error"]
in [tool.pytest.ini_options]. No Harness-deprecation ignore is needed now
that the suite is migrated to Scenario.
ops 3.x dropped Python 3.8 support, so pip resolves the 2.x line on the
3.8 job, which still ships the Scenario actions.yaml leak. Narrow the
-Werror filter to that one warning until a 2.23.x backport or a move
to ops 3.8 makes it unnecessary.
The -Werror commit put filterwarnings in pyproject.toml's
[tool.pytest.ini_options], which is repo-wide. This repo runs pytest in
two tox environments -- tests/unit and tests/functional -- and
[testenv:func] invokes plain pytest with no filterwarnings override and
no ini of its own, so the functional suite was also being run under
-Werror. That is scope creep: the change is meant to promote warnings to
errors in the unit tests, not to fail functional runs on deprecations
raised inside juju/libjuju/zaza, which this charm does not control.

Exempt the functional suite in its existing conftest.py rather than
editing tox.ini, which is centrally managed from
canonical/solutions-engineering-automation and would be reverted by the
soleng-terraform bot.

Verified by adding a throwaway functional test that emits a
DeprecationWarning: it passes with this exemption and fails without it.
Unit suite unchanged: 42 passed, 18 subtests, coverage 92.73%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants