test: Migrate integration tests from pytest-operator to jubilant#167
Open
tonyandrewmeyer wants to merge 6 commits intocanonical:mainfrom
Open
test: Migrate integration tests from pytest-operator to jubilant#167tonyandrewmeyer wants to merge 6 commits intocanonical:mainfrom
tonyandrewmeyer wants to merge 6 commits intocanonical:mainfrom
Conversation
…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>
b0720f6 to
bc62d97
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
The documentation for charmhub is updatedurgent,trivial,complex)CHANGELOG.mdis updated with user-relevant changes.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.