Skip to content

test: Migrate integration tests from pytest-operator to jubilant#167

Open
tonyandrewmeyer wants to merge 6 commits intocanonical:mainfrom
tonyandrewmeyer:migrate-to-jubilant
Open

test: Migrate integration tests from pytest-operator to jubilant#167
tonyandrewmeyer wants to merge 6 commits intocanonical:mainfrom
tonyandrewmeyer:migrate-to-jubilant

Conversation

@tonyandrewmeyer
Copy link
Copy Markdown

@tonyandrewmeyer tonyandrewmeyer commented Mar 7, 2026

Applicable spec: N/A

Overview

This PR migrates the integration tests from pytest-operator and python-libjuju to Jubilant and pytest-jubilant.

Note that this was originally written by AI as part of exploratory work by Charm Tech to see how AI (particularly copilot) can help get charms migrated to Jubilant. This PR is an example of that work (a post will appear on Discourse very soon referencing this PR and will more details). However, I have also reviewed it and made tweaks, so am putting myself as the human in the loop, so to speak.

However, what is needed is review from someone who is familiar with the charm and its tests, which I am not.

I'm opening this against the upstream repo as the CI can't run in my fork, since it needs hosted runners. This will allow verifying that the tests do pass.

Rationale

Using Jubilant allows for simpler and more modern and maintainable tests. Most importantly, it allows running the integration tests against both Juju 3 and Juju 4.

Juju Events Changes

N/A

Module Changes

Only tests are changed.

Library Changes

N/A

Checklist

I don't believe I can tag a PR, as an external contributor. I'm unsure if you want a changelog entry for this or not, but can add one if so.

@tonyandrewmeyer tonyandrewmeyer marked this pull request as ready for review March 19, 2026 06:02
@tonyandrewmeyer tonyandrewmeyer requested a review from a team as a code owner March 19, 2026 06:02
@tonyandrewmeyer tonyandrewmeyer requested review from DeeKay3 and arturo-seijas and removed request for a team March 19, 2026 06:02
tonyandrewmeyer and others added 4 commits April 9, 2026 09:26
…ilant

- Replace juju (python-libjuju) and pytest-operator deps with jubilant
  and pytest-jubilant in pyproject.toml; update uv.lock
- Rewrite tests/integration/conftest.py:
  - Remove all async/await, pytest_asyncio, OpsTest, python-libjuju imports
  - Use jubilant.Juju (via pytest-jubilant's juju fixture) for synchronous
    model interactions
  - Replace wait_for_idle with juju.wait(jubilant.all_active, ...)
  - Replace model.deploy/add_relation with juju.deploy/juju.integrate
  - Remove run_action fixture; call juju.run() directly in app fixture
  - Rewrite nginx_integrator_app, app, ip_address_list fixtures to return
    app-name strings instead of python-libjuju Application objects
  - Rewrite unit_ip_list using juju.status() instead of model.get_status()
  - Rewrite charm_file fixture using pytest_jubilant.pack()
- Rewrite tests/integration/test_core.py:
  - Remove @pytest.mark.asyncio and async def from all tests
  - Remove @pytest.mark.abort_on_fail (pytest-operator specific)
  - Replace app.units[0].workload_status with juju.status() + is_active
  - Replace run_action and action.wait() with juju.run() + task.results
  - Replace ops_test.model.applications[...].set_config with juju.config()
- Fix tests/conftest.py: add default="" to --charm-file option

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The nginx-ingress-integrator charm enters "waiting" status ("waiting for
relation") before relations are added, so waiting for all_active times out.
Wait for either active or waiting, matching the original wait_for_idle behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The unscoped jubilant.all_active checks ALL apps in the model, including
nginx-ingress-integrator which is in "waiting" state until it gets
relations. Scope the waits to only the app being waited on.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tonyandrewmeyer
Copy link
Copy Markdown
Author

I've rebased, signed all commits, and things seem ok now (the doc failure is unrelated, I believe). I think this is over to you now, but let me know if you need anything more from me.

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.

1 participant