test: Migrate integration tests from pytest-operator to jubilant#723
Open
tonyandrewmeyer wants to merge 17 commits intocanonical:mainfrom
Open
test: Migrate integration tests from pytest-operator to jubilant#723tonyandrewmeyer wants to merge 17 commits intocanonical:mainfrom
tonyandrewmeyer wants to merge 17 commits intocanonical:mainfrom
Conversation
Replace pytest-operator/python-libjuju with jubilant and pytest-jubilant for integration tests. All async patterns converted to synchronous. Generated with GitHub Copilot (Claude Sonnet 4.6).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pytest-jubilant already registers this option, so adding it again causes a ValueError during collection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These options are already registered in tests/conftest.py, causing ValueError on collection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The requests module is imported by test_charm.py, test_loki.py, and test_saml.py but was missing from the integration tox env deps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Jubilant uses 'juju integrate' which requires Juju 3.x. The reusable workflow defaults to 2.9/stable which doesn't have this command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Juju 3.6 requires strictly confined microk8s. Set the microk8s channel to 1.34-strict/stable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jubilant.Juju.run() raises TaskError when the action fails, so the test must use pytest.raises to catch it and inspect the task from the exception. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR migrates the charm’s integration test suite from pytest-operator/python-libjuju to jubilant/pytest-jubilant, aligning the tests with newer Juju versions and a more modern testing approach.
Changes:
- Replace pytest-operator async-based integration tests with synchronous Jubilant-based equivalents.
- Update
toxintegration/lint environments to includejubilant+pytest-jubilantand drop pytest-operator/libjuju-related deps. - Update CI integration workflow inputs to target specific charm/juju channels.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tox.ini |
Swaps integration/lint deps to use Jubilant tooling instead of pytest-operator/libjuju. |
tests/integration/conftest.py |
Reworks deployment/integration fixtures to use jubilant.Juju and pytest_jubilant.pack(). |
tests/integration/test_actions.py |
Migrates action tests from libjuju actions to Jubilant tasks. |
tests/integration/test_charm.py |
Migrates status checks and remote execs to Jubilant CLI/status APIs. |
tests/integration/test_s3.py |
Migrates S3 assertions and remote pebble plan retrieval to Jubilant CLI/tasks. |
tests/integration/test_saml.py |
Migrates SAML test config/waits to Jubilant while keeping HTTP flow intact. |
tests/integration/test_loki.py |
Migrates model status access and polling to Jubilant, making the test synchronous. |
docs/release-notes/artifacts/migrate_to_jubilant.yaml |
Adds a release-note artifact documenting the testing migration. |
.github/workflows/integration_test.yaml |
Adjusts integration workflow inputs (channel / juju-channel). |
Comment on lines
77
to
+80
| for target in prometheus_targets: | ||
| cmd = f"curl -m 10 http://{target}/metrics" | ||
| action = await indico_unit.run(cmd, timeout=15) | ||
| # Change this if upgrading Juju lib version to >= 3 | ||
| # See https://github.com/juju/python-libjuju/issues/707#issuecomment-1212296289 | ||
| result = action.data | ||
| code = result["results"].get("Code") | ||
| stdout = result["results"].get("Stdout") | ||
| stderr = result["results"].get("Stderr") | ||
| assert code == "0", f"{cmd} failed ({code}): {stderr or stdout}" | ||
| # CLIError is raised if the command fails, so a successful return means status 200. | ||
| juju.cli("exec", "--unit", f"{app}/0", "--", "bash", "-c", cmd) |
Contributor
Author
There was a problem hiding this comment.
This existed previously, so is really out of scope for a migration PR, but since the fix is small, I've included it as a drive-by.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
florentianayuwono
approved these changes
Apr 9, 2026
Contributor
Author
|
The license headers check is expecting a license in uv.lock, which seems wrong. I think this is ready, so handing over to you - let me know if there's anything else needed 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 test code is changed.
Library Changes
N/A
Checklist
The documentation for charmhub is updateddocs/release-notes/artifacts. If this PR does not require a change artifact, the PR has been tagged withno-release-note.urgent,trivial,complex)I don't believe I can add a label as an external contributor.