Skip to content

test: migrate integration tests to jubilant#782

Merged
cbartz merged 12 commits intomainfrom
test/migrate-integration-tests-to-jubilant
Apr 15, 2026
Merged

test: migrate integration tests to jubilant#782
cbartz merged 12 commits intomainfrom
test/migrate-integration-tests-to-jubilant

Conversation

@cbartz
Copy link
Copy Markdown
Collaborator

@cbartz cbartz commented Apr 14, 2026

Overview

Migrate charm integration tests to jubilant.

Most of the PR is

  • removing asyncio constructs
  • using jubilant
  • adding some mechanisms pytest-operator provided

Rationale

Current integration tests are quite flaky, which seems to be related to the usage of python-libjuju.
Also python-libjuju is no longer maintained and jubilant is required for juju 4 .

Checklist

  • The charm style guide was applied.
  • The contributing guide was applied.
  • The changes are compliant with ISD054 - Managing Charm Complexity
  • The documentation for charmhub is updated.
  • The PR is tagged with appropriate label (urgent, trivial, complex).
  • The changelog is updated with changes that affects the users of the charm.
  • The application version number is updated in github-runner-manager/pyproject.toml.

cbartz added 2 commits April 14, 2026 12:17
Remove pytest_operator, pytest_asyncio, and types-python-dateutil
from lint deps since nothing imports them after the jubilant migration.
Add jubilant so mypy can resolve its types.
cbartz added 8 commits April 14, 2026 13:07
The tox integration env was renamed from integration-juju3.6 to
integration during the jubilant migration, but the workflow files
still referenced the old name.
Python 3.12 enforces that typing.Generator takes exactly 3 type
arguments (YieldType, SendType, ReturnType). The juju fixture was
missing the ReturnType, causing a collection error in CI.
jubilant's juju.run() raises CLIError (not TimeoutError) when the
Juju CLI returns non-zero, e.g. when an action times out. Polling
loops that call juju.run() need to catch both CLIError and
TimeoutError to avoid crashing on transient action failures.

Affected: wait_for_runner_ready, _no_runners teardown fixture,
and _wait_for_runner_ready in prometheus metrics test.
Juju 3.6 deprecated --series for juju download. Replace
--series jammy with --base ubuntu@22.04 to fix the upgrade test.
pytest-operator previously set basetemp to the tox env tmp directory.
Without it, pytest defaults to /tmp which the juju snap cannot access,
causing juju download to fail with 'no such file or directory'.
…st-operator

pytest-operator provided the abort_on_fail marker which skips
remaining tests in a module after a failure. Without it, expensive
integration tests continue running even when earlier tests fail,
wasting CI resources.
wait_for_runner_ready returned as soon as 1 runner was online, even
when multiple were requested. This caused test_check_runner to
flake when asserting online == 2 before the second runner was ready.

Pass num_runners through from set_app_runner_amount so the wait
polls until all expected runners are online.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the charm’s integration/E2E test harness away from python-libjuju/pytest-operator to the jubilant CLI-driven approach, aiming to reduce flakiness and simplify the test runtime model management.

Changes:

  • Replace pytest-operator/async libjuju model interactions with synchronous jubilant operations across integration tests and fixtures.
  • Consolidate tox integration environments into a single [testenv:integration] and update GitHub Actions workflows to use it.
  • Refactor integration helpers (common.py, openstack.py) to operate on Jubilant models, unit/app names (strings), and synchronous polling utilities.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tox.ini Removes libjuju/pytest-operator integration env matrix; adds unified integration env and tweaks pytest tempdir usage.
tests/integration/test_prometheus_metrics.py Converts the Prometheus/Grafana/COS integration test flow to Jubilant-only operations.
tests/integration/test_multi_unit_same_machine.py Rewrites multi-unit colocated-machine test to use jubilant.status/add_unit/wait and unit-name based helpers.
tests/integration/test_e2e.py Converts E2E workflow dispatch test from async libjuju objects to app-name strings and sync flow.
tests/integration/test_charm_upgrade.py Refactors upgrade test to deploy/integrate/refresh via Jubilant and sync wait utilities.
tests/integration/test_charm_runner.py Converts runner action/workflow tests to Jubilant (run, config) and synchronous waiting.
tests/integration/test_charm_no_runner.py Replaces libjuju relation/secret operations with Jubilant equivalents and sync waits.
tests/integration/test_charm_fork_path_change.py Updates fork-path-change scenario to use app/unit names and Jubilant waits/config.
tests/integration/helpers/openstack.py Refactors OpenStack instance helper to be synchronous and to execute via Jubilant + unit-name strings.
tests/integration/helpers/common.py Reworks core helpers (deploy, exec-in-unit, workflow dispatch, wait loops) to synchronous Jubilant-based APIs.
tests/integration/conftest.py Removes OpsTest/model fixtures; introduces a temp-model Jubilant fixture and updates all dependent fixtures to return app names.
tests/conftest.py Adds --keep-models option and an abort_on_fail marker implementation to skip remaining tests in a module after failure.
.github/workflows/integration_test.yaml Switches CI workflow to run unified tox -e integration.
.github/workflows/e2e_test.yaml Switches CI workflow to run unified tox -e integration for E2E suite.

Comment thread .github/workflows/e2e_test.yaml
Comment thread tox.ini
Comment thread tests/conftest.py
@cbartz cbartz changed the title [WIP] test: migrate integration tests to jubilant test: migrate integration tests to jubilant Apr 15, 2026
@cbartz cbartz marked this pull request as ready for review April 15, 2026 05:15
@cbartz cbartz enabled auto-merge (squash) April 15, 2026 05:22
@cbartz cbartz merged commit 167d09f into main Apr 15, 2026
220 of 235 checks passed
@cbartz cbartz deleted the test/migrate-integration-tests-to-jubilant branch April 15, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants