Repository navigation
feat: run a charm's events in a persistent worker process for ops.testing - #2902
Draft
tonyandrewmeyer wants to merge 2 commits into
Draft
tonyandrewmeyer wants to merge 2 commits into
tonyandrewmeyer wants to merge 2 commits into
Conversation
…ting Adds a private worker that runs one charm's events in its own interpreter, with the event and State crossing as JSON, so that charms with conflicting dependencies can be tested together. One worker serves every unit of an application, and is kept between events. A worker that crashes or times out raises IsolationError and isn't restarted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closing stdin flushes it, so after a write to a worker that had died the close raised BrokenPipeError and left stdout and stderr open. Adds tests for a worker that dies between events and for a charm module with no charm class or two, and drops python_path, which nothing uses yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tonyandrewmeyer
force-pushed
the
saddle/split-02-worker
branch
from
November 15, 2026 00:37
4bbd5cd to
7a4db44
Compare
This branch has not been deployed
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.
Adds a private worker that runs one charm's events in a separate Python process, with the event and
Statecrossing as JSON (the encoding from #2828), so that charms whose dependencies conflict can be tested together.scenario._isolation.Workeris what the multi-charm model will hold, one per application. It reads the charm's metadata from disk and never imports the charm in the test process. It starts the worker process on the first event and keeps it for later ones, and the unit ID comes with each event, so one process serves every unit.IsolationError, and isn't restarted. A charm that raises is different: the worker sends the traceback back and stays usable.print.IsolationErroris private for now, inscenario._juju_errors, and feat: add a typed JSON encoding of ops.testing State for worker processes #2828's version error is now a subclass of it.IsolationErrormoves totesting.errorswhen the API is exposed.Some things the proof of concept had are left out: a mode that starts a new process for every event, an idle timer, charm mocking, per-unit filesystems, and telling a charm's own exception apart from a worker failure. Those come in later PRs in the series.
The tests run the worker with fixture charms, including two that need conflicting versions of the same dependency, one that exits the process, one that never returns, and one that writes to fd 1.